You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2016/04/29 18:34:11 UTC

Loading svg image at runtime

I am trying to load an svg image.
var request:URLRequest = new URLRequest('image.svg');
var imageLoader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext();
loaderContext.checkPolicyFile = true;
imageLoader.load(request,loaderContext);

in the Console I see this:
[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression

and it's just keep popping up.

Can we load svg images into Flex application?

Thanks

Re: Loading svg image at runtime

Posted by jude <fl...@gmail.com>.
or, or we could get the ast from a flex spark skin and take the ast and
reverse the process to produce the SVG.

in flex your states are usually a one to one ratio with html pseudo states,
normal, over, down, active.
On Apr 29, 2016 7:11 PM, "jude" <fl...@gmail.com> wrote:

> hmm if it's a simple mapping we may be able to use some of the classes out
> there like as blocks or claus whalers swf utils to parse the SVG xml into
> swf tags then create that class at runtime? this is probably overkill but
> if we are trying to have Flex JS swf and js look the same it may be worth
> looking into.
>
> Was considering making SVG skins for each of the Flex components. Om made
> the first one for button a few years back. In my tests it worked well.
> On Apr 29, 2016 4:54 PM, "Alex Harui" <ah...@adobe.com> wrote:
>
>>
>>
>> On 4/29/16, 2:01 PM, "jude" <fl...@gmail.com> wrote:
>>
>> >Isn't SVG markup? it should load as plain text. You may need to try
>> >different content types for it to load correctly. There are a few SVG to
>> >AS3 importer classes online.
>>
>> Embedded SVG is transcoded to a Sprite.
>>
>> >
>> >What's being used in three MXML compiler that's used to convert embedded
>> >SVG to a Sprite?
>>
>> AIUI, it is a simple mapping of SVG tags to SWF tags.  Not all SVG tags
>> are supported.
>>
>> >Can we convert that code into an AS3 class we can use at
>> >runtime?
>>
>> The result of any embed is a class.
>>
>> -Alex
>>
>>

Re: Loading svg image at runtime

Posted by jude <fl...@gmail.com>.
hmm if it's a simple mapping we may be able to use some of the classes out
there like as blocks or claus whalers swf utils to parse the SVG xml into
swf tags then create that class at runtime? this is probably overkill but
if we are trying to have Flex JS swf and js look the same it may be worth
looking into.

Was considering making SVG skins for each of the Flex components. Om made
the first one for button a few years back. In my tests it worked well.
On Apr 29, 2016 4:54 PM, "Alex Harui" <ah...@adobe.com> wrote:

>
>
> On 4/29/16, 2:01 PM, "jude" <fl...@gmail.com> wrote:
>
> >Isn't SVG markup? it should load as plain text. You may need to try
> >different content types for it to load correctly. There are a few SVG to
> >AS3 importer classes online.
>
> Embedded SVG is transcoded to a Sprite.
>
> >
> >What's being used in three MXML compiler that's used to convert embedded
> >SVG to a Sprite?
>
> AIUI, it is a simple mapping of SVG tags to SWF tags.  Not all SVG tags
> are supported.
>
> >Can we convert that code into an AS3 class we can use at
> >runtime?
>
> The result of any embed is a class.
>
> -Alex
>
>

Re: Loading svg image at runtime

Posted by Alex Harui <ah...@adobe.com>.

On 4/29/16, 2:01 PM, "jude" <fl...@gmail.com> wrote:

>Isn't SVG markup? it should load as plain text. You may need to try
>different content types for it to load correctly. There are a few SVG to
>AS3 importer classes online.

Embedded SVG is transcoded to a Sprite.

>
>What's being used in three MXML compiler that's used to convert embedded
>SVG to a Sprite? 

AIUI, it is a simple mapping of SVG tags to SWF tags.  Not all SVG tags
are supported.

>Can we convert that code into an AS3 class we can use at
>runtime?

The result of any embed is a class.

-Alex


Re: Loading svg image at runtime

Posted by jude <fl...@gmail.com>.
Isn't SVG markup? it should load as plain text. You may need to try
different content types for it to load correctly. There are a few SVG to
AS3 importer classes online.

What's being used in three MXML compiler that's used to convert embedded
SVG to a Sprite? Can we convert that code into an AS3 class we can use at
runtime?

As a last case scenario you could pass the SVG to the web browser or
internal browser in an AIR app and draw that to a bitmap and pass that back
to your app.
On Apr 29, 2016 3:49 PM, "Alex Harui" <ah...@adobe.com> wrote:

> Did you end up embedding the SVG file?  If so, I believe it gets
> transcoded into a Sprite.  There are various ways to take a bitmap
> snapshot of a Sprite, but also keep in mind that if you were using the
> image array to cache bitmaps being loaded, now that they are embedded, you
> no longer need that cache.
>
> -Alex
>
> On 4/29/16, 11:19 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >How can I store a content of an svg image in an array?
> >
> >With png images I am doing something like this:
> >
> >Loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
> >CompleteHandler);
> >private function CompleteHandler(event:Event):void
> >{
> >    imageArray.addItem(event.currentTarget.content.bitmapData);
> >}
> >
> >Thanks
> >
> >On Fri, Apr 29, 2016 at 12:23 PM mark goldin <ma...@gmail.com>
> >wrote:
> >
> >> I see, thanks.
> >>
> >> On Fri, Apr 29, 2016 at 12:15 PM Alex Harui <ah...@adobe.com> wrote:
> >>
> >>> IIRC, SVG is only supported when embedded.
> >>>
> >>> In FlexJS, we might have an SVG loader some day.
> >>>
> >>> -Alex
> >>>
> >>> On 4/29/16, 9:34 AM, "mark goldin" <ma...@gmail.com> wrote:
> >>>
> >>> >I am trying to load an svg image.
> >>> >var request:URLRequest = new URLRequest('image.svg');
> >>> >var imageLoader:Loader = new Loader();
> >>> >var loaderContext:LoaderContext = new LoaderContext();
> >>> >loaderContext.checkPolicyFile = true;
> >>> >imageLoader.load(request,loaderContext);
> >>> >
> >>> >in the Console I see this:
> >>> >[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression
> >>> >
> >>> >and it's just keep popping up.
> >>> >
> >>> >Can we load svg images into Flex application?
> >>> >
> >>> >Thanks
> >>>
> >>>
>
>

Re: Loading svg image at runtime

Posted by Alex Harui <ah...@adobe.com>.
Did you end up embedding the SVG file?  If so, I believe it gets
transcoded into a Sprite.  There are various ways to take a bitmap
snapshot of a Sprite, but also keep in mind that if you were using the
image array to cache bitmaps being loaded, now that they are embedded, you
no longer need that cache.

-Alex

On 4/29/16, 11:19 AM, "mark goldin" <ma...@gmail.com> wrote:

>How can I store a content of an svg image in an array?
>
>With png images I am doing something like this:
>
>Loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
>CompleteHandler);
>private function CompleteHandler(event:Event):void
>{
>    imageArray.addItem(event.currentTarget.content.bitmapData);
>}
>
>Thanks
>
>On Fri, Apr 29, 2016 at 12:23 PM mark goldin <ma...@gmail.com>
>wrote:
>
>> I see, thanks.
>>
>> On Fri, Apr 29, 2016 at 12:15 PM Alex Harui <ah...@adobe.com> wrote:
>>
>>> IIRC, SVG is only supported when embedded.
>>>
>>> In FlexJS, we might have an SVG loader some day.
>>>
>>> -Alex
>>>
>>> On 4/29/16, 9:34 AM, "mark goldin" <ma...@gmail.com> wrote:
>>>
>>> >I am trying to load an svg image.
>>> >var request:URLRequest = new URLRequest('image.svg');
>>> >var imageLoader:Loader = new Loader();
>>> >var loaderContext:LoaderContext = new LoaderContext();
>>> >loaderContext.checkPolicyFile = true;
>>> >imageLoader.load(request,loaderContext);
>>> >
>>> >in the Console I see this:
>>> >[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression
>>> >
>>> >and it's just keep popping up.
>>> >
>>> >Can we load svg images into Flex application?
>>> >
>>> >Thanks
>>>
>>>


Re: Loading svg image at runtime

Posted by mark goldin <ma...@gmail.com>.
How can I store a content of an svg image in an array?

With png images I am doing something like this:

Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, CompleteHandler);
private function CompleteHandler(event:Event):void
{
    imageArray.addItem(event.currentTarget.content.bitmapData);
}

