actionscript - Flex或Actionscript从外部Illustrator SWF访问内容

标签 actionscript flash adobe-illustrator

我从Illustrator SWF访问内容时遇到问题(我使用illustrator创建了swf,我导出了将图层另存为符号)。
当我使用Flash创建SWF文件时,可以使用此代码访问形状和符号。

我正在尝试获取并更改SWF文件中符号的颜色

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;                    

}


但是,当我使用Illustrator创建SWF文件时,它什么也不返回。

如何访问内容并更改Illustrator SWF的颜色

最佳答案

是否可以使用Illustrator导出AVM2(AS 3)swf?如果我错了,请纠正我,但据我所知Illustrator CS5仍会导出AVM1(AS 1和2)SWF。在AS3项目中,所有已加载的AS2电影均由flash.display.AVM1Movie类表示。此类没有显示链子级,它只是一个显示呈现的AVM1剪辑的DisplayObject。由此可见,您无法访问Illustrator定义的任何符号。

我不确定是否可以使用call()方法在AVM1Movie中调用某些方法。是否可以在Illustrator中添加AS2方法?可能不是...

您可以将每个元素导出为单个swf,也可以选择其他导出格式,例如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

        }
    }
}

关于actionscript - Flex或Actionscript从外部Illustrator SWF访问内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6672646/

相关文章:

apache-flex - 具有虚线边框的 Flex BorderContainer

flash - 从 as3 中的 POST 上传中获取 ProgressEvent

java - IntelliJ IDEA 12——查看调用堆栈

flash - actionscript3参数错误: Error #2015: Invalid BitmapData

flash - 使用 Brightcove 的 HTML5 视频

flash - Adobe Flash 创建 Flash 影片文件时出错 目标目录不存在

svg - 最小化SVG文件大小

.net - 如何以编程方式创建基本的 Adob​​e Illustrator 文件?

javascript - 柔性 : Children components disapear when SkinnableContainer is skinned

html - 具有透明度的 SVG