Hi,

I'm checking it, and I found that setting src to null makes the browser
throw an error: Failed to load resource: net::ERR_FILE_NOT_FOUND
(also tried to set to '' but it didn't change anything)

so that doesn't seem the solution Royale should do by default, since apps
will be getting lots of errors in browsers console.

Searching on the internet people use to remove the image from the DOM or
remove from display, I think we can do that. What do others think about it?

Also since we are adding ErrorImage.as bead, we can manage it there. So a
normal image control only can load an image.
If people want to set it to null or empty string and remove it add
ErrorImage bead and display the alternative image.
Also we could have another "RemoveImageFromDisplay" and
"RemoveImageFromDOM" bead that instead of add alternative image will remove
from DOM or display or DOM respectively.

thoughts?




El sáb., 27 jun. 2020 a las 18:10, Maria Jose Esteve (<[email protected]>)
escribió:

> 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.
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Reply via email to