Building on Alex's response,
<js:UIBase>
<js:beads>
<js:ImageModel source="image/star.png" />
<js:PNGImageViewBead />
</js:beads>
</js:UIBase>
<js:UIBase>
<js:beads>
<js:ImageModel
source="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6Qd
vCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeK
qNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2h
B0SlBCBMQiB0UjIQA7"/>
</js:BlobImageViewBead />
</js:beads>
</js:UIBase>
or
<js:Image className="pngImage" />
<js:Image className="blobImage" />
Š
.pngImage {
src: "image/star.png";
IBeadView:
ClassReference("org.apache.flex.html.beads.PNGImageViewBead");
}
.blobImage {
src:
"data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGo
lfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQG
DsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCB
MQiB0UjIQA7";
IBeadView:
ClassReference("org.apache.flex.html.beads.BlobImageViewBead");
}
How much code is in common between BlobImageViewBead and PNGImageViewBead?
Can you make a base class that shares most of the code? I think this works
well when the two types of View beads are sufficiently different that
there isn't a lot of overlap, but if they are very close then I do wonder
if the effort to create two separate beads (and more, JPEGImageViewBead,
GIFImageViewBead, etc.) is worth it.
‹peter
On 8/8/16, 1:39 PM, "Christofer Dutz" <[email protected]> wrote:
>Can't we implement the url as well as the binary image using css?
>
>For examle a url source:
><img width="16" height="16" alt="star" src="image/star.png" />
>
>For example a binary source:
><img width="16" height="16" alt="star"
>src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvC
>chPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
>AAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeK
>qNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2
>hB0SlBCBMQiB0UjIQA7" />
>
>Both are named source and a UrlSource would be identical to the url and a
>BinarySource would be the base64 encoded presentation.
>I can't see how there should be problems with mapping this to Flash
>
>Chris
>
>-----Ursprüngliche Nachricht-----
>Von: Alex Harui [mailto:[email protected]]
>Gesendet: Montag, 8. August 2016 17:56
>An: [email protected]
>Betreff: Re: FlexJS Image.source
>
>
>
>On 8/8/16, 8:32 AM, "Harbs" <[email protected]> wrote:
>
>>How do I do that without ending up with double code in my app? If one
>>part of the app uses Image and another uses ImageWithBlob, that¹s going
>>to duplicate about 600 lines of code.
>
>Why wouldn't all of your code use ImageWithBlob? Also, why wouldn't
>ImageWithBlob subclass Image to share most of that code, and
>ImageViewWithBlob subclass ImageView?
>
>I should point out that, with beads, the outer component is really
>supposed to be a shell or wrapper. An exercise Peter and I try to do
>when creating new components is to make sure they are truly aggregations.
> IOW,
>
> <js:Image source="foo.png" />
>
>Which loads ImageModel and ImageView by default, should be replaceable in
>your MXML with
>
> <js:UIBase>
> <js:beads>
> <js:ImageModel source="foo.png" />
> <js:ImageView />
> </js:beads>
> </js:UIBase>
>
>All Image does is subclass UIBase and proxy the model's source property
>to the component's API surface.
>
>It sounds like in your app, you want one single Image component that
>takes a url or binary blob. We can't overload the source property right
>now, so you'll have to use a different property name like "binary", but
>essentially I think you want to allow:
>
> <js:UIBase>
> <js:beads>
> <js:ImageModelWithBlob binary="bunchofbytes" />
> <js:ImageViewWithBlob />
> </js:beads>
> </js:UIBase>
>
>Or even:
>
> <js:Image>
> <js:beads>
> <js:ImageModelWithBlob binary="bunchofbytes" />
> <js:ImageViewWithBlob />
> </js:beads>
> </js:Image>
>
>And then you could aggregate the last pattern by having ImageWithBlob
>subclass Image and proxy the binary property and maybe add a src property
>that switches between source and binary. That's why I would expect
>ImageModelWithBlob could subclass ImageModel and ImageViewWithBlog could
>subclass ImageView and only add support for "binary".
>
>
>
>FWIW, I used the property name "source" for Image because Flex did, and I
>don't like using abbreviations like "src" like the <img/> tag does, but
>if folks would rather use "src" or "url" for the String source and
>"source"
>as an Object that can take Blob or String, that's fine with me.
>
>-Alex
>