Thanks

On Fri, Apr 29, 2016 at 12:23 PM mark goldin <ma...@gmail.com> wrote:

> I see, thanks.
>
> On Fri, Apr 29, 2016 at 12:15 PM Alex Harui <ah...@adobe.com> wrote:
>
>> IIRC, SVG is only supported when embedded.
>>
>> In FlexJS, we might have an SVG loader some day.
>>
>> -Alex
>>
>> On 4/29/16, 9:34 AM, "mark goldin" <ma...@gmail.com> wrote:
>>
>> >I am trying to load an svg image.
>> >var request:URLRequest = new URLRequest('image.svg');
>> >var imageLoader:Loader = new Loader();
>> >var loaderContext:LoaderContext = new LoaderContext();
>> >loaderContext.checkPolicyFile = true;
>> >imageLoader.load(request,loaderContext);
>> >
>> >in the Console I see this:
>> >[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression
>> >
>> >and it's just keep popping up.
>> >
>> >Can we load svg images into Flex application?
>> >
>> >Thanks
>>
>>

Re: Loading svg image at runtime

Posted by mark goldin <ma...@gmail.com>.
I see, thanks.

On Fri, Apr 29, 2016 at 12:15 PM Alex Harui <ah...@adobe.com> wrote:

> IIRC, SVG is only supported when embedded.
>
> In FlexJS, we might have an SVG loader some day.
>
> -Alex
>
> On 4/29/16, 9:34 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >I am trying to load an svg image.
> >var request:URLRequest = new URLRequest('image.svg');
> >var imageLoader:Loader = new Loader();
> >var loaderContext:LoaderContext = new LoaderContext();
> >loaderContext.checkPolicyFile = true;
> >imageLoader.load(request,loaderContext);
> >
> >in the Console I see this:
> >[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression
> >
> >and it's just keep popping up.
> >
> >Can we load svg images into Flex application?
> >
> >Thanks
>
>

Re: Loading svg image at runtime

Posted by Alex Harui <ah...@adobe.com>.
IIRC, SVG is only supported when embedded.

In FlexJS, we might have an SVG loader some day.

-Alex

On 4/29/16, 9:34 AM, "mark goldin" <ma...@gmail.com> wrote:

>I am trying to load an svg image.
>var request:URLRequest = new URLRequest('image.svg');
>var imageLoader:Loader = new Loader();
>var loaderContext:LoaderContext = new LoaderContext();
>loaderContext.checkPolicyFile = true;
>imageLoader.load(request,loaderContext);
>
>in the Console I see this:
>[SWF] /assets/casemanagement/closed.svg - 0 bytes after decompression
>
>and it's just keep popping up.
>
>Can we load svg images into Flex application?
>
>Thanks