Share Posted January 17, 2013 Hi, I found a great library for loading external SVG graphics: http://code.google.c...svgrendererlib/ It's very simple, using something like this code: import com.lorentz.SVG.display.SVGDocument; import com.lorentz.processing.ProcessExecutor; ProcessExecutor.instance.initialize(stage); ProcessExecutor.instance.percentFrameProcessingTime = 0.9; var svgDocument:SVGDocument = new SVGDocument(); svgdocument.load('graphics/coloredtoucan.svg'); addChild(svgDocument); I was looking at loading it using LoaderMax, but couldn't get anywhere with SWFLoader and ImageLoader. Any suggestions no how I might achieve this? Link to comment Share on other sites More sharing options...
Author Share Posted January 17, 2013 Ok I found a way round it, using DataLoader. It just fetches the raw SVG data and converts it to a graphic import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; import com.lorentz.SVG.display.SVGDocument; import com.lorentz.processing.ProcessExecutor; //create SVG graphic ProcessExecutor.instance.initialize(stage); ProcessExecutor.instance.percentFrameProcessingTime = 0.9; var svgDocument:SVGDocument = new SVGDocument(); //create a LoaderMax named "mainQueue" and set up onprogress, onComplete and onerror listeners var queue:LoaderMax = new LoaderMax({name:"mainQueue",onprogress:progressHandler,onComplete:completeHandler,onerror:errorHandler}); //append several loaders queue.append( new DataLoader("graphics/coloredtoucan.svg", {name:"childClip"}) ); //start loading queue.load(); function progressHandler(event:LoaderEvent):void { // trace("progress: " + event.target.progress); } function completeHandler(event:LoaderEvent):void { svgdocument.parse(LoaderMax.getContent("childClip")); addChild(svgDocument); TweenMax.from(svgDocument,1,{alpha:0}); } function errorHandler(event:LoaderEvent):void { trace("error occured with " + event.target + ": " + event.text); } 1 Link to comment Share on other sites More sharing options...
Share Posted November 13, 2013 Hello, I have the same estructure, but appart of this i would like to load svg by string, where the string is the svg text - tag itself, no the path of the file, so instead of queue.append( new DataLoader("graphics/coloredtoucan.svg", {name:"childClip"}) ); something like queue.append( new DataLoader("("<svg ...../>",", {format:"text"}) ); try differents options, but no one works. Someone knows if that is possible? Cheers! Link to comment Share on other sites More sharing options...
Share Posted November 13, 2013 If you have the text, there's no need to "load" it at all, so I'm kinda confused about your goal. LoaderMax is for loading external assets. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now