Reviews & Opinions
Independent and trusted. Read before buy Macromedia Flash 8 - Actionscript 2 0 Language Reference!

Macromedia Flash 8 - Actionscript 2 0 Language Reference


Bookmark
Macromedia Flash 8 - Actionscript 2 0 Language Reference

Bookmark and Share

 

Macromedia Flash 8 - Actionscript 2 0 Language ReferenceActionScript 2.0 language reference for Macromedia Flash 8 [Book]

By Francis Cheng, Jen deHaan, Robert L. Dixon, Shimul Rahim - Macromedia Press (2006) - Paperback - 1370 pages - ISBN 0321384040

The "ActionScript 2.0 Language Reference for Macromedia Flash 8" is a comprehensive reference manual that describes the application programming interface (API) for Macromedia Flash Player, the most pervasive client runtime environment in the world. It includes valuable syntax and usage information; detailed descriptions of classes, functions, properties, and events; and copy-and-paste code samples for every element in the ActionScript language. The "ActionScript 2.0 Language Refer... Read more
[ Report abuse or wrong photo | Share your Macromedia Flash 8 - Actionscript 2 0 Language Reference photo ]

 

 

Manual

Preview of first few manual pages (at low quality). Check before download. Click to enlarge.
Manual - 1 page  Manual - 2 page  Manual - 3 page 

Download (English)
Macromedia Flash 8-actionscript 2.0 Language Reference, size: 18.5 MB

 

Macromedia Flash 8 - Actionscript 2 0 Language Reference

 

 

User reviews and opinions

<== Click here to post a new opinion, comment, review, etc.

Comments to date: 2. Page 1 of 1. Average Rating:
winks2005 10:44am on Saturday, July 3rd, 2010 
Overpriced content consumption table. Very responsive touch screen, high res screen Content Consumption only. Not great value for money. No camera.
yvette3324 7:07am on Thursday, March 25th, 2010 
you will love the 9 inches screen. You will enjoy the touchscreen experience with iPad Fast, Lightweight, Compact The iPad is exactly what I expected, easy to use, very well executed so long as you understand that it is mainly a device to consume media.

Comments posted on www.ps2netdrivers.net are solely the views and opinions of the people posting them and do not necessarily reflect the views or opinions of us.

 

Documents

doc0

Timeline variables

Timeline variables are available to any script on that particular timeline. To declare timeline variables, use the var statement and initialize them in any frame in the timeline. The variable is available to that frame and all following frames, as shown in the following example.
To use timeline variables in a document:
Create a new Flash document, and name it timelinevar.fla. Add the following ActionScript to Frame 1 of the Timeline:
var myNum:Number = 15; /* initialized in Frame 1, so it's available to all frames */

3. 4. 5.

Select Frame 20 of the Timeline. Select Insert > Timeline > Blank Keyframe. With the new keyframe selected, type the following ActionScript into the Actions panel:

trace(myNum);

Select Control > Test Movie to test the new document. The value 15 appears in the Output panel after approximately a second. Because Flash documents loop by default, the value 15 continually traces in the Output panel every time the playhead reaches Frame 20 in the Timeline. To stop the looping action, add stop(); after the trace() statement.
You must declare a timeline variable before trying to access it in a script. For example, if you put the code var myNum:Number = 15; in Frame 20, any scripts attached to a frame before Frame 20 cannot access myNum and are undefined instead of containing the value 15.

Local variables

When you use the var statement inside a function block, you declare local variables. When you declare a local variable within a function block (also called function definition), it is defined within the scope of the function block, and expires at the end of the function block. Therefore, the local variable only exists within that function. For example, if you declare a variable named myStr within a function named localScope, that variable will not be available outside of the function.
function localScope():Void { var myStr:String = "local"; } localScope(); trace(myStr); // Undefined, because myStr is not defined globally
If the variable name you use for your local variable is already declared as a timeline variable, the local definition takes precedence over the timeline definition while the local variable is in scope. The timeline variable will still exist outside of the function. For example, the following code creates a timeline string variable named str1, and then creates a local variable of the same name inside the scopeTest() function. The trace statement inside the function generates the local definition of the variable, but the trace statement outside the function generates the timeline definition of the variable.

this.formClip.submitBtn.mouseOver = true;
You can express a method or property of a particular object (such as a movie clip or text field) using this pattern. For example, the property of an object would be

myClip._alpha = 50;

About scope and targeting
When you nest instances, the movie clip that nests a second movie clip is known as the parent to the nested instance. The nested instance is known as the child instance. The main Stage and main timeline are essentially a movie clip themselves, and can therefore be targeted as such. For more information on scope, see About variables and scope on page 60. You can target parent instances and parent timelines using ActionScript. When you want to target the current timeline, you use the this keyword. For example, when you target a movie clip called myClip that's on the current main timeline, you would use

this.myClip.

Optionally, you can drop the this keyword, and just use

myClip

You might choose to add the this keyword for readability and consistency. For more information on recommended coding practices, see Chapter 17, Best Practices and Coding Conventions for ActionScript 2.0, on page 665. If you trace the movie clip, for either snippet above you see _level0.myClip in the Output panel. However, if you have ActionScript thats inside the myClip movie clip but you want to target the main timeline, target the parent of the movie clip (which is the main Stage). Double-click a movie clip, and place the following ActionScript on the movie clips timeline:
trace("me: " + this); trace("my parent: " + this._parent);
Test the SWF file, and youll see the following message in the Output panel:
me: _level0.myClip my parent: _level0
This indicates you targeted the main timeline. You can use parent to create a relative path to an object. For example, if the movie clip dogClip is nested inside the animating movie clip animalClip, the following statement on the instance dogClip tells animalClip to stop animating:

this._parent.stop();

If you're familiar with Flash and ActionScript, youve probably noticed people using the _root scope. The _root scope generally refers to the main timeline of the current Flash document. You should avoid using the _root scope unless its absolutely necessary. You can use relative target paths instead of _root. If you use _root in your code, you can encounter errors if you load the SWF file into another Flash document. When the SWF file loads into a different SWF file, _root in the loaded file might point to the root scope of the SWF file it loads into, instead of referring to its own root as you intend it to. This can lead to unpredictable results, or break functionality altogether.

var listenerObj:Object = new Object(); listenerObj.onKeyDown = function() { // Use the String.fromCharCode() method to return a string. switch (String.fromCharCode(Key.getAscii())) { case "A" : trace("you pressed A"); break; case "a" : trace("you pressed a"); break; case "E" : case "e" : /* E doesn't have a break statement, so this block executes if you press e or E. */ trace("you pressed E or e"); break; case "I" : case "i" : trace("you pressed I or i"); break;
default : /* If the key pressed isnt caught by any of the above cases, execute the default case here. */ trace("you pressed some other key"); } }; Key.addListener(listenerObj); 3.
Select Control > Test Movie to test the ActionScript. Type letters using the keyboard, including the a, e, or i key. When you type those three keys, youll see the trace statements in the preceding ActionScript. The line of code creates a new object that you use as a listener for the Key class. You use this object to notify the onKeyDown() event when the user presses a key. The Key.getAscii() method returns the ASCII code of the last key that the user presses or releases, so you need to use the String.fromCharCode() method to return a string that contains the characters represented by the ASCII values in the parameters. Because E doesnt have a break statement, the block executes if the user presses the e or E key. If the user presses a key that isnt caught by any of the first three cases, the default case executes.
Using try.catch and try.catch.finally statements
Using try.catch.finally blocks lets you add error handling to your Flash applications. The try.catch.finally keywords let you enclose a block of code where an error can occur and respond to that error. If any code within the try code block throws an error (using the throw statement), control passes to the catch block, if one exists. Then control passes to the finally code block, if one exists. The optional finally block always executes, regardless of whether an error was thrown. If code within the try block doesnt throw an error (that is, the try block completes normally), the code in the finally block still executes.

