开发者

Flex or Actionscript Accessing content from a external Illustrator SWF

I have problem accessing content from an Illustrator SWF(I create the swf using illustrator, I export I Save layers as symbols). When I crea开发者_开发知识库te my swf file using flash i can access shapes and symbols using this code.

I am trying to get and change the color of a symbols in my swf file

var flashMovie:Sprite = this.content as Sprite;
for (var i:int = 0; i < flashMovie.numChildren; i++) 
{                           
flashMovie.getChildAt(i).name;
flashMovie.getChildAt(i).transform.colorTransform.color;                    

}

But when I create my swf file using Illustrator it return nothing.

How can can i access the content and change the color of an Illustrator SWF


Is it possible to export AVM2 (AS 3) swf's using Illustrator? Correct me if i am wrong, but as far as I know Illustrator CS5 still exports AVM1 (AS 1 & 2) swf's. Within a AS3 Project all loaded AS2 Movies are represented by the flash.display.AVM1Movie class. This class has no display-chain children, it is just a DisplayObject showing the rendered AVM1 Clip. From this it follows that you can't access any symbols defined by Illustrator.

I am not quite sure if you can use the call() Method to invoke some Method within a AVM1Movie. Is it possible to add AS2 methods within Illustrator? Probably not...

You can either export every element as single swf, or choose some other export format such as svg.

package
{
    import flash.display.AVM1Movie;
    import flash.display.DisplayObject;
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.net.URLRequest;
    import flash.utils.describeType;

    public class AIImportDemo extends Sprite
    {
        private var __loader:Loader = new Loader();
        public function AIImportDemo()
        {
            super();
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE
            __loader.contentLoaderInfo.addEventListener(Event.COMPLETE,__onComplete);
            __loader.load(new URLRequest('assets/myAIExport.swf'));
        }
        private function __onComplete($e:Event):void{
            addChild(__loader);
            trace(describeType(__loader.content));
            trace("is MovieClip "+ (__loader.content is MovieClip)); // false   
            trace("is Sprite "+ (__loader.content is Sprite)); // false
            trace("is Shape "+ (__loader.content is Shape)); // false
            trace("is AVM1Movie "+ (__loader.content is AVM1Movie)); // true
            trace("is Display Object "+(__loader.content is DisplayObject)); // true

        }
    }
}


Your best bet is to Copy/Paste your objects from Illustrator to Flash CS. That way vector objects may be ported over as AS3 Shape objects. You can also split them to different Symbols etc...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