Solved

To render SVG in Flex

Posted on 2008-10-30
5
4,827 Views
Last Modified: 2013-11-11
How I can load an SVG to setting image source property dinamicaly?
In the code attached there are two case: the first where I used the bindable var works but the second where I set the property source doesn't work.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="onComplete()">
	<mx:Script>
		<![CDATA[
			[Embed(source='../images/MB1.svg')]
			[Bindable]
			private var svg:Class;
			
			private function onComplete():void
			{
				image2.source = "@Embed(source='../images/MB1.svg')";
			}
		]]>
	</mx:Script>
	
	<mx:Image id="image1" source="{svg}" x="42" y="21" width="206" height="218"/>
	<mx:Image id="image2" x="42" y="278" width="206" height="229"/>
	
</mx:Application>

Open in new window

MB1.jpg
0
Comment
Question by:rfedericoni
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Gary Benade
ID: 22866645
There are free 3rd party svg rendering libraries available:
http://code.google.com/p/as3svgrendererlib/
0
 

Author Comment

by:rfedericoni
ID: 22867308
I don't need 3rd party libraries because SVG it's natively supported by Flex 3.. my problem it's to understand how utilise it.
0
 

Author Comment

by:rfedericoni
ID: 22902454
The solution it's this:
Flex supports importing GIF, JPEG, PNG, and SWF files at run time, and embedding GIF, JPEG, PNG, SVG, and SWF at compile time.
0
 
LVL 19

Expert Comment

by:Gary Benade
ID: 22902518
That's not the solution, that's the problem. I am well aware of the limitations of flex's native SVG support but just because something isn't supported out of the box doesn't mean it can't be done. The link above is one of the many solutions being developed by third parties, you just need to look around a bit.
0
 
LVL 19

Accepted Solution

by:
Gary Benade earned 500 total points
ID: 22903121
From your demo svg file I have made the assumption based on the fact that your SVG was generated from a PDF that what you are ultimately trying to do is show a PDF in flex.
The solution may be as simple as converting to SWF instead of SVG

http://www.swftools.org/
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question