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

发布于 2024-11-19 18:08:28 字数 504 浏览 1 评论 0原文

我在访问 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 的内容并更改其颜色

I have problem accessing content from an Illustrator SWF(I create the swf using illustrator, I export I Save layers as symbols).
When I create 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绝對不後悔。 2024-11-26 18:08:28

是否可以使用 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

        }
    }
}

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

        }
    }
}
幽梦紫曦~ 2024-11-26 18:08:28

最好的选择是将对象从 Illustrator 复制/粘贴到 Flash CS。这样,矢量对象就可以作为 AS3 Shape 对象移植。您还可以将它们拆分为不同的符号等...

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文