var i:Number; for (i = 1; i <= 4; i++) { myClip["nestedClip" + i]._visible = false; }

10. Use

This ActionScript toggles the visibility of each of the nested movie clips.

12. Select

Control > Test Movie to test the ActionScript you just added.
Now the four nested instances are invisible. Youre using the array access operator to iterate over each nested movie clip in the myClip instance and set its visible property dynamically. You save time, because you dont have to specifically target each instance. You can also use the array access operator on the left side of an assignment, which lets you set instance, variable, and object names dynamically:

myNum[i] = 10;

In ActionScript 2.0, you can use the bracket operator to access properties on an object that are created dynamically, in case the class definition for that object is not given the dynamic attribute. You can also create multidimensional arrays using this operator. For more information on creating multidimensional arrays using array access operators, see Creating multidimensional arrays on page 131.

About postfix operators

The postfix operators take one operator and either increment or decrement the operators value. Although these operators are unary operators, they are classified separately from the rest of the unary operators because of their higher precedence and special behavior. For information on unary operators, see About unary operators on page 147. When you use a postfix operator as part of a larger expression, the expressions value is returned before the postfix operator is processed. For example, the following code shows how the value of the expression xNum++ is returned before the value is incremented.
var xNum:Number = 0; trace(xNum++); // 0 trace(xNum); // 1
When you trace this code, the text in the Output panel reads:
The operators in this table have equal precedence:

Operator

Operation performed
Increment (postfix) Decrement (postfix)

About unary operators

Unary operators take one operand. The increment (++) and decrement (--) operators in this group are prefix operators, which means that they appear before the operand in an expression. They can also appear after the operand, in which case they are postfix operators. For information on postfix operators, see About postfix operators on page 147. The prefix operators differ from the postfix counterparts because the increment or decrement operation completes before the value of the overall expression is returned. For example, the following code shows how the value of the expression xNum++ is returned after the value is incremented.

About object-oriented programming and Flash
ActionScript 2.0 is an object-oriented language. Like ActionScript, OOP languages are based on the concept of classes and instances. A class defines all of the properties that distinguish a series of objects. For example, a User class represents a bunch of users who are using your application. Then, you have an instantiation of the class, which, for the User class, is one of the individual usersone of its members. The instantiation produces an instance of the User class, and that instance has all of the properties of the User class. Classes are also considered like data types or templates that you can create to define a new type of object. For example, if you need a data type of Lettuce in your application, you might write the Lettuce class. This defines the Lettuce object, and then you can assign your Lettuce methods (wash()) and properties (leafy or bugs). To define a class, you use the class keyword in an external script file. You can create an external script file in the Flash authoring tool by selecting File > New and then selecting ActionScript File. ActionScript 2.0 includes features such as filter effects, file upload and download, and the External API, and also provides several powerful and familiar OOP concepts and keywords (such as class, interface, and package) found in other programming languages, such as Java. The programming language lets you build program structures that are reusable, scalable, robust, and maintainable. It can also decrease development time by providing users with thorough coding assistance and debugging information. You can use ActionScript 2.0 to create objects and establish inheritance and to create custom classes and extend the Flash toplevel and built-in classes. You learn how to create classes and use custom classes in this chapter. Flash includes approximately 65 top-level and built-in classes that provide everything from basic, or primitive, data types (Array, Boolean, Date, and so on), to custom errors and events, as well as several ways to load external content (XML, images, raw binary data, and more). You can also write your own custom classes and integrate them into your Flash documents or even extend the top-level classes and add your own functionality or modify existing functionality. For example, About class members on page 211 in this chapter shows you how to make a custom Person class that contains custom properties for the persons name and age. You can then treat this custom class as a new data type in your documents and create a new instance of the class using the new operator. For more information on working with OOP, see the following topics:
The benefits of using classes on page 189 About packages on page 189
About values and data types on page 193 Object-oriented programming fundamentals on page 193

Global classpath

is a classpath thats shared by all Flash documents. You set it in the Preferences dialog box (Edit > Preferences (Windows) or Flash > Preferences (Macintosh), click ActionScript in the Category list, and then click ActionScript 2.0 Settings). is a classpath that you specifically define for a single Flash document. It is set in the Publish Settings dialog box (File > Publish Settings, select the Flash tab, and then click the Settings button).

Document-level classpath

