EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 247

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
About working with custom classes in an application 247
5. Type the following ActionScript code into Frame 1 of the Timeline:
var picture1:Picture = new Picture("http://www.helpexamples.com/flash/
images/image1.jpg");
picture1.showInfo();
this.createEmptyMovieClip("img_mc", 9);
img_mc.loadMovie(picture1.src);
6.
Save the Flash document.
7. Select Control > Test Movie to test the document.
The following text is displayed in the Output panel:
[Picture src=http://www.helpexamples.com/flash/images/image1.jpg]
A sample file on your hard disk demonstrates how to create a dynamic menu with XML data
and a custom class file. The sample calls the ActionScript
XmlMenu() constructor and passes it
two parameters: the path to the XML menu file and a reference to the current timeline. The
rest of the functionality resides in a custom class file, XmlMenu.as.
You can find the sample source file, xmlmenu.fla, in the Samples folder on your hard disk.
On Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\XML_Menu.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/XML_Menu.
About public, private, and static methods and
properties (members)
When you write ActionScript class files in an external script file, there are four types of
methods and properties that you can create: public methods and properties, private methods
and properties, public static methods and properties, and private static methods and
properties. These methods and properties define how Flash can access variables, and they
allow you to specify what parts of your code can access certain methods or properties.
When you are building class-based applications, whether the application is small or large, it is
especially important to consider whether a method or property should be private or public.
Considering this ensures that your code is as secure as possible. For example, if you were
building a User class, you might not want to allow people using the class to be able to change
a user’s ID. By setting the class property (sometimes referred to as an instance member) to
private, you can limit access to the property to code within the class or subclasses of that
class, meaning that no users can change that property directly.

Table of Contents

Related product manuals