Solved

To render SVG in Flex

Posted on 2008-10-30
5
4,816 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now