从 Flash 8 到 CS3

发布于 2024-08-13 21:38:28 字数 161 浏览 3 评论 0原文

使用 Flash 8 多年后,我将在工作中转向 CS3。我知道我必须学习 AS 3.0,所以有人对主要/最显着的变化有任何好的参考资料或摘要吗?另外,对于 flash 环境有什么提示/技巧吗?在 CS3 中花了几分钟后,我注意到你不能直接将动作脚本附加到按钮,这对我来说是新的。还有其他需要注意的此类陷阱吗?

After many years of using Flash 8, I'm moving to CS3 at work. I know I'll have to learn AS 3.0 so, does anyone have any good references or summaries of the major/most noticeable changes? Also, are there any tips/tricks for the flash environment? After spending a few minutes in CS3, I noticed that you can't directly attach actionscript to a button, which is new to me. Any other such pitfalls to watch over?

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

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

发布评论

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

评论(3

孤君无依 2024-08-20 21:38:28

大约 3 个月前,我进行了彻底的转变,以下是一些帮助我快速提升的事情:

1)在类文件中执行所有操作

很多 AS3 教程只处理粘贴在时间轴上的代码(其中我无法忍受,因为现在你必须寻找你需要的进口物品),但对于快速的小东西来说是可以的。从长远来看,主要在类文件中工作效果更好。学习类的工作原理为我打开了一扇大门,这与我第一次发现 AS2 中的函数时的感觉/体验相同:)

2) 将图形保留在库中并远离工作区

示例,您有一个 jpg、gif、png 文件您刚刚导入到您的库中。制作了一个 movieClip 并给它一个类名(MyButton)。现在,下面的代码将为您将图形放入工作区中:

var myButton:MovieClip = new MyButton();
    myButton.x = 6;
    myButton.y = 22;
    myButton.buttonMode = true;

addChild(myButton);    

3) 习惯 AS3 中的新按钮代码

这是我们所有新皈依者都必须痛苦处理的事情,但现在它是小菜一碟:)

myButton.addEventListener(MouseEvent.MOUSE_UP, clickThis);

function clickThis(event:MouseEvent):void
        {
            navigateToURL(new URLRequest("form.html"), "_self");
            //navigateToURL(request, '_self');
        }

4) 确保在使用后删除事件监听器

我花了一些时间来包装我周围的这个...为什么要删除它们?哦,它们仍在后台运行,当我再次聆听时,我会收到各种变异错误。

private function volDown(e:MouseEvent):void
    {
        masker.width = volControl.mouseX;
        userVolume = (masker.width / 100) * 1;
        volControl.addEventListener(MouseEvent.MOUSE_MOVE, volMove);
    }

private function volUp(e:MouseEvent):void
    {
        lastVolPoint = masker.width;
        setVolume(userVolume);
        e.updateAfterEvent();
        volControl.removeEventListener(MouseEvent.MOUSE_MOVE, volMove);
    }

5)不要忘记传递事件

我不是一个职业程序员,这引起了很多悲伤,我很高兴我已经摆脱了这种分娩的痛苦:

myButton.addEventListener(MouseEvent.MOUSE_UP, clickThis);

由于 clickThis 函数是通过事件启动的,所以你有像这样传递: event:MouseEvent 到其中:

function clickThis(event:MouseEvent):void

因为下面的代码会抛出可怕的 AS3“访问未定义属性”错误,这是 AS3 新人总是会遇到的。

function clickThis():void

6) 在 StackOverflow 上阅读并发布问题......很多!

顺便说一句,我仍然是一个菜鸟,最初是一名设计师,然后是 AS2 开发人员,我仍然不知道为什么我们把 :void 放在函数名称后面..如果我们有类似的编码背景,我希望这一切都会有所帮助:)

I made the total switch just about 3 months ago, here are some things that helped me ramp up rather quickly:

1) Do everything in Class files

A lot of AS3 tutorials out there deal with just code pasted on the timeline (which I can't stand because now you have to hunt for what import you need), but is fine for quick tiny stuff. In the long run it's way better work primarily in Class files. Learning how Classes work opened a huge door for me, it was the same feeling/experience I had when I first discovered Functions in AS2 :)

2) Keep graphics in library and off the workspace

Example, you have a jpg, gif, png file you just imported into your library. Made a movieClip and gave it a class name(MyButton). Now the code below will place the graphic into the workspace for you:

var myButton:MovieClip = new MyButton();
    myButton.x = 6;
    myButton.y = 22;
    myButton.buttonMode = true;

addChild(myButton);    

3) Get use to the new button code in AS3

It's something all of us new converts had to deal with painfully, but now it's a piece of cake :)

myButton.addEventListener(MouseEvent.MOUSE_UP, clickThis);

function clickThis(event:MouseEvent):void
        {
            navigateToURL(new URLRequest("form.html"), "_self");
            //navigateToURL(request, '_self');
        }

4) Make sure you remove Event Listeners after use

It took me a bit to wrap my around this one... remove em why? Oh they are still running in the background and when I listen again I'll get all kinds of mutated errors.

private function volDown(e:MouseEvent):void
    {
        masker.width = volControl.mouseX;
        userVolume = (masker.width / 100) * 1;
        volControl.addEventListener(MouseEvent.MOUSE_MOVE, volMove);
    }

private function volUp(e:MouseEvent):void
    {
        lastVolPoint = masker.width;
        setVolume(userVolume);
        e.updateAfterEvent();
        volControl.removeEventListener(MouseEvent.MOUSE_MOVE, volMove);
    }

5) Don't forget to pass Events

I'm not a programmer by trade and this has caused so much grief, I'm glad I'm done with this birthing pain:

myButton.addEventListener(MouseEvent.MOUSE_UP, clickThis);

Since the clickThis function is launched via an Event, you have to pass: event:MouseEvent into it like so:

function clickThis(event:MouseEvent):void

Because the code below will throw the dreaded AS3 "Access of undefined property" error that new AS3 guys will always run into.

function clickThis():void

6) Read and post questions on StackOverflow... a lot!

btw I'm still a noob and originally a designer then AS2 dev, I still don't know why we put :void behind a function name.. if we have similar coding backgrounds I hope all that helps :)

━╋う一瞬間旳綻放 2024-08-20 21:38:28

我建议您查看 Adob​​e devnet 上的 ActionScript 语言迁移页面。它提供了很多关于 ActionScript 3 的关键更改的文章。

要回答按钮上的操作问题,这不再有效(并且在 ActionScript 2 中已经不是最好的方法了)。 AS3要求代码集中在时间轴上。因此,为了给按钮一些操作,您需要给它一个实例名称并为 CLICK 事件添加一个事件侦听器,如下所示:

function doSomething ( event:MouseEvent ):void
{
    trace( "test" );
}
myButton.addEventListener( MouseEvent.CLICK, doSomething );

I suggest you to look at the ActionScript language migration page on the Adobe devnet. It offers quite a lot articles about the key changes with ActionScript 3.

To answer your problem with the actions on a button, this no longer works (and was already with ActionScript 2 not the best way to do it). AS3 requires the code to be centralized on the timeline. So for giving a button some action, you'll need to give it an instance name and add an event listener for the CLICK event, like this:

function doSomething ( event:MouseEvent ):void
{
    trace( "test" );
}
myButton.addEventListener( MouseEvent.CLICK, doSomething );
王权女流氓 2024-08-20 21:38:28

获取 Actionscript 3 IDE。例如 Flash Builder、FlashDevlop 或 FDT。这将迫使你学得非常快。

Get an Actionscript 3 IDE. Such as Flash Builder, FlashDevlop, or FDT. This will force you to learn really fast.

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