When you import class files, the following rules apply:
The import statements can exist in the following locations:
Anywhere before the class definition in class files Anywhere in frame or object scripts Anywhere in ActionScript files that you include in an application (using the #include statement).
You import individual, packaged definitions using this syntax:
import flash.display.BitmapData;
You can import entire packages using the wildcard syntax:

import flash.display.*;

You can also include ActionScript code in a Flash document (FLA) file using an include statement. The following rules apply to the include statement:
include statements are essentially a copy and paste of the content inside the included ActionScript file. include statements inside ActionScript class files are relative to the subdirectory that contains the file.
An include statement in a FLA file can only bring in code that is valid inside FLA files, and the same goes for other places that include statements can live. For example, if you have an include statement inside a class definition, only property and method definitions can exist in the included ActionScript file:
// Foo.as class Foo { #include "FooDef.as" } // FooDef.as: var fooProp; function fooMethod() {} trace("Foo"); // This statement is not permitted in a class definition.
For more information on the include statement, see #include directive in the ActionScript 2.0 Language Reference. For more information on classpaths, see About setting and modifying the classpath on page 202.
About setting and modifying the classpath
In order to use a class or interface that youve defined, Flash must locate the external ActionScript files that contain the class or interface definition. The list of directories in which Flash searches for class and interface definitions is called the classpath. When you create an ActionScript class file, you need to save the file to one of the directories specified in the classpath or a subdirectory therein. (You can modify the classpath to include the desired directory path). Otherwise, Flash wont be able to resolve, that is, locate, the class or interface specified in the script. Subdirectories that you create within a classpath directory are called packages and let you organize your classes. (For more information on packages, see Creating and packaging your class files on page 226.) Flash has two classpath settings: a global classpath and a document-level classpath. The global classpath is a classpath thats shared by all of your Flash documents. The document-level classpath is a classpath that you specifically define for a single Flash document. The global classpath applies to external ActionScript files and to FLA files, and you set it in the Preferences dialog box (Windows: Edit > Preferences (Windows) or Flash > Preferences (Macintosh), select ActionScript from the Category list, and then click ActionScript 2.0 Settings). You can set the document-level classpath in the Flash documents Publish Settings dialog box (File > Publish Settings, select the Flash tab, and then click the Settings button).

Create a new ActionScript document and save it as InterfaceC.as. This interface extends the InterfaceA interface you created earlier, and it adds a new method definition.

19. In

InterfaceC.as, type the following ActionScript code into the Script window:
// filename: InterfaceC.as interface InterfaceC extends InterfaceA { public function p():Void; } 20.Save your changes to the ActionScript file and then create a new ActionScript file and save
it as ClassE.as in the complexInterface directory. This class implements two interfaces, InterfaceB and InterfaceC.

21. In

ClassE.as, type the following ActionScript code into the Script window:
// filename: ClassE.as class ClassE implements InterfaceB, InterfaceC { public function k():Number { return 15; } public function n(z:Number):Number { return (z + 5); } public function o():Void { trace("o"); } public function p():Void { trace("p"); } } 22.Save
your changes to the ActionScript document, and then create a new Flash document and save it as classeTest.fla in the complexInterface directory.
classeTest.fla, type the following ActionScript code on Frame 1 of the Timeline:
// filename: classeTest.fla import ClassE; var myE:ClassE = new ClassE(); trace(myE.k()); // 15 trace(myE.n(7)); // 12 myE.o(); // o myE.p(); // p 24.Save
the Flash document, and then select Control > Test Movie to test the SWF file.
The values 15, 12, o, and p display in the Output panel. These values are the values that return from the ClassE.k(), ClassE.n(), ClassE.o(), and ClassE.p() methods. Since the ClassE class implemented both the InterfaceB and InterfaceC interfaces, each method from the two interface files must be defined. Although the InterfaceB and InterfaceC interfaces only define the o() and p() methods, InterfaceC extends InterfaceA. This means that all of its defined methods, k() and n(), must also be implemented.

CHAPTER 9

Handling Events
Events are actions that occur while a SWF file is playing. An event such as a mouse click or a keypress is called a user event because it occurs as a result of direct user interaction. An event that Flash Player generates automatically, such as the initial appearance of a movie clip on the Stage, is called a system event because it isnt generated directly by the user. In order for your application to react to events, you must use event handlersActionScript code associated with a particular object and event. For example, when a user clicks a button on the Stage, you might advance the playhead to the next frame. Or when an XML file finishes loading over the network, the contents of that file might appear in a text field. You can handle events in ActionScript in several ways:

To create button states in a movie clip:
Create a new Flash document and save it as mcbutton.fla. Using the Rectangle Tool, draw a small rectangle (approximately 100 pixels wide by 20 pixels high) on the Stage. Double-click the shape with the Selection tool and press F8 to launch the Convert to Symbol dialog box. Enter a symbol name of mcbutton, set the symbol type to movie clip, and click OK. Double-click the movie clip symbol on the Stage to enter symbol-editing mode. Create a new layer in the movie clips timeline and rename the new layer labels. Enter a frame label of _up in the Property inspector. Create a new layer above the default layer and labels layer.

4. 5. 6. 7. 8.

Rename the new layer actions and add the following ActionScript to Frame 1 of the movie clips timeline:
Frame 10, all three layers, and select Insert > Timeline > Keyframe.
Add a stop() action on Frame 10 of the actions layer, and add a frame label of _over in frame 10 of the labels layer. the rectangle on Frame 10 and use the Property inspector to select a different fill color. Create new keyframes on frame 20 of each of the three layers, and add a frame label of _down in the Property inspector. the color of the rectangle in Frame 20 so each of the three button states have a different color. to the main timeline. To make the movie clip respond to mouse events, do one of the following:
14. Modify 15. Return 16.
Attach an on() event handler to the movie clip instance, as discussed in Using button and movie clip event handlers on page 300). Assign a function to one of the movie clip objects mouse event handlers (onPress, onRelease, and so forth), as discussed in About ActionScript and events on page 292.
Select Control > Test Movie to test the Flash document. Move your mouse pointer over the movie clip instance on the Stage and the movie clip automatically goes to the movie clips _over state. Click the movie clip instance and the playhead automatically goes to the movie clips _down state.

To animate _alpha in the previous example instead of _yscale, tween the target_mc directly instead of the mask movie clip.
Understanding scaling and slice guides
You can use 9-slice scaling (Scale-9) to specify component-style scaling for movie clips. 9-slice scaling lets you create movie clip symbols that scale appropriately for use as user interface components, as opposed to the type of scaling typically applied to graphics and design elements.
Understanding how 9-slice scaling works
The easiest way to explain how 9-slice scaling works is to look at an example of how 9-slice scaling works in Flash.
To understand scaling in Flash:
Create a new Flash document and save it as dynmask.fla. Drag a copy of the Button component to the Stage from the Components panel (Window > Components). Increase the Stages zoom level to 400% by using the Zoom tool.
By default, the Button component instance is 100 pixels wide by 22 pixels high.
Resize the Button component instance to 200 pixels width by 44 pixels high by using the Property inspector.
You can see that even though the component resized, the Buttons border and text label do not distort. The buttons label remained centered and maintained its font size. Although components of version 2 of the Adobe Component Architecture do not use 9-slice scaling, components handle scaling in the version 2 component architecture so the outlines do not change size (as shown in the next figure). Imagine that the button instance is sliced into 9 separate pieces, or a 3 by 3 grid, similar to a keypad on a telephone or keyboard. When you resize the button instance horizontally, only the three vertical segments in the center (numbers 2, 5, and 8 on a keypad) stretch so your content doesnt appear distorted. If you resized the button instance vertically, only the three horizontal segments in the center (numbers 4, 5, and 6 on a keypad) would resize. The four corners of the scaling grid are not scaled at all, which allows the component to grow without looking like it is being stretched (see the following images).
You can enable slice guides for 9-slice scaling in the Flash environment within the Convert to Symbol dialog box or the Symbol Properties dialog box. The Enable guides for 9-slice scaling check box is available only if you are publishing for Flash Player 8 and later and the behavior is set to movie clip. The 9-slice scaling guides are not available for earlier versions of Flash or if you are creating a button or graphic symbol. 9-slice scaling can be enabled in ActionScript by setting the scale9Grid property on a movie clip instance. Whether you created your slice guides by using the user interface or by using ActionScript, you can trace the x coordinate, y coordinate, width, and height by tracing the movie clips scale9Grid property.

my_lv.load("http://www.helpexamples.com/flash/404.txt"); /* output: Error opening URL "http://www.helpexamples.com/flash/404.txt" HTTP status is: 404 */
The previous code creates a new text field on the Stage and enables text field autosizing. Next, a LoadVars object is created and two event handlers: onHTTPStatus and onLoad. The onHTTPStatus event handler (supported in Flash Player 8 and later) is invoked when a LoadVars.load() or LoadVars.sendAndLoad() operation has completed. The value passed to the onHTTPStatus event handler function (httpStatus in the previous code) contains the HTTP status code definition for the current load operation. If the SWF file was able to successfully load the text file, the value of httpStatus is set to 200 (HTTP status code for OK). If the file didnt exist on the server, the value of httpStatus is set to 404 (HTTP status code for Not Found). The second event handler, LoadVars.onLoad(), gets called after the file has finished loading. If the file successfully loaded, the value of the success parameter is set to true, otherwise the success parameter is set to false. Finally, the external file is loaded using the LoadVars.load() method.
Select Control > Test Movie to test the Flash document. Flash displays an error message to the Output panel stating that it was unable to load the image because it doesnt exist on the server. The onHTTPStatus event handler traces the status code of 404 since the file could not be found on the server, and the onLoad event handler sets the params_txt text fields text property to unable to load text file.

C A U TI O N

If a web server does not return a status code to the Flash Player, the number 0 is returned to the onHTTPStatus event handler.
About file uploading and downloading
The FileReference class lets you add the ability to upload and download files between a client and server. Your users can upload or download files between their computer and a server. Users are prompted to select a file to upload or a location for download in a dialog box (such as the Open dialog box on the Windows operating system). Each FileReference object that you create with ActionScript refers to a single file on the users hard disk. The object has properties that contain information about the files size, type, name, creation date, and modification date. On the Macintosh, there is also a property for the files creator type. You can create an instance of the FileReference class in two ways. You can use the following new operator:
import flash.net.FileReference; var myFileReference:FileReference = new FileReference();
Or, you can call the FileReferenceList.browse() method, which opens a dialog box on the users system to prompt the user to select a file to upload and then creates an array of FileReference objects if the user selects one or more files successfully. Each FileReference object represents a file selected by the user from the dialog box. A FileReference object does not contain any data in the FileReference properties (such as name, size, or modificationDate) until the FileReference.browse() method or FileReferenceList.browse() method has been called and the user has selected a file from the file picker or until the FileReference.download() method has been used to select a file from the file picker.

