开发者

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 to the stage, but I want to do this dynamically, is th开发者_C百科ere a way to do this?


You could save the vector data in an XML format such as SVG (Illustrator supports this), then load it using URLLoader, parse the data and draw it into a Shape object.

There are a few AS3 SVG parsers available on the web: http://www.google.com/search?q=svg+as3


For AI (and many other formats) you can use Zaail-lib. It's old and possibly legacy but it works. http://zaalabs.com/2010/04/introducing-zaail-40-image-format-support-for-flash/


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 didn't tested it, but I think this works!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