The process of writing the ActionScript to create an applications goes beyond just knowing the syntax and the names of the classes that will be used. Most of the Flash Platform documentation treats these two topics (syntax and use of ActionScript classes). However, to build an ActionScript applications, you need to know as well:
• What programs can be used to write ActionScript?
• How to organize the ActionScript code?
• How to include the ActionScript code in an application?
• What steps should we follow to develop an ActionScript application?
You can use the ActionScript 3.0 code to power everything from simple graphics animations to complex client-server transactions processing systems. Depending on the type of application that is being created, use one or more of these different ways of including ActionScript in your project.
In Flash Professional, for example, the ActionScript code can be created in any frame of the timeline. This code executes while the movie is playing at the moment when the player enters that frame.
Placing ActionScript code in frames provides a simple means of adding behaviors to embedded applications in Flash Professional. The tool allows you to add code to any frame in the main timeline or in the timeline of any MovieClip symbol. However, this flexibility comes at a price. When you create large applications, it’s easy to lose track of which frames contain which scripts. This complicated structure may make it more difficult to keep the application in time.
Many developers simplify the Organization of ActionScript code in Flash Professional, putting the code only in the first frame of a timeline or on a specific layer in the Flash document. The separation of your code makes finding and maintaining the code in Flash FLA files. However, the same code cannot be used in other Flash Professional project without copying and pasting the code into the new file. To facilitate the use of the ActionScript code in other Flash Professional projects in the future stores the code in external ActionScript files (text files with the extension).
Another very common example, in a development environment Flex as Flash Builder, the developer can include ActionScript code inside a tag in a Flex MXML file. However, this technique can increase the complexity in large projects and make use of the same code in another Flex project. To facilitate the use of this code in other Flex projects in the future, store your code in external ActionScript files.
For projects involving a significant amount of ActionScript code, the best way to organize this code is in separate ActionScript source files (text files with the extension). An ActionScript file can be structured in one of two ways, depending on how you intend to use it in your application.
• Unstructured ActionScript code: lines of ActionScript code, including statements or function definitions, written as if they were entered directly in a timeline script or MXML file;
• ActionScript class definition: a definition of an ActionScript class, including its method and property definitions.
When defining a class, you can access so the ActionScript code in the class by creating an instance of the class using its properties, methods, and events.
Visit our blog and check out more content!
You might also like…