Writing conditional statements
Use the following guidelines when you write conditional statements:
Place conditions on separate lines in if, else.if, and if.else statements. Use braces ({}) for if statements. Format braces as shown in the following examples:
// if statement if (condition) { // statements } // if.else statement if (condition) { // statements } else { // statements } // else.if statement if (condition) { // statements } else if (condition) { // statements } else { // statements }
When you write complex conditions, it is good form to use parentheses [()] to group conditions. If you dont use parentheses, you (or others working with your ActionScript 2.0 code) might run into operator precedence errors. For example, the following code does not use parentheses around the conditions:
if (fruit == apple && veggie == leek) {}
if ((fruit == apple) && (veggie == leek)) {}
You can write a conditional statement that returns a Boolean value in two ways. The second example is preferable:
if (cartArr.length>0) { return true; } else { return false; }
Compare this example with the previous one:
// better return (cartArr.length > 0);
The second snippet is shorter and has fewer expressions to evaluate. Its easier to read and to understand. The following example checks if the variable y is greater than zero (0), and returns the result of x/y or a value of zero (0).
return ((y > 0) ? x/y : 0);
The following example shows another way to write this code. This example is preferable:
if (y>0) { return x/y; } else { return 0; }
The shortened if statement syntax from the first example is known as the conditional operator (?:). It lets you convert simple if.else statements into a single line of code. In this case, the shortened syntax reduces readability. If you must use conditional operators, place the leading condition (before the question mark [?]) inside parentheses to improve the readability of your code. You can see an example of this in the previous code snippet.
Writing compound statements
Compound statements contain a list of statements within braces ({}). The statements within these braces are indented from the compound statement. The following ActionScript code shows an example of this:

