简体   繁体   English

从Flash 8到CS3

[英]Going from Flash 8 to CS3

After many years of using Flash 8, I'm moving to CS3 at work. 在使用Flash 8多年之后,我开始使用CS3。 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? 我知道我将必须学习AS 3.0,所以有人对主要/最明显的变化有任何好的参考或总结吗? Also, are there any tips/tricks for the flash environment? 另外,是否有关于Flash环境的提示/技巧? After spending a few minutes in CS3, I noticed that you can't directly attach actionscript to a button, which is new to me. 在CS3中花了几分钟之后,我注意到您不能直接将动作脚本附加到按钮上,这对我来说是新的。 Any other such pitfalls to watch over? 还有其他需要注意的陷阱吗?

I made the total switch just about 3 months ago, here are some things that helped me ramp up rather quickly: 大约3个月前,我进行了总体转换,以下是一些有助于我快速提升速度的事情:

1) Do everything in Class files 1)在Class文件中执行所有操作

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. 许多AS3教程只处理粘贴在时间轴上的代码(我无法忍受,因为现在您必须寻找所需的导入内容) ,但是对于快速的小东西来说很好。 In the long run it's way better work primarily in Class files. 从长远来看,最好是在Class文件中更好地工作。 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 :) 学习班级的工作方式为我打开了一扇巨大的门,这与我第一次在AS2中发现函数时的感觉/体验一样:)

2) Keep graphics in library and off the workspace 2)将图形保存在库中并且不在工作区中

Example, you have a jpg, gif, png file you just imported into your library. 例如,您有一个刚导入到库中的jpg,gif,png文件。 Made a movieClip and gave it a class name( MyButton ). 制作了movieClip,并为其指定了一个类名( 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 3)熟悉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 4)确保使用后删除事件监听器

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 5)不要忘记通过活动

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: 由于clickThis函数是通过事件启动的,因此您必须像这样将event:MouseEvent传递给它:

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. 因为下面的代码将引发可怕的AS3“未定义属性的访问”错误,所以新AS3总是会遇到此错误。

function clickThis():void

6) Read and post questions on StackOverflow... a lot! 6)阅读并在StackOverflow上发布问题...很多!

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 :) 顺便说一句,我仍然是菜鸟,最初是AS2开发人员的设计师,我仍然不知道为什么在函数名后加上:void。如果我们有类似的编码背景,希望对您有所帮助:)

I suggest you to look at the ActionScript language migration page on the Adobe devnet. 建议您查看Adobe devnet上的ActionScript语言迁移页面 It offers quite a lot articles about the key changes with ActionScript 3. 它提供了很多有关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). 为了解决按钮上的操作问题,该方法不再起作用(并且ActionScript 2已经不是最佳方法)。 AS3 requires the code to be centralized on the timeline. AS3要求将代码集中在时间轴上。 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: 因此,为了给按钮提供一些动作,您需要为其指定一个实例名称,并为CLICK事件添加一个事件侦听器,如下所示:

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

Get an Actionscript 3 IDE. 获取一个Actionscript 3 IDE。 Such as Flash Builder, FlashDevlop, or FDT. 例如Flash Builder,FlashDevlop或FDT。 This will force you to learn really fast. 这将迫使您快速学习。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM