Solved

To render SVG in Flex

Posted on 2008-10-30
5
4,842 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

617 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