Organizing Data In Objects - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

<embed src="urlvariables.swf" quality="high" FlashVars="imgURL=http://
www.helpexamples.com/flash/images/image2.jpg" bgcolor="#ffffff"
width="550" height="400" name="urlvariables" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
7.
Test the HTML document to see the changes. An image that you specify in the HTML
code appears in the SWF file.
To modify this example to use your own images, you would modify the FlashVars value
(the string inside the double quotes).

Organizing data in objects

You might already be used to objects that you place on the Stage. For example, you might
have a MovieClip object on the Stage, and this object contains other movie clips inside it. Text
fields, movie clips, and buttons are often called objects when you place them on the Stage.
Objects, in ActionScript, are collections of properties and methods. Each object has its own
name, and it is an instance of a particular class. Built-in objects are from classes that are
predefined in ActionScript. For example, the built-in Date class provides information from
the system clock on the user's computer. You can use the built-in LoadVars class to load
variables into your SWF file.
You can also create objects and classes using ActionScript. You might create an object to hold
a collection of data, such as a person's name, address. and telephone number. You might create
an object to hold color information for an image. Organizing data in objects can help keep
your Flash documents more organized. For general information on creating a custom class to
hold a collection of methods and properties, see
detailed information on both built-in and custom classes, see
page
225.
There are several ways to create an object in ActionScript. The next example creates simple
objects in two different ways, and then loops over the contents of those objects.
To create simple objects in Flash:
1.
Create a new Flash document, and save it as simpleObjects.fla.
2.
Select Frame 1 of the Timeline, and type the following ActionScript into the Actions panel:
// The first way
var firstObj:Object = new Object();
firstObj.firstVar = "hello world";
firstObj.secondVar = 28;
firstObj.thirdVar = new Date(1980, 0, 1); // January 1, 1980
108
Data and Data Types
"Writing custom class files" on page
Chapter 7, "Classes," on
235. For

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents