ActionScript 3: loading ai files dynamically?

Is it possible to dynamically load vector files, in this case .ai files in ActionScript 3? You can import them into the scene, but I want to do it dynamically, is there any way to do this?

+5
source share
3 answers

You can save vector data in XML format such as SVG (Illustrator supports this), and then load it with URLLoader, analyze the data and draw it in a Shape object.

There are several AS3 SVG parsers on the Internet: http://www.google.com/search?q=svg+as3

+1
source

Of course,

you can use the URLLoader class to load it at runtime:

var _loader:URLLoader;
var request:URLRequest = new URLRequest("http://yourserver.com/graphic.ai");
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(request);

    private function completeHandler(e:Event):void {
        var content:DisplayObject = _e.target.content;
        addChild(content);
    }

I have not tested it, but I think it works!

-1
source

All Articles