if (a == b) { // This code is indented. trace("a == b"); }
Place braces around each statement when it is part of a control structure (if.else or for), even if it contains only a single statement. The following example shows code that is written poorly:
// bad if (numUsers == 0) trace("no users found.");
Although this code validates, it is poorly written because it lacks braces around the statements. In this case, if you add another statement after the trace statement, the code executes regardless of whether the numUsers variable equals 0:
// bad var numUsers:Number = 5; if (numUsers == 0) trace("no users found."); trace("I will execute");
Executing the code despite the numUsers variable can lead to unexpected results. For this reason, add braces, as shown in the following example:
var numUsers:Number = 0; if (numUsers == 0) { trace("no users found"); }
When you write a condition, dont add the redundant ==true in your code, as follows:
if (something == true) { //statements }
If you are compare against false, you could use if if(!something).

(something==false)

Writing a for statement
You can write the for statement using the following format:
for (init; condition; update) { // statements }
The following structure demonstrates the for statement:
var i:Number; for (var i = 0; i<4; i++) { myClip.duplicateMovieClip("newClip" + i + "Clip", i + 10, {_x:i*100, _y:0}); }
Remember to include a space following each expression in a for statement.
Writing while and do.while statements
You can write while statements using the following format:
while (condition) { // statements }
You can write do-while statements using the following format:
do { // statements } while (condition);
Writing return statements
Dont use parentheses [()] with any return statements that have values. The only time to use parentheses with return statements is when they make the value more obvious, as shown in the third line of the following ActionScript code snippet:
return; return myCar.paintColor; // parentheses used to make the return value obvious return ((paintColor)? paintColor: defaultColor);
Writing switch statements
All switch statements include a default case. The default case is the last case in a switch statement. The default case includes a break statement that prevents a fall-through error if another case is added.
If a case does not have a break statement, the case will fall through (see case following code example).
Your statement should include a comment in the break statements place, as you can see in the following example after case A. In this example, if the condition matches case A, both cases A and B execute.
You can write switch statements using the following format:

named functions 169 naming classes and objects, best practices 673 naming conventions 666 Booleans 672 classes and objects 673 functions and methods 673 interfaces 675 packages 190, 675 variables 670 naming interfaces, best practices 675 naming packages, best practices 675 navigation controlling 519
jumping to frame or scene 520 nested movie clips, defined 313 Netscape, JavaScript methods supported 621 NetStream class and onMetaData handler 577 using onMetaData handler 577 networking restricting networking APIs 648 newline character 420 nodes 608 noise effect 494 null data type 41 numbers, manipulating with methods 42 numeric keypad, ASCII key code values 718
object literal 136 object properties assigning values to 257 object-oriented programming 193 Object-oriented programming. SeeOOP objects accessing properties 257 calling methods 258 coding standards 680 creating 54, 72, 257 creating in Flash 72 data type 42 fading out 432 looping through children of 117 organizing data in arrays 73 old players, targeting 721 on() and onClipEvent() handlers 300 attaching to movie clips 301 scope 306 onEnterFrame, and frame rate 431 online resources 16 OOP about 188, 193 and encapsulation 195 and inheritance 194 and interfaces 195 and objects 193 and polymorphism 196 design 221 instances and class members 194 writing custom classes 196 opaqueBackground property
defined 331 using 336 operands 138 operation order 498 operator precedence and associativity 140 operators about 137 additive 148 assignment 140, 154 associativity 140 bitwise logical 158 bitwise shift 157 combining with values 137 comparison 144 conditional 114, 151, 160 deprecated 713 dot and array access 145 equality 150, 151 logical 155, 156 manipulating values 139 mathematical expressions 137 multiplicative 148 numeric 149 operands 138 postfix 147 precedence and associativity 140 relational 150 relational and equality 151 unary 147 using assignment 155 using in Flash 160 order of execution (operator) operator associativity 140 operator precedence 140 organizing scripts ActionScript 1.0 and ActionScript 2.attaching to objects 680 coding conventions 679 out-of-memory error 462
packages about 189 compared with classes 191 importing 192 naming 190 working with 191, 458 parameters 169
parent movie clips 313 parentheses, about 93 PDF documentation, where to find 15 performance and filters 462 and frame rate 431 bitmap caching 440 playing movie clips 521 pointer. See cursors policy files defined 658 must be named crossdomain.xml 658 See also security polymorphism about 196 using 271 post colon syntax, defined 46 prefixes, super 690 primitive data type (data value) 37 progress bar and drawing API 592 creating with code 580 for data loading 592 projectors, executing applications from 619 properties initializing at runtime 340 of movie clips 319 of objects, accessing 257 private 209 public 209 static 210 publish settings choosing Flash Player version 34 punctuators about 88 curly braces 90 parentheses 93 semicolons and colons 89

doc1

DepthManager.kTopmost. 491 DepthManager.setDepthAbove(). 492 DepthManager.setDepthBelow(). 492 DepthManager.setDepthTo(). 493 Chapter 21: EventDispatcher class. 495 Event objects. EventDispatcher class (API). EventDispatcher.addEventListener(). EventDispatcher.dispatchEvent(). EventDispatcher.removeEventListener(). 499
Chapter 22: FLVPlayback Component. 501 Using the FLVPlayback component. 503 Using cue points. 510 Playing multiple FLV files. 517 Streaming FLV files from a FMS. 519 Customizing the FLVPlayback component. 520 FLVPlayback class.535 VideoError class. 694 VideoPlayer class.702 Using a SMIL file. 707 Chapter 23: FocusManager class. 717 Using Focus Manager. 718 Customizing Focus Manager. 721 FocusManager class (API). 721 FocusManager.defaultPushButton. 725 FocusManager.defaultPushButtonEnabled. 726 FocusManager.enabled. 726 FocusManager.getFocus(). 727 FocusManager.nextTabIndex. 728 FocusManager.sendDefaultPushButtonEvent(). 728 FocusManager.setFocus().730 Chapter 24: Form class. 731 Using the Form class. 732 Form class. 733 Form.currentFocusedForm.739 Form.getChildForm(). 739 Form.indexInParentForm.740
Form.numChildForms. 741 Form.parentIsForm. 742 Form.parentForm. 742 Form.rootForm. 743 Form.visible. 744 Chapter 25: Iterator interface. 745 Iterator.hasNext(). 745 Iterator.next(). 746 Chapter 26: Label component. 749 Using the Label component. 749 Customizing the Label component. 751 Label class. 753 Label.autoSize. 756 Label.html. 757 Label.text. 758 Chapter 27: List component. 759 Using the List component. 760 Customizing the List component. 764 List class. 768 List.addItem(). 774 List.addItemAt(). 775 List.cellRenderer. 776 List.change. 776 List.dataProvider. 778 List.getItemAt(). 779 List.hPosition. 780 List.hScrollPolicy. 781 List.iconField. 782 List.iconFunction. 783 List.itemRollOut. 784 List.itemRollOver. 786 List.labelField. 787 List.labelFunction. 788 List.length. 789 List.maxHPosition. 790 List.multipleSelection. 791 List.removeAll(). 792 List.removeItemAt(). 793
List.replaceItemAt().794 List.rowCount.795 List.rowHeight. 796 List.scroll. 797 List.selectable.799 List.selectedIndex.799 List.selectedIndices. 800 List.selectedItem. 801 List.selectedItems. 802 List.setPropertiesAt(). 803 List.sortItems(). 804 List.sortItemsBy(). 805 List.vPosition.807 List.vScrollPolicy.808 Chapter 28: Loader component. 811 Using the Loader component. 811 Customizing the Loader component. 814 Loader class. 815 Loader.autoLoad. 819 Loader.bytesLoaded. 819 Loader.bytesTotal. 820 Loader.complete. 821 Loader.content.823 Loader.contentPath.824 Loader.load().825 Loader.percentLoaded.826 Loader.progress. 827 Loader.scaleContent.829 Chapter 29: Media components. 831 Interacting with media components.832 Understanding media components.833 Using media components.836 Media component parameters.843 Creating applications with media components.846 Customizing media components. 847 Media class. 847 Media.activePlayControl. 851 Media.addCuePoint().852 Media.aspectRatio.853

// Create new Listener object. var my_accListener:Object = new Object(); my_accListener.change = function() { trace("Changed to different view"); // Assign label of child panel to variable. var selectedChild_str:String = my_acc.selectedChild.label; // Perform action based on selected child. switch (selectedChild_str) { case "Shipping Address": trace("One was selected"); break; case "Billing Address": trace("Two was selected"); break;
case "Payment": trace("Three was selected"); break; } }; my_acc.addEventListener("change", my_accListener);

Accordion.createChild()

accordionInstance.createChild(classOrSymbolName, instanceName[, initialProperties])

Parameters

Either the constructor function for the class of the UIObject to be instantiated, or the linkage name (a reference to the symbol to be instantiated). The class must be UIObject or a subclass of UIObject, but most often it is View object or a subclass of View.
classOrSymbolName instanceName
The instance name of the new instance.
initialProperties An optional parameter that specifies initial properties for the new instance. You can use the following properties:

label icon

A string that specifies the text label that the new child instance uses on its header.
A string that specifies the linkage identifier of the library symbol that the child uses for the icon on its header.

Returns

A reference to an instance of the UIObject that is the newly created child.
Method (inherited from View); creates a child for the accordion. The newly created child is added to the end of the list of children owned by the accordion. Use this method to place views inside the accordion. The created child is an instance of the class or movie clip symbol specified in the classOrSymbolName parameter. You can use the label and icon properties to specify a text label and an icon for the associated accordion header for each child in the initialProperties parameter.
When each child is created, it is assigned an index number in the order of creation and the numChildren property is increased by 1.
Start with an Accordion instance on the Stage named my_acc. Add a symbol to the library with the Linkage Identifier payIcon to be the icon for the child header. The following code creates a child named billing (with the label Payment) that is an instance of the View class:
var child_obj:Object = my_acc.createChild(mx.core.View, "billing", {label: "Payment", icon: "payIcon"});
The following code also creates a child that is an instance of the View class, but it uses import to reference the constructor for the View class:

import mx.core.View; import mx.controls.Label; import mx.controls.TextInput; var child_obj:Object = my_acc.createSegment(View, "billing", "Payment", "payIcon"); // Create labels as children of the view instance. var cardType_label:Object = child_obj.createChild(Label, "CardType_label", {_x:10, _y:50}); var cardNumber_label:Object = child_obj.createChild(Label, "CardNumber_label", {_x:10, _y:100}); // Create text inputs as children of the view instance. var cardTypeInput_ti:Object = child_obj.createChild(TextInput, "CardType_ti", {_x:150, _y:50}); var cardNumberInput_ti:Object = child_obj.createChild(TextInput, "CardNumber_ti", {_x:150, _y:100}); // Fill in labels. cardType_label.text = "Card Type"; cardNumber_label.text = "Card Number";
Accordion.destroyChildAt()
accordionInstance.destroyChildAt(index)
The index number of the accordion child to destroy. Each child of an accordion is assigned a zero-based index number in the order in which it was created.

Nothing.

Method (inherited from View); destroys one of the accordions children. The child to be destroyed is specified by its index, which is passed to the method in the index parameter. Calling this method destroys the corresponding header as well. If the destroyed child is selected, a new selected child is chosen. If there is a next child, it is selected. If there is no next child, the previous child is selected. If there is no previous child, the selection is undefined.
Calling destroyChildAt() decreases the numChildren property by 1.
The following code destroys the first child of my_acc when the third child is selected:
import mx.core.View; // Create child panels with instances of the View class. my_acc.createSegment(View, "myMainItem1", "Menu Item 1"); my_acc.createSegment(View, "myMainItem2", "Menu Item 2"); my_acc.createSegment(View, "myMainItem3", "Menu Item 3");
// Create new Listener object. my_accListener = new Object(); my_accListener.change = function() { if ("myMainItem3"){ my_acc.destroyChildAt(0); } }; my_acc.addEventListener("change", my_accListener);

Using styles with the Button component
You can set style properties to change the appearance of a button instance. If the name of a style property ends in Color, it is a color style property and behaves differently than noncolor style properties. For more information, see Using styles to customize component color and text in Using ActionScript 2.0 Components. A Button component supports the following styles:
Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". The background color. The default value is 0xEFEBEF (light gray). The Halo theme uses 0xF8F8F8 (very light gray) for the button background color when the button is up and themeColor when the button is pressed. You can only modify the up background color in the Halo theme by skinning the button. See Using skins with the Button component on page 93. The Button component uses a RectBorder instance as its border in the Sample theme and responds to the styles defined in that class. See RectBorder class on page 1065. With the Halo theme, the Button component uses a custom rounded border whose colors cannot be modified except for themeColor.

Sample

Both Both Both The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. The color for text when the component is disabled. The default color is 0x848384 (dark gray). A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. The font name for text. The default value is "_sans". The point size for the font. The default value is 10. The font style: either "normal" or "italic". The default value is "normal". The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() return "none". The text decoration: either "none" or "underline". The default value is "none".
Using skins with the Button component
The Button component includes 32 different skins that can be customized to correspond to the border and icon in 16 different states. To skin the Button component while authoring, create new movie clip symbols with the desired graphics and set the symbol linkage identifiers using ActionScript. (For more information, see Using ActionScript to draw Button skins on page 96.) The default implementation of the Button skins provided with both the Halo and Sample themes uses the ActionScript drawing API to draw the button states, and uses a single movie clip symbol associated with one ActionScript class to provide all skins for the Button component.

FLVPlayback.bringVideoPlayerToFront()
my_FLVPlybk.bringVideoPlayerToFront(index:Number)
A number that is the index of the video player to move to the front
Method; brings a video player to the front of the stack of video players. Useful for custom transitions between video players. The stack order is the same as it is for the activeVideoPlayerIndex property: 0 is on the bottom, 1 is above it, 2 is above 1, and so on.
The following example uses two video players to play two FLV files. When each of the three cue points in the first FLV file (cuepoints.flv) occurs, the example calls the bringVideoPlayerToFront() method to bring the other FLV file to the front. Because the example sets the _alpha property to 75 for video player number 1, the FLV file (plane_cuepoints) playing in that player is transparent, making both FLV files visible simultaneously when that FLV file is in front.
/** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ my_FLVPlybk.load("http://www.helpexamples.com/flash/video/cuepoints.flv"); var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object) { if (eventObject.target.contentPath == "http://www.helpexamples.com/ flash/video/cuepoints.flv") { //this fires after the first flv is ready my_FLVPlybk.activeVideoPlayerIndex = 1; my_FLVPlybk.load("http://www.helpexamples.com/flash/video/ plane_cuepoints.flv"); } else { //this fires after the second flv is ready eventObject.target.activeVideoPlayerIndex = 0; eventObject.target.play(); eventObject.target.activeVideoPlayerIndex = 1; eventObject.target.play(); var layerOnTop:MovieClip = eventObject.target.getVideoPlayer(1); layerOnTop._alpha = 75; layerOnTop._visible = true; } } my_FLVPlybk.addEventListener("ready", listenerObject); var listenerObject:Object = new Object(); listenerObject.cuePoint = function(eventObject:Object) { //based upon the cue name, bring one or the other to the front if (eventObject.info.name == "point1") { trace(eventObject.info.name + " : 0 to front"); eventObject.target.bringVideoPlayerToFront(1); } else if (eventObject.info.name == "point2") { trace(eventObject.info.name + " : 1 to front"); eventObject.target.bringVideoPlayerToFront(0); }else if (eventObject.info.name == "point3") { trace(eventObject.info.name + " : 0 to front"); eventObject.target.bringVideoPlayerToFront(1); } } my_FLVPlybk.addEventListener("cuePoint", listenerObject);
FLVPlayback.activeVideoPlayerIndex, FLVPlayback.getVideoPlayer(), VideoPlayer

class,

var listenerObject:Object = new Object(); listenerObject.buffering = function(eventObject:Object):Void { // insert event-handling code here }; my_FLVplybk.addEventListener("buffering", listenerObject);

/** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ // create cue point object import mx.video.*; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv"; var cuePt:Object = new Object(); var rtn_cuePt:Object = new Object(); // create object for return value cuePt.time = 4.444; cuePt.name = "AScue1"; my_FLVPlybk.addASCuePoint(cuePt); //add AS cue point // add 2nd AS cue point using time and name parameters my_FLVPlybk.addASCuePoint(10, "AScue2"); // find navigation cue point using time rtn_cuePt = my_FLVPlybk.findCuePoint(7.748, FLVPlayback.NAVIGATION); //find actionscript cue point using name only rtn_cuePt = my_FLVPlybk.findCuePoint("AScue1"); //find actionscript cue point using cue point object cuePt.time = 10; cuePt.name = "AScue2"; rtn_cuePt = my_FLVPlybk.findCuePoint(cuePt, FLVPlayback.ACTIONSCRIPT); // see what returned cue point object contains for (i in rtn_cuePt) { //if an array object, open it up and trace contents if (typeof rtn_cuePt[i] == "object") { tracer(rtn_cuePt[i]); // else trace name (i) and value (rtn_cuePt[i]) pair } else { trace(i+ " " + rtn_cuePt[i]); } }
// trace array of cue points function tracer(cuepts:Array) { for (i in cuepts) { if (typeof cuepts[i] == "object") { //if object in object tracer(cuepts[i]); //trace object } else { // trace the name : value pair trace(i + " " + cuepts[i]); } } }
FLVPlayback.addASCuePoint(), FLVPlayback.cuePoints,
FLVPlayback.findNearestCuePoint(), FLVPlayback.findNextCuePointWithName(), FLVPlayback.isFLVCuePointEnabled(), FLVPlayback.removeASCuePoint(), FLVPlayback.seekToNavCuePoint(), FLVPlayback.seekToNextNavCuePoint(), FLVPlayback.seekToPrevNavCuePoint(), FLVPlayback.setFLVCuePointEnabled()
my_FLVplybk.findNearestCuePoint(time:Number[, type:String]):Object my_FLVplybk.findNearestCuePoint(name:String[, type:String]):Object my_FLVplybk.findNearestCuePoint(cuePoint:Object[, type:String]):Object
A number that is the time, in seconds, of the cue point for which to search. The method uses only the first three decimal places and rounds any additional decimal places that you provide. The method returns the cue point that matches this time or the nearest earlier cue point of the specified type. If multiple cue points have the same time, which can only occur with ActionScript cue points, the method returns only the name that is first in alphabetical order. It returns null if it does not find a match. A string that is the name of the cue point for which to search. The method returns the first cue point that matches this name or null, if it does not find a match.

The following example creates two video players to play two FLV files consecutively in a single FLVPlayback instance. It sets the visibleVideoPlayerIndex property to make the video players and the FLV files visible. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline:
/** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ import mx.video.*; // specify name and location of FLV for default player my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ clouds.flv" var listenerObject:Object = new Object(); listenerObject.ready = function(eventObject:Object):Void { // add a second video player and specify the name and loc of its FLV my_FLVPlybk.activeVideoPlayerIndex = 1; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ water.flv"; // reset to default video player, which plays its FLV automatically my_FLVPlybk.activeVideoPlayerIndex = 0; };
my_FLVPlybk.addEventListener("ready", listenerObject); listenerObject.complete = function(eventObject:Object):Void { // if complete is for 2nd FLV, make default active and visible if (eventObject.vp == 1) { my_FLVPlybk.activeVideoPlayerIndex = 0; my_FLVPlybk.visibleVideoPlayerIndex = 0; } else { // make 2nd player active & visible and play FLV my_FLVPlybk.activeVideoPlayerIndex = 1; my_FLVPlybk.visibleVideoPlayerIndex = 1; my_FLVPlybk.play(); } }; // add listener for complete event my_FLVPlybk.addEventListener("complete", listenerObject);
FLVPlayback.activeVideoPlayerIndex, FLVPlayback.setScale(), FLVPlayback.setSize(), FLVPlayback.height, FLVPlayback.width, FLVPlayback.scaleX, FLVPlayback.scaleY, FLVPlayback.visible

my_FLVPlybk.volume

Property; a number in the range of 0 to 100 that indicates the volume control setting. The default value is 100.
The following example sets the initial volume to 10, a relatively low setting. Drag an FLVPlayback component to the Stage, and give it an instance name of my_FLVPlybk. Then add the following code to the Actions panel on Frame 1 of the Timeline:
/** Requires: - FLVPlayback component on the Stage with an instance name of my_FLVPlybk */ import mx.video.*; // You can change this value from 0 to 100 my_FLVPlybk.volume = 10; my_FLVPlybk.contentPath = "http://www.helpexamples.com/flash/video/ cuepoints.flv";
FLVPlayback.transform, FLVPlayback.volumeBar, FLVPlayback.volumeBarInterval, FLVPlayback.volumeUpdate
my_FLVPlybk.volumeBarInterval

The Focus Manager interacts with the System Manager, which activates and deactivates FocusManager instances as pop-up windows are activated or deactivated. Each modal window has an instance of FocusManager so the components in that window become their own tab set, preventing the user from tabbing into components in other windows. The Focus Manager recognizes groups of radio buttons (those with a defined RadioButton.groupName property) and sets focus to the instance in the group that has a selected property that is set to true. When the Tab key is pressed, the Focus Manager checks to see if the next object has the same group name as the current object. If it does, it automatically moves focus to the next object with a different group name. Other sets of components that support a groupName property can also use this feature.
The Focus Manager handles focus changes caused by mouse clicks. If the user clicks a component, that component is given focus.

TI P 718 N OTE

When testing a script using Focus Manager (Control > Test Movie), select Control > Disable Keyboard Shortcuts in test mode; otherwise, Focus Manager does not appear to work. Also, tabbing and keyboard shortcuts are used by the authoring environment by default. So, if you use test mode, the tab navigation, Enter key, and other key combinations may perform in unexpected ways or appear to fail. Those features should be tested in the Player outside the authoring environment.

Using Focus Manager

The Focus Manager does not automatically assign focus to a component. You must write a script that calls FocusManager.setFocus() on a component if you want a component to have focus when an application loads.
If you call FocusManager.setFocus() to set focus to a component when an application loads, the focus ring does not appear around that component. The component has focus, but the indicator is not present.
To create focus navigation in an application, set the tabIndex property on any objects (including buttons) that should receive focus. When a user presses the Tab key, the Focus Manager looks for an enabled object with a tabIndex property that is higher than the current value of tabIndex. Once the Focus Manager reaches the highest tabIndex property, it returns to zero. So, in the following example, the comment object (probably a TextArea component) receives focus first, and then the okButton object receives focus:

This code creates a listener object, mblistener, that catches a menu item selection and displays its name and the value of the menu item object.
You must call the addEventListener() method to register the listener with the menu instance, not with the menu bar instance.
Select Control > Test Movie to test the MenuBar component.
Customizing the MenuBar component
This component sizes itself according to the activator labels that are supplied through the dataProvider property or the methods of the MenuBar class. When an activator button is in a menu bar, it remains at a fixed size that is dependent on the font styles and the text length.
Using styles with the MenuBar component
The MenuBar component creates an activator label for each menu in a group. You can use styles to change the look of the activator labels. A MenuBar component supports the following styles:
Halo The base color scheme of a component. Possible values are "haloGreen", "haloBlue", and "haloOrange". The default value is "haloGreen". The text color. The default value is 0x0B333C for the Halo theme and blank for the Sample theme. The color for text when the component is disabled. The default color is 0x848384 (dark gray). A Boolean value that indicates whether the font specified in fontFamily is an embedded font. This style must be set to true if fontFamily refers to an embedded font. Otherwise, the embedded font is not used. If this style is set to true and fontFamily does not refer to an embedded font, no text is displayed. The default value is false. The font name for text. The default value is "_sans". The point size for the font. The default value is 10. The font style: either "normal" or "italic". The default value is "normal". The font weight: either "none" or "bold". The default value is "none". All components can also accept the value "normal" in place of "none" during a setStyle() call, but subsequent calls to getStyle() return "none". The text decoration: either "none" or "underline". The default value is "none".
The MenuBar component also forwards all style settings for Menu style properties to the composed Menu instances. For a list of Menu style properties, see Using styles with the Menu component on page 898.
Using skins with the MenuBar component
The MenuBar component uses three skins to represent its background, uses a movie clip symbol for highlighting individual items, and contains a Menu component as the pop-up, which itself is skinnable. The MenuBar skins are described in the following table. For information about skinning the Menu component, see Using skins with the Menu component on page 901. The MenuBar component supports the following skin properties.

ProgressBar.direction

progressBarInstance.direction
Property; indicates the fill direction for the progress bar. A value of right specifies that the bar will fill from left to right. A value of left specifies that the bar will fill from right to left. The default value is right.
The following code loads a sound object and marks the progress with a progress bar that fills to the left. You must first drag a ProgressBar component from the Components panel to the current documents library; then add the following code to Frame 1 of the main timeline:
/** Requires: - ProgressBar component in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 20); //Set progress bar attributes my_pb.mode = "polled"; my_pb.source = "my_sound"; my_pb.direction = "left"; //Load sound var my_sound:Sound = new Sound(); my_sound.loadSound("http://www.helpexamples.com/flash/sound/disco.mp3", true);
ProgressBar.indeterminate
progressBarInstance.indeterminate
Property; a Boolean value that indicates whether the progress bar has a striped fill and a loading source of unknown size (true), or a solid fill and a loading source of a known size (false). For example, you might use this property if you are loading a large data set into a SWF file and do not know the size of the data you are loading.
The following code creates an indeterminate progress bar that moves from left to right with a striped fill. You must first drag a Loader component and a ProgressBar component from the Components panel to the current documents library; then add the following code to Frame 1 of the main timeline:
/** Requires: - ProgressBar component in library - Loader component in library */ System.security.allowDomain("http://www.helpexamples.com"); this.createClassObject(mx.controls.ProgressBar, "my_pb", 10); this.createClassObject(mx.controls.Loader, "my_ldr", 20); //Create Listener Object var pbListener:Object = new Object(); pbListener.complete = function(evt_obj:Object) { trace("Height: " + evt_obj.target.height + ", Width: " + evt_obj.target.width);}; //Add Listener my_pb.addEventListener("complete", pbListener); //Set progress bar settings my_pb.mode = "polled";

Using the TextInput component
You can use a TextInput component wherever you need a single-line text field. If you need a multiline text field, use the TextArea component. For example, you could use a TextInput component as a password field in a form. You could also set up a listener that checks if the field has enough characters when a user tabs out of the field. That listener could display an error message indicating that the proper number of characters must be entered.

TextInput parameters

You can set the following authoring parameters for each TextInput component instance in the Property inspector or the Component inspector (Window > Component Inspector menu option):
indicates whether the TextInput component is editable (true) or not (false). The default value is true.
password indicates whether the field is a password field (true) or not (false). The default value is false. text specifies the contents of the TextInput component. You cannot enter carriage returns in the Property inspector or the Component inspector. The default value is "" (an empty string).
You can set the following additional parameters for each TextInput component instance in the Component inspector (Window > Component Inspector):
maxChars is the maximum number of characters that the text input field can contain. The default value is null (meaning unlimited). restrict indicates the set of characters that a user can enter in the text input field. The default value is undefined. See TextInput.restrict on page 1229. enabled is a Boolean value that indicates whether the component can receive focus and input.

N OTE 1210

You can write ActionScript to control these and additional options for the TextInput component using its properties, methods, and events. For more information, see TextInput class on page 1214.
Creating an application with the TextInput component
The following procedure explains how to add a TextInput component to an application while authoring. In this example, the component is a password field with an event listener that determines if the proper number of characters has been entered.
To create an application with the TextInput component:
Select File > New and choose Flash File (ActionScript 2.0). Drag a TextInput component from the Components panel to the Stage. In the Property inspector, do the following:
Enter the instance name my_ti. Leave the text parameter blank. Set the editable parameter to true.
/** Requires: - TextInput instance on Stage (instance name: my_ti) */ var my_ti:mx.controls.TextInput; // Create listener object. var tiListener:Object = new Object(); tiListener.handleEvent = function (evt_obj:Object){ if (evt_obj.type == "enter"){ if (my_ti.length < 8) { trace("You must enter at least 8 characters"); } else { trace("Thanks"); } } } // Add listener. my_ti.addEventListener("enter", tiListener); This code sets up an enter event handler on the TextInput instance

wsc.params = [param_txt.text];
componentInstance.addEventListener("result", myListenerObject)
Event; broadcast when a call to a web service completes successfully. The parameter to the event handler is an object with the following fields:
the string "result"
target: a reference to the object that emitted the event (for example, a WebServiceConnector component)
You can retrieve the actual result value using the results property.
The following example defines a function res for the result event and assigns the function to the addEventListener event handler:
var res = function (ev) { trace(ev.target.results); }; wsc.addEventListener("result", res);
This example returns data from a remote web service and traces a tip. Drag a WebServiceConnector component into your library, and enter the following code on Frame 1 of the timeline:
import mx.data.components.WebServiceConnector; var wscListener:Object = new Object(); wscListener.result = function(evt:Object) { trace(evt.target.results); }; var wsConn:WebServiceConnector = new WebServiceConnector(); wsConn.addEventListener("result", wscListener); wsConn.WSDLURL = "http://www.flash-mx.com/mm/tips/tips.cfc?wsdl"; wsConn.operation = "getTipByProduct"; wsConn.params = ["Flash"]; wsConn.trigger();
componentInstance.results
Property; identifies data that was received from the server as a result of a trigger() operation. Each WebServiceConnector component defines how this data is fetched, and what the valid types are. This data appears when the RPC operation has successfully completed, as signaled by the result event. It is available until the component is unloaded, or until the next RPC operation. The returned data can be large. You can manage this size in two ways:
Select an appropriate movie clip, timeline, or screen as the parent for the WebServiceConnector component. The components storage memory becomes available for garbage collection when the parent is destroyed. In ActionScript, you can assign null to this property at any time.
componentInstance.addEventListener("send", myListenerObject)
Event; broadcast during the processing of a trigger() operation, after the parameter data has been gathered but before the data is validated and the call to the web service is initiated. This is a good place to put code that modifies the parameter data before the call. The parameter to the event handler is an object with the following fields:
the string "send"

The following example creates a window and then defines a complete handler that resizes the window to fit its contents. You drag a Window component from the Components panel to the current documents library, and then add the following code to Frame 1:
/** Requires: - Window component in library */
import mx.managers.PopUpManager; import mx.containers.Window; System.security.allowDomain("http://www.flash-mx.com"); var my_win:MovieClip = PopUpManager.createPopUp(this, Window, true, {closeButton:true, contentPath:"http://www.flash-mx.com/images/ image1.jpg"}); var winListener:Object = new Object(); winListener.click = function(evt_obj:Object) { my_win.deletePopUp(); }; winListener.complete = function(evt_obj:Object) { my_win.setSize(my_win.content._width, my_win.content._height + 25); } my_win.addEventListener("click", winListener); my_win.addEventListener("complete", winListener);

windowInstance.content

Read-only property; a reference to the content (root movie clip) of the window. This property returns a MovieClip object. When you attach a symbol from the library, the default value is an instance of the attached symbol. When you load content from a URL, the default value is undefined until the load operation has started.
The following example creates a window and then defines a complete handler that resizes the window to fit its contents. It uses the content property to reference the width of the windows movie clip content. You drag a Window component from the Components panel to the current documents library, and then add the following code to Frame 1:
/** Requires: - Window component in library */ import mx.managers.PopUpManager; import mx.containers.Window; System.security.allowDomain("http://www.flash-mx.com"); var my_win:MovieClip = PopUpManager.createPopUp(this, Window, true, {closeButton:true, contentPath:"http://www.flash-mx.com/images/ image1.jpg"}); var winListener:Object = new Object(); winListener.click = function(evt_obj:Object) { my_win.deletePopUp(); }; winListener.complete = function(evt_obj:Object) { my_win.setSize(my_win.content._width, my_win.content._height + 25); } my_win.addEventListener("click", winListener); my_win.addEventListener("complete", winListener);

 

Technical specifications

Full description

The "ActionScript 2.0 Language Reference for Macromedia Flash 8" is a comprehensive reference manual that describes the application programming interface (API) for Macromedia Flash Player, the most pervasive client runtime environment in the world. It includes valuable syntax and usage information; detailed descriptions of classes, functions, properties, and events; and copy-and-paste code samples for every element in the ActionScript language. The "ActionScript 2.0 Language Reference for Macromedia Flash 8" will help you: - Learn how to use specific APIs efficiently and effectively - Understand the range and variety of functionality ActionScript offers - Repurpose Macromedia-tested code in your own applications Powerful development and design tools require thorough and authoritative technical advice and documentation. When it comes to Macromedia Flash, no one is more authoritative than Macromedia Development and writing teams. Now their official documentation is available to you in printed book form. As you work, keep this guide by your side for ready access to valuable information on using Flash. We've designed it so that it's easy to annotate as you progress.

 

Tags

AX4BSV SU-VX920 A3000 VGN-A617M DMP-BD655 HDR-CX500VE IC-P7A 8838 PC LE32C535 DCB-P850R F1DS104P Kdna 4300 DXZ556MP LE32A436 Letra TAG VGN-A317M 1 0 Hc8440 JS-P502 S3PRO JW-K42A VGN-NS20e S KX-FP300E 55T03 Samsung E210 SC-155 FAX-2800 320MX-2 TH-42PZ80B Notice 42PFL3403 12 HD081GJ-SRA PD-M455 AV-HS300 VP-DC173 28PW5324 CT-700 MDR-XB40EX Samsung 712N GA-M61sme-s2 YV-150Z Of Rome 8120 USB Dvdm-800 Manfrotto 521 R-310AW 3350B W2284F-PF Review Hotpoint-ariston WD64 SF-2030 14C-GM3 26PFL5403D 10 Urc-7740 YBR125-2005 JR 2005 KDC-W4644UY PS50A456 TX-480L WF9702N3C LG U890 42PFL7422D 37 LA40B610 MS7090S Acapulco MP52 MS9058E 247-3 LN32A550p3R Pta60E PPC6700 Switch KDL-40S2810 SE-A800S SC-AK230 AOR-401M CAM-350 PCG-SRX77P 4 0 DPL913VD-receiver SR5002 HVR-M15AU Alero 2000 29PT6447-55 FRS 220 DVD-S557 C515BEE Photosmart 320 KH 2232 1800-204 Cezai998 LCD2010X Flash Electronic STR-GX900ES DA4002 Alfa 147 IC-730 DE6344 Sunfire 1998 F5U251 Lexmark C752

 

manuel d'instructions, Guide de l'utilisateur | Manual de instrucciones, Instrucciones de uso | Bedienungsanleitung, Bedienungsanleitung | Manual de Instruções, guia do usuário | инструкция | návod na použitie, Užívateľská príručka, návod k použití | bruksanvisningen | instrukcja, podręcznik użytkownika | kullanım kılavuzu, Kullanım | kézikönyv, használati útmutató | manuale di istruzioni, istruzioni d'uso | handleiding, gebruikershandleiding

 

Sitemap

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101