Do you get the attached screens? I don't see them ...
I'm sorry, I put it in text:

De: Maria Jose Esteve <[email protected]<mailto:[email protected]>>
Enviado el: sábado, 27 de junio de 2020 15:00
Para: [email protected]<mailto:[email protected]>
Asunto: Image, does not flush when link value is null or blank

Hi,
Setting up a detail form, where I have a jewel image component, I have noticed 
that when a "" (empty string) or null is assigned to the src property, the 
image is not emptied..
I have detected the origin of the problem and I present a possible solution, to 
see how you see it.

When the url / src is "" or null it does not enter through the if (_model.url) 
and consequently it does not call applyImageDate and the img is not updated:

[ImageViewBase.as]

        protected function handleUrlChange(event:Event):void
        {
            COMPILE::SWF
            {
                if (_model.url) {
                    setupLoader();
                    loader.load(new URLRequest(_model.url));
                }
            }
            COMPILE::JS
            {
                if (_model.url) {
                    setupLoader();
                    (host as IImage).applyImageData(_model.url);
                }
            }
        }


[jewel.Image.as]

        /**
         * @royaleignorecoercion HTMLImageElement
         */
        COMPILE::JS
        override public function applyImageData(binaryDataAsString:String):void
        {
            (element as HTMLImageElement).src = binaryDataAsString;
        }
    }

If when the url is "" or null we directly call the applyImageData function 
everything works perfectly (commented lines //)

 }else if(sw == 1){
                //avatarTmp.applyImageData("");
                lblStep.text = "Blanco";
                avatarTmp.src = "";
            }else if(sw == 2){
                //avatarTmp.applyImageData(null);
                lblStep.text = "Null";
                avatarTmp.src = null;


If in ImageViewBase.as we changed the code:

        protected function handleUrlChange(event:Event):void
        {
            COMPILE::SWF
            {
                if (_model.url) {
                    setupLoader();
                    loader.load(new URLRequest(_model.url));
                }
            }
            COMPILE::JS
            {
                if (_model.url) {
                    setupLoader();
                    (host as IImage).applyImageData(_model.url);
                }
            }
        }

For this other, It would be correct?

            COMPILE::JS
            {
                if (_model.url)
                    setupLoader();
                (host as IImage).applyImageData(_model.url);

            }

I haven't tested it for SWC but I think it might be feasible too. (In my Flex 
application it works when I assign a null if it empties the image)
As you see?

Hiedra.

Reply via email to