flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harbs <harbs.li...@gmail.com>
Subject Re: FlexJS Image.source
Date Mon, 08 Aug 2016 14:22:42 GMT
Almost exactly the same as a string, but you first need to get an ObjectURL:

The four bold lines are pretty much the only difference:

            COMPILE::JS
            {
                if (_model.binary) {
                    var host:IUIBase = _strand as IUIBase;
                    (host.element as HTMLImageElement).addEventListener('load',
                        loadHandler, false);
                    host.addEventListener('sizeChanged',
                        sizeChangedHandler);
                    if(_objectURL)
                        URLUtils.revokeObjectURL(_objectURL);
                    var blob:Blob = new Blob([_model.binary.array]);
                    _objectURL = URLUtils.createObjectURL(blob);
                    (host.element as HTMLImageElement).src = _objectURL;
                }
            }

All the URLUtils class does is call URL.createObjectURL() and URL.revokeObjectURL(), but it
deals with the differences in browsers.

On Aug 8, 2016, at 5:04 PM, Alex Harui <aharui@adobe.com> wrote:

> How do you set a binary image to a <img> tag in HTML?
> 
> Otherwise, my first reaction is that this sounds like a separate
> BitmapImage component.
> 
> Thoughts?
> -Alex
> 
> On 8/8/16, 6:06 AM, "Harbs" <harbs.lists@gmail.com> wrote:
> 
>> I think it should be possible to specify a url source as a string.
>> 
>> On Aug 8, 2016, at 3:37 PM, Christofer Dutz <christofer.dutz@c-ware.de>
>> wrote:
>> 
>>> How about a "source" property accepting source objects having UrlSource
>>> and BinarySource implementations?
>>> 
>>> Chris
>>> 
>>> 
>>> 
>>> Von meinem Samsung Galaxy Smartphone gesendet.
>>> 
>>> 
>>> -------- Ursprüngliche Nachricht --------
>>> Von: Harbs <harbs.lists@gmail.com>
>>> Datum: 08.08.16 12:55 (GMT+01:00)
>>> An: dev <dev@flex.apache.org>
>>> Betreff: FlexJS Image.source
>>> 
>>> I’m implementing support for setting binary data to images.
>>> 
>>> Currently, Image (and ImageModel, etc.) has a source property and a
>>> urlChanged event.
>>> 
>>> I can do one of two things:
>>> 
>>> 1. I can change source to url and add a binary property. This would go
>>> along with a “binaryChanged” event.
>>> 2. I can change source to untyped and allow setting (and getting) of
>>> either strings or BinaryData. I think the event name should be changed
>>> to “sourceChanged”.
>>> 
>>> I started implementing it the first way, but I wanted to hear if anyone
>>> has a compelling reason to do it the second way.
>>> 
>>> Harbs
>> 
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message