开发者

How to add scripts (AS3) to a project?

开发者 https://www.devze.com 2023-01-23 00:58 出处:网络
I am using Adobe Flash CS3 with Actionscript 3.0. What are the different ways to add scripts to a p开发者_高级运维roject except adding the script to a new keyframe?Specifying a document class, as Came

I am using Adobe Flash CS3 with Actionscript 3.0. What are the different ways to add scripts to a p开发者_高级运维roject except adding the script to a new keyframe?


Specifying a document class, as Cameron suggest, is a good starting point. That class (the main class, if you will) can then import and use other classes.

You can also specify classes for library items (Properties/Linking/Export for ActionScript).


You can use the Document Class field to specify a class for the whole stage, or, if you want some modularity, you can link a library symbol to a specific class too.

The Linkage property is available in the Properties of a symbol from the library, checking the Export For Actionscript checkbox and filling the Class field.

If you want a functionality similar to the "main" function of the other programming languages, the Document Class is the way to go. Otherwise, link a symbol to the class of your liking and put it in stage manually.


You can use a document class, which lets your scripts reside exclusively in files (instead of on the frame).

This is the only other method that I am aware of for linking code to a project in the Flash authoring tool.

UPDATE: As others have mentioned, you can also specify a class to link your library assets to (I had forgotten about this :-). This lets you add custom behaviour when creating instances of your assets; for example, you can link a MovieClip asset to a class that extends MovieClip. Then, whenever you instantiate instances of that asset in your code, they will have all the behaviour of the linked class.

0

精彩评论

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