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

Macromedia Flash 8-learning Actionscript 2 0 IN Flash


Bookmark
Macromedia Flash 8-learning Actionscript 2 0 IN Flash

Bookmark and Share

 

Macromedia Flash 8-learning Actionscript 2 0 IN FlashLearning ActionScript 2.0 for Macromedia Flash 8 [Book]

By Jen DeHaan, Peter DeHaan - Macromedia Press (2006) - Paperback - 848 pages - ISBN 0321394151

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. Wersquo;ve designed it so that itrsquo;s easy to annotate as you progress. Learning ActionScript 2.0 for M... Read more
[ Report abuse or wrong photo | Share your Macromedia Flash 8-learning Actionscript 2 0 IN Flash 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-learning Actionscript 2.0 IN Flash, size: 6.5 MB

 

Macromedia Flash 8-learning Actionscript 2 0 IN Flash

 

 

Video review

Awesome Tutorial Flash 8 Objects move in one direction with mouse

 

User reviews and opinions

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

Comments to date: 2. Page 1 of 1. Average Rating:
hellman 3:36am on Sunday, May 2nd, 2010 
Love both the silicone case and zebra sleeve pouch. This product is EXACTLY what I wanted. It fits perfectly and it got here very fast. The item was all that the description said it would be! I am very pleased with this product and would recommend it to friends.
chiew-sum ng 5:38am on Friday, March 12th, 2010 
Bought the 16G WiFi for my wife. She enjoys playing games, surfing the web, reading books, reading email and catching up on her Soaps at ABC.com.

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

About the Script window

You can write and edit ActionScript in the Script window when you create a new ActionScript, Flash Communication, or Flash JavaScript file. You use the Script window to write and edit external script files. Syntax coloring, code hinting, and other editor options are supported in the Script window. You can create external ActionScript, ActionScript communication, and Flash JavaScript files in the Script window. Depending upon the type of external script file you create, the Actions toolbox provides you with a complete list of the language elements available for each. When you use the Script window, youll notice that some of the other code-assistance features like Script navigator, Script Assist mode, and behaviors are unavailable. This is because these features are only useful in the context of creating a Flash document, not for creating an external script file.
You will also notice that many of the options available in the Actions panel are unavailable in the Script window. The Script window supports the following editor options: the Actions toolbox, find and replace, syntax checking, automatic formatting, code hinting, and debug options (ActionScript files only). Additionally, the Script window supports displaying line numbers, hidden characters, and word wrap.
To display the Script window:
Select File > New. Select the type of external file you want to create (ActionScript file, Flash Communication file, or Flash JavaScript file).
You can have multiple external files open at the same time; filenames are displayed on tabs across the top of the Script window. For more information on features in the Script window, see the following topics:
About coding in the Actions panel and Script window
The Script pane, where you edit code, is the primary element of both the Actions panel and the Script window. The Actions panel and Script window offer basic script editing and codeassistance features like code hinting, coloring, automatic formatting, and so on. Features that help you edit code are accessible from the toolbar in the Actions panel or Script window, through the menu system, and in the Script pane itself.

Another example is the addition (+) operator, which you use to add two or more numeric values to produce a new value. If you use the + operator on two or more string values, the strings will be concatenated. The values that operators manipulate are called operands.
When you assign a value, you use an operator to define a value to a variable. For example, the following script uses the assignment operator to assign a value of 7 to the variable numChildren:
var numChildren:Number = 7;
If you want to change the value of the numChildren variable, use the following code:
numChildren = 8; You dont need to use var because the variable has previously been defined.
For more information on using operators in your ActionScript, see About operators on page 176.

About naming variables

Be careful when you start naming variables, because although they can have nearly any name, there are some rules. A variables name must follow these rules: A variable must be an identifier.
An identifier is the name of a variable, property, object, function, or method. The first character of an indentifier must be a letter, underscore (_), or dollar sign ($). Each subsequent character can be a number, letter, underscore, or dollar sign.
A variable cannot be a keyword or an ActionScript literal such as true, false, null, or undefined. For more information on literals, see About literals on page 130. A variable must be unique within its scope (see About variables and scope on page 96). A variable should not be any element in the ActionScript language, such as a class name.
If you dont follow the rules when you name a variable, you might experience syntax errors or unexpected results. In the following example, if you name a variable new and then test your document, Flash will generate a compiler error:
// This code works as expected. var helloStr:String = new String(); trace(helloStr.length); // 0 // But if you give a variable the same name as a built-in class. var new:String = "hello"; //error: Identifier expected var helloStr:String = new String(); trace(helloStr.length); // undefined

This example simply shows that the global variable is not accessed in the scope of the count() function. However, you could access the global-scoped variable if you prefix it with _global. For example, you could access it if you prefix the counter with _global as shown in the following code:

trace(_global.counter);

You cannot assign strict data types to variables that you create in the _global scope, because you have to use the var keyword when you assign a data type. For example, you couldn't do:
_global.foo:String = "foo"; //syntax error var _global.foo:String = "foo"; //syntax error
The Flash Player version 7 and later security sandbox enforces restrictions when accessing global variables from SWF files loaded from separate security domains. For more information, see Chapter 17, Understanding Security, on page 677.

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.

Its also possible for operators to have the same precedence. In this case, the associativity determines the order in which the operators perform. You can either have left-to-right associativity or right-to-left associativity. Take a look at the multiplication operator again. It has left-to-right associativity, so the following two statements are the same.
var mySum:Number; var myOtherSum:Number; mySum = 2 * 4 * 3; myOtherSum = (2 * 4) * 3; trace(mySum); // 24 trace(myOtherSum); // 24
You might encounter situations in which two or more operators of the same precedence appear in the same expression. In these cases, the compiler uses the rules of associativity to determine which operator to process first. All of the binary operators, except the assignment operators, are left-associative, which means that operators on the left are processed before operators on the right. The assignment operators and the conditional (?:) operator are rightassociative, which means that the operators on the right are processed before operators on the left. For more information on assignment operators, see Using assignment operators on page 194. For more information on the conditional (?:) operator, see About the conditional operator on page 199. For example, consider the less than (<) and greater than (>) operators, which have the same precedence. If both operators are used in the same expression, the operator on the left is processed first because both operators are left-associative. This means that the following two statements produce the same output:
trace(3 > 2 < 1); // false trace((3 > 2) < 1); // false
The greater than (>) operator is processed first, which results in a value of true because the operand 3 is greater than the operand 2. The value true is then passed to the less than (<) operator, along with the operand 1. The less than (<) operator converts the value true to the numeric value 1 and compares that numeric value to the second operand 1 to return the value false (the value 1 is not less than 1). Consider the order of operands in your ActionScript, particularly when you set up complex conditions and you know how often one of those conditions is true. For example, if you know that i will be greater than 50 in your condition, you need to write i<50 first. Therefore, its checked first, and the second condition that you write doesnt need to be checked as often.
The following table lists all the ActionScript operators and their associativity, from highest to lowest precedence. For more information and guidelines on using operators and parentheses, see Chapter 19, Formatting ActionScript syntax, on page 764.
Operator Description Highest precedence
x++ x-. [ ] ( ) function ( ) ++x --x ~ ! new delete typeof void * / % + << >> >>> instanceof

Associativity

month: 7 min: -3 max: 34 For information on writing code using Script Assist, see Using Script Assist to write ActionScript on page 328, Creating a startDrag/stopDrag event using Script Assist on page 331 and the ActionScript:Use Script Assist Mode tutorial (which begins with Open the starter document on page 213).
Using variables in functions
Local variables are valuable tools for organizing code and making it easy to understand. When a function uses local variables, it can hide its variables from all other scripts in the SWF file; local variables are invoked in the scope of the body of the function and cease to exist when the function exits. Flash also treats any parameters passed to a function as local variables.
You can also use regular variables in a function. However, if you modify regular variables, it is good practice to use script comments to document these modifications.
To use variables in functions:
Create a new Flash document and save it as flashvariables.fla. Add the following ActionScript to Frame 1 of the main Timeline:
var myName:String = "Ester"; var myAge:String = "65"; var myFavSoftware:String = "Flash"; function traceMe(yourFavSoftware:String, yourName:String, yourAge:String) { trace("I'm " + yourName + ", I like " + yourFavSoftware + ", and I'm " + yourAge + "."); } traceMe(myFavSoftware, myName, myAge);
For more information on passing parameters, see Passing parameters to a function on page 218. For more information on variables and data, see Chapter 4, Data and Data Types, on page 71
Passing parameters to a function
Parameters, also referred to as arguments, are the elements on which a function executes its code. (In this book, the terms parameter and argument are interchangeable.) You can pass parameters (values) to a function. You can then use these parameters for processing the function. You use the values within the function block (statements within the function). Sometimes parameters are required, and sometimes they are optional. You might even have some required and some optional parameters in a single function. If you do not pass enough parameters to a function, Flash sets the missing parameter values to undefined, which may cause unexpected results in your SWF file. The following function called myFunc() takes the parameter someText:
function myFunc(someText:String):Void { trace(someText); }

Create a new ActionScript file, and then save it as Ia.as. In Ia.as, type the following ActionScript code into the Script window:
interface Ia { public function f1():Void; public function f2():Void; }
Save your changes to the ActionScript file. Create a new ActionScript file and save it as Ib.as in the same folder as the Ia.as file you created in step 1. In Ib.as, type the following ActionScript code into the Script window:
interface Ib extends Ia { public function f8():Void; public function f9():Void; }
Save your changes to the ActionScript file. Create a new ActionScript file and save it as ClassA.as in the same directory as the two previous files.
In ClassA.as, type the following ActionScript code into the Script window:
class ClassA implements Ib { // f1() and f2() are defined in interface Ia. public function f1():Void { } public function f2():Void { } // f8() and f9() are defined in interface Ib, which extends Ia. public function f8():Void { } public function f9():Void { } }
Save your class file and click the Check Syntax button above the Script window. Flash doesnt generate any error messages as long as all four methods are defined and match the definitions from their respective interface files.
Classes are only able to extend one class in ActionScript 2.0, although you can use classes to implement as many interfaces as you want.
If you want your ClassA class to implement multiple interfaces in the previous example, you would simply separate the interfaces with commas. Or, if you had a class that extended a superclass and implemented multiple interfaces, you would use code similar to the following:
class ClassA extends ClassB implements Ib, Ic, Id {.}.
Example: Using interfaces
In this example you create a simple interface that you can reuse between many different classes.

To build an interface:

Create a new ActionScript file and save it as IDocumentation.as. In IDocumentation.as, type the following ActionScript code into the Script window:
interface IDocumentation { public function downloadUpdates():Void; public function checkForUpdates():Boolean; public function searchHelp(keyword:String):Array; }
Save the changes that you made to the ActionScript interface file. Create a new ActionScript file in the same directory as the IDocumentation.as file, and save this new file as FlashPaper.as.
Example: Using interfaces 321
In FlashPaper.as, type the following ActionScript code into the Script window:

If you create component properties for a class and want a movie clip to inherit those component properties, you need to take an additional step: with the movie clip symbol selected in the Library panel, select Component Definition from the Library pop-up menu and enter the new class name in the Class box.
Initializing class properties
In the example presented in the second procedure under Assigning a class to a movie clip symbol, you added the instance of the Ball symbol to the Stage while authoring. As discussed in Adding parameters to dynamically created movie clips on page 364, you can assign parameters to clips you create at runtime by using the initObject parameter of attachMovie() and duplicateMovie(). You can use this feature to initialize properties of the class youre assigning to a movie clip.
For example, the following class named MoveRightDistance is a variation of the MoveRight class (see Assigning a class to a movie clip symbol on page 378). The difference is a new property named distance, whose value determines how many pixels a movie clip moves each time it is clicked.
To pass arguments to a custom class:
Create a new ActionScript document and save it as MoveRightDistance.as. Type the following ActionScript into the Script window:
// MoveRightDistance class -- moves clip to the right 5 pixels every frame. class MoveRightDistance extends MovieClip { // Distance property determines how many // pixels to move clip for each mouse press. var distance:Number; function onPress() { this._x += this.distance; } }
Save your progress. Create a new Flash document, and save it as MoveRightDistance.fla in the same directory as the class file. Create a movie clip symbol that contains a vector shape, such as an oval, and then delete any content from the Stage. You only need a movie clip symbol in the library for this example. In the Library panel, right-click (Windows) or Control-click (Macintosh) the symbol and select Linkage from the context menu. Assign the linkage identifier Ball to the symbol. Type MoveRightDistance into the AS 2.0 Class text box. Add the following code to Frame 1 of the Timeline:
this.attachMovie("Ball", "ball50_mc", 10, {distance:50}); this.attachMovie("Ball", "ball125_mc", 20, {distance:125});
This code creates two new instances of the symbol on the root timeline of the SWF file. The first instance, named ball50_mc, moves 50 pixels each time it is clicked; the second, named ball125_mc, moves 125 pixels each time it is clicked.

MovieClip.createTextField()
For more information on using the TextField class, see the following topics:
Assigning text to a text field at runtime on page 385 About text field instance and variable names on page 386
You can find sample source files that demonstrate how to work with text fields using ActionScript. The source files are called textfieldsA.fla and textfieldsB.fla, and you can find them in the Samples folder on your hard disk:
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\TextFields.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript/TextFields.
Assigning text to a text field at runtime
When you build applications with Flash, you may want to load text from an external source, such as a text file, an XML file, or even a remote web service. Flash provides a great deal of control over how you create and display text on the Stage, such as supporting text that is HTML formatted, plain text, XML formatted text, and external style sheets. Or you can use ActionScript to define a stylesheet. To assign text to a text field, you can use the TextField.text or the TextField.htmlText property. Or, if you entered a value in the variable text field in the Property inspector, you can assign a value to the text field by creating a variable with the specified name. If you use version 2 of Macromedia Components Architecture in your Flash document, you can also assign values by creating bindings between components. The following exercise assigns text to a text field at runtime.
To assign text to a text field at runtime:
Using the Text tool, create a text field on the Stage. With the text field selected, in the Property inspector (Window > Properties > Properties), select Input Text from the Text Type pop-up menu, and enter headline_txt in the Instance Name text box. Instance names must consist only of letters, numbers, underscores (_), and dollar signs ($).

Applies advanced anti-aliasing for improved text readability, which is available in Flash Player 8. Advanced anti-aliasing allows font faces to be rendered at very high quality at small sizes. It is best used with applications that have a lot of small text.
Macromedia does not recommend advanced anti-aliasing for fonts larger than 48 points.

advanced

To use ActionScript to set anti-alias text, see the following example.
To use advanced anti-aliasing:
Create a new Flash document and save it as antialiastype.fla. Create two movie clips on the Stage and give them instances names of normal_mc and advanced_mc. You will use these movie clips to toggle between the two types of anti-aliasing: normal and advanced.
Open the Library panel and select New Font from the pop-up menu in the upper-right corner of the Library panel. The Font Symbol Properties dialog box opens, in which you can select a font to embed in the SWF file (including a font style and font size). You can also assign a font name that appears in the documents library and in the Font drop-down menu in the Property inspector (if you have a text field selected on the Stage).

a. b. c. d. e.

Select the Arial font from the Font drop-down menu. Make sure that the Bold and Italic options are not selected. Set the size to 10 pixels. Enter the font name of Arial-10 (embedded). Click OK.
In the library, right-click the font symbol and select Linkage from the context menu. The Linkage Properties dialog box appears.
Select the Export for ActionScript and Export in First Frame options, enter the linkage identifier Arial-10, and click OK. Add the following ActionScript to Frame 1 of the main Timeline:
var text_fmt:TextFormat = new TextFormat(); text_fmt.font = "Arial-10"; text_fmt.size = 10; this.createTextField("my_txt", 10, 20, 20, 320, 240); my_txt.autoSize = "left"; my_txt.embedFonts = true; my_txt.selectable = false; my_txt.setNewTextFormat(text_fmt); my_txt.multiline = true; my_txt.wordWrap = true; var lorem_lv:LoadVars = new LoadVars(); lorem_lv.onData = function(src:String) { if (src != undefined) { my_txt.text = src; } else { my_txt.text = "unable to load text file."; } }; lorem_lv.load("http://www.helpexamples.com/flash/lorem.txt"); normal_mc.onRelease = function() { my_txt.antiAliasType = "normal"; }; advanced_mc.onRelease = function() { my_txt.antiAliasType = "advanced"; };
The preceding code is separated into four key areas. The first block of code creates a new TextFormat object, which specifies a font and font size to be used for a text field that will be created shortly. The specified font, Arial-10, is the linkage identifier for the font symbol that you embedded in a previous step. The second block of code creates a new text field with the instance name my_txt. In order for the font to be properly embedded, you must set embedFonts to true for the text field instance. The code also sets the text formatting for the new text field to the TextFormat object that you created earlier. The third block of code defines a LoadVars instance that populates the text field on the Stage with the contents of an external text file. After the document is fully loaded (but not parsed), the entire contents of the file are copied into the my_txt.text property, so that they are displayed on the Stage.

Using filter effects

Filters are visual effects that you can apply to objects rendered at runtime by Flash Player, such as movie clip instances. The filters include drop shadow, blur, glow, bevel, gradient glow, and gradient bevel. You can also use an adjust color filter that lets you edit a movie clips brightness, contrast, saturation, and hue. You can apply filters using the Flash user interface in Flash Professional 8, or using ActionScript in Flash Basic 8 or Flash Professional 8. You can apply each of these filter effects to movie clips, buttons, or text fields by using either the Filters tab in the Property inspector or by using ActionScript. If you use ActionScript to apply the filters to an instance, you can also use a displacement map filter (see Using the displacement map filter on page 528) or a convolution filter (see Using the convolution filter on page 527). These filters are applied to the vector definitions, so there is no overhead of storing a bitmap image within the SWF file. You can also write ActionScript that lets you modify an existing filter that you applied to a text field, movie clip, or button. The following procedure demonstrates how you could use an onEnterFrame event handler to animate a glow filter effect on a movie clip.
To animate a filter effect applied to a movie clip instance:
Create a new Flash document and save it as animFilter.fla. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("box_mc", 10); box_mc.lineStyle(20, 0x000000); box_mc.beginFill(0x000000); box_mc.moveTo(0, 0); box_mc.lineTo(160, 0); box_mc.lineTo(160, 120); box_mc.lineTo(0, 120); box_mc.lineTo(0, 0); box_mc.endFill(); box_mc._x = 100; box_mc._y = 100; box_mc.filters = [new flash.filters.GlowFilter()]; var dir:Number = 1; box_mc.blur = 10; box_mc.onEnterFrame = function() { box_mc.blur += dir; if ((box_mc.blur >= 30) || (box_mc.blur <= 10)) { dir *= -1; } var filter_array:Array = box_mc.filters; filter_array[0].blurX = box_mc.blur; filter_array[0].blurY = box_mc.blur; box_mc.filters = filter_array; };
This code completes two different functionalities. The first section creates and positions a movie clip instance, and draws a black rounded rectangle on the Stage. The second block of code applies a glow filter to the rectangle on the Stage and defines an onEnterFrame event handler, which is responsible for animating the filter effect. The onEnterFrame event handler animates the glow filter between a blur of 10 and 30 pixels, and after the animation is greater than or equal to 30, or less than or equal to 10, the direction of the animation reverses.

trace(my_mc.filters[0].angle); // 45.0 trace(my_mc.filters[0].distance); // 4
You can access and modify filters as you would a regular array object. Setting and getting the filters by using the property returns a duplicate of the filters object, not a reference. To modify an existing filter, you can use code similar to the code in the following procedure.
To modify a filters properties when applied to a movie clip instance:
Create a new Flash document and save the file as modifyFilter.fla. Add the following ActionScript to Frame 1 of the Timeline:
this.createEmptyMovieClip("my_mc", 10); // draw square with (my_mc) { beginFill(0xFF0000, 100); moveTo(0, 0); lineTo(100, 0); lineTo(100, 100); lineTo(0, 100); lineTo(0, 0); endFill(); } my_mc._x = 100; my_mc._y = 100; // use default DropShadowFilter values my_mc.filters = [new flash.filters.DropShadowFilter()]; trace(my_mc.filters[0].distance); // 4 var filter_array:Array = my_mc.filters; filter_array[0].distance = 10; my_mc.filters = filter_array; trace(my_mc.filters[0].distance); // 10
The first section of this code uses the Drawing API to create a red square, and positions the shape on the Stage. The second section of code applies a drop shadow filter to the square. Next, the code creates a temporary array to hold the current filters to apply to the red square on the Stage. The distance property of the first filter is set to 10 pixels, and the modified filter is reapplied to the my_mc movie clip instance.
Currently, no support is available for having any filters perform rotation based upon their parents rotation or some sort of other rotation. The blur filter always blurs perfectly horizontally or vertically, independently of the rotation or skew of any item in the parent object tree. Filtered content has the same restrictions on size as content with its cacheAsBitmap property set to true. If the author zooms in too far on the SWF file, the filters are no longer visible when the bitmap representation is greater than 2880 pixels in either direction. When you publish SWF files with filters, it is a good idea to disable the zoom menu options.

N OT E TIP

About hit detection, rotating, skewing, and scaling filters
No filtered region (drop shadow, for example) outside of a movie clip instances bounding box rectangle is considered to be part of the surface for hit detection purposes (determining if an instance overlaps or intersects with another instance). Because hit detection is vector-based, you cannot perform a hit detection on the bitmap result. For example, if you apply a bevel filter to a button instance, hit detection is not available on the beveled portion of the instance. Scaling, rotating, and skewing are not supported by filters; if the instance itself is scaled (_xscale and _yscale are not 100%), the filter effect does not scale with the instance. This means that the original shape of the instance rotates, scales, or skews; however, the filter does not rotate, scale, or skew with the instance. You can animate an instance with a filter to create realistic effects, or nest instances and use the BitmapData class to animate filters to achieve this effect.

var distance:Number = 10;
Add the following ActionScript code to the Actions panel below the existing code:
this.createTextField("display_txt", 999, 0, 0, 100, 20);
To create the event handler for the car movie clip that checks which arrow key (left, right, up, or down) is currently pressed, add the following code to the Actions panel:
var keyListener:Object = new Object(); keyListener.onKeyDown = function() { }; Key.addListener(keyListener);
To check if the Left Arrow key is pressed and to move the car movie clip accordingly, add code to the body of the onEnterFrame event handler. Your code should look like the following example (new code is in boldface):
var distance:Number = 10; this.createTextField("display_txt", 999, 0, 0, 100, 20); var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.LEFT)) { car_mc._x = Math.max(car_mc._x - distance, 0); display_txt.text = "Left"; } }; Key.addListener(keyListener);
If the Left Arrow key is pressed, the cars _x property is set to the current _x value minus distance or the value 0, whichever is greater. Therefore, the value of the _x property can never be less than 0. Also, the word Left should appear in the SWF file.
Use similar code to check if the Right, Up, or Down Arrow key is being pressed. Your complete code should look like the following example (new code is in boldface):
var distance:Number = 10; this.createTextField("display_txt", 999, 0, 0, var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.LEFT)) { car_mc._x = Math.max(car_mc._x - distance, display_txt.text = "Left"; } else if (Key.isDown(Key.RIGHT)) { car_mc._x = Math.min(car_mc._x + distance, car_mc._width); display_txt.text = "Right"; } else if (Key.isDown(Key.UP)) { car_mc._y = Math.max(car_mc._y - distance, display_txt.text = "Up"; } else if (Key.isDown(Key.DOWN)) { car_mc._y = Math.min(car_mc._y + distance, car_mc._height); display_txt.text = "Down"; } }; Key.addListener(keyListener); 100, 20);

Stage.width -

Stage.height -
Select Control > Test Movie to test the file.
For more information about the methods of the Key class, see Key in the ActionScript 2.0 Language Reference.

Setting color values

You can use the methods of the built-in ColorTransform class (flash.geom.ColorTransform) to adjust the color of a movie clip. The rgb property of the ColorTransform class assigns hexadecimal red, green, blue (RGB) values to the movie clip. The following example uses rgb to change an objects color, based on which button the user clicks.
To set the color value of a movie clip:
Create a new Flash document and save it as setrgb.fla. Select the Rectangle Tool and draw a large square on the Stage. Convert the shape to a movie clip symbol and give the symbol an instance name of car_mc in the Property inspector. Create a button symbol named colorChip, place four instances of the button on the Stage, and name them red_btn, green_btn, blue_btn, and black_btn. Select Frame 1 in the main Timeline, and select Window > Actions. Add the following code to Frame 1 of the main Timeline:
import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); var trans:Transform = new Transform(car_mc); trans.colorTransform = colorTrans;
To make the blue button change the color of the car_mc movie clip to blue, add the following code to the Actions panel:
blue_btn.onRelease = function() { colorTrans.rgb = 0x333399; // blue trans.colorTransform = colorTrans; };
The preceding snippet of code changes the rgb property of the color transform object and reapplies the color tranform effect to the car_mc movie clip whenever the button is pressed.
Repeat step 7 for the other buttons (red_btn, green_btn, and black_btn) to change the color of the movie clip to the corresponding color. Your code should now look like the following example (new code is in bold):
import flash.geom.ColorTransform; import flash.geom.Transform; var colorTrans:ColorTransform = new ColorTransform(); var trans:Transform = new Transform(car_mc); trans.colorTransform = colorTrans; blue_btn.onRelease = function() { colorTrans.rgb = 0x333399; // blue trans.colorTransform = colorTrans; }; red_btn.onRelease = function() { colorTrans.rgb = 0xFF0000; // red trans.colorTransform = colorTrans; }; green_btn.onRelease = function() { colorTrans.rgb = 0x006600; // green trans.colorTransform = colorTrans; }; black_btn.onRelease = function() { colorTrans.rgb = 0x000000; // black trans.colorTransform = colorTrans; };
Select Control > Test Movie to change the color of the movie clip.
For more information about the methods of the ColorTransform class, see ColorTransform (flash.geom.ColorTransform) in the ActionScript 2.0 Language Reference.

doc1

this.createEmptyMovieClip("square_mc", 1); square_mc.lineStyle(1, 0x000000, 100); square_mc.beginFill(0xFF0000, 100); square_mc.moveTo(100, 100); square_mc.lineTo(200, 100); square_mc.lineTo(200, 200); square_mc.lineTo(100, 200); square_mc.lineTo(100, 100); square_mc.endFill(); square_mc.onPress = function() { this.startDrag(); }; square_mc.onRelease = function() { this.stopDrag(); };
For more information, see Chapter 10, Working with Movie Clips, on page 313 and the MovieClip entry in the ActionScript 2.0 Language Reference.

null data type

The null data type has only one value, null. This value means no valuethat is, a lack of data. You can assign the null value in a variety of situations to indicate that a property or variable does not yet have a value assigned to it. For example, you can assign the null value in the following situations:
To indicate that a variable exists but has not yet received a value To indicate that a variable exists but no longer contains a value As the return value of a function, to indicate that no value was available to be returned by the function As a parameter to a function, to indicate that a parameter is being omitted
Several methods and functions return null if no value has been set. The following example demonstrates how you can use null to test if form fields currently have form focus:
if (Selection.getFocus() == null) { trace("no selection"); }

Number data type

The Number data type is a double-precision floating-point number. The minimum value of a number object is approximately 5e-324. The maximum is approximately 1.79E+308. You can manipulate numbers using the arithmetic operators addition (+), subtraction (-), multiplication (*), division (/), modulo (%), increment (++), and decrement (--). For more information, see Using numeric operators on page 149. You can also use methods of the built-in Math and Number classes to manipulate numbers. For more information on the methods and properties of these classes, see the Math and Number entries in ActionScript 2.0 Language Reference. The following example uses the sqrt() (square root) method of the Math class to return the square root of the number 100:

Math.sqrt(100);

The following example traces a random integer between 10 and 17 (inclusive):

var myNum:Number = 6; var squared:Number = myNum * myNum; trace(squared); // 36
Similar behavior occurs when you pass an undefined variable to a method or function, as shown next.
To compare undefined and defined variables being passed to a function:

1. 2. 3.

Drag a Button component to the Stage from the Components panel. Open the Property inspector and type bad_button into the Instance Name text box. Type the following code on Frame 1 of the Timeline.
// Does not work function badClickListener(evt:Object):Void { getURL(targetUrl); var targetUrl:String = "http://www.adobe.com"; } bad_button.addEventListener("click", badClickListener);
Select Control > Test Movie, and notice that the button does not work (it doesnt open the web page). Drag another Button component onto the Stage. Select the button. Open the Property inspector, and type good_button into the Instance Name text box.
Add the following ActionScript to Frame 1 of the Timeline (following the previous ActionScript you added):
// Works function goodClickListener(evt:Object):Void { var targetUrl:String = "http://www.adobe.com"; getURL(targetUrl); } good_button.addEventListener("click", goodClickListener);
Select Control > Test Movie and click the second button you added to the Stage. This button properly opens the web page.
The type of data that a variable contains affects how and when the variables value changes. Primitive data types, such as strings and numbers, are passed by value, which means the current value of the variable is used rather than a reference to that value. Examples of complex data types include the Array and Object data types. In the following example, you set myNum to 15 and copy the value into otherNum. When you change myNum to 30 (in line 3 of the code), the value of otherNum remains 15 because otherNum doesnt look to myNum for its value. The otherNum variable contains the value of myNum that it receives (in line 2 of the code).
To use variables in your ActionScript:
Create a new Flash document, and save it as var_example.fla. Select Frame 1 of the Timeline, and type the following code into the Actions panel:
var myNum:Number = 15; var otherNum:Number = myNum; myNum = 30; trace(myNum); // 30 trace(otherNum); // 15

If you want to pass multiple variables to Flash, you need to separate the name/values pairs with an ampersand (&). Find the following code from step 6:
?myURL=http://weblogs.macromedia.com
Replace it with the following text:
?myURL=http://weblogs.macromedia.com&myTitle=adobe+News+Aggregator
Remember, you need to make the same changes to both the object tag and the embed tag to maintain consistency between all browsers. You might notice that the words are separated by + punctuators. The words are separated this way because the values are URLencoded and the + punctuator represents a single blank space.
For a list of common URL-encoded special characters, see the Flash TechNote, URL Encoding: Reading special characters from a text file.
Because the ampersand (&) serves as a delimiter for different name/value pairs, if the values you are passing contain ampersands, unexpected results might occur. Given the nature of name/value pairs and parsing, if you had the following values being passed to Flash:
my.swf?name=PB+&+J&flavor=strawberry+rhubarb
Flash would build the following variables (and values) into the root scope:
'name': 'PB ' (note space at end of value) ' J': '' (note space at beginning of variable name and an empty value) 'flavor': 'strawberry rhubarb'
To avoid this, you need to escape the ampersand (&) character in the name/value pair with its URL-encoded equivalent (%26).
Open the urlvariables.html document, and find the following code:
?myURL=http://weblogs.macromedia.com&myTitle=Adobe+News+Aggregator
Replace it with the following code:
?myURL=PB+%26+J&flavor=strawberry+rhubarb
Save the revised HTML, and test your Flash document again. You see that Flash created the following name/value pairs.
'name': 'PB & J' 'flavor': 'strawberry rhubarb'
All browsers will support string sizes as large as 64K (65535 bytes) in length. FlashVars must be assigned in both the object and embed tags in order to work on all browsers.
Using FlashVars in an application
Using FlashVars to pass variables into Flash is similar to passing variables along the URL in the HTML code. With FlashVars, instead of passing variables after the filename, variables are passed in a separate param tag as well as in the embed tag.

dynamic class Person2 { public var userName:String; public var age:Number; }
This ActionScript adds the dynamic keyword to the Person class in the previous example. Instances of the Person2 class can add and access properties and methods that are not defined in this class.
Save your changes to the ActionScript file. Select File > New and then select Flash Document to create a new FLA file, and then click OK. Select File > Save As and name the new file person2_test.fla. Save it in the same directory as Person2.as.
Type the following code to create a new instance of the Person2 class (firstPerson), and assign a value to a property called hairColor (which doesnt exist in the Person2 class).
var firstPerson:Person2 = new Person2(); firstPerson.hairColor = "blue"; trace(firstPerson.hairColor); // blue
Save your changes to the person2_test.fla file. Select Control > Test Movie to test the code. Because the custom Flash class is dynamic, you can add methods and properties to the class at runtime (when the SWF file plays). When you test the code the text blue should be displayed in the Output panel.
When you develop applications, you wouldnt want to make classes dynamic unless you needed to. One reason not to use dynamic classes is that type checking on dynamic classes is less strict than type checking on nondynamic classes, because members accessed inside the class definition and on class instances are not compared with those defined in the class scope. Class member functions, however, can still be type checked for return types and parameter types. Subclasses of dynamic classes are also dynamic, with one exception. Subclasses of the MovieClip class are not dynamic by default, even though the MovieClip class itself is dynamic. This implementation provides you with more control over subclasses of the MovieClip class, because you can choose to make your subclasses dynamic or not:
class A dynamic class C class D dynamic extends class B extends extends class E MovieClip {} extends A {} B {} A {} extends MovieClip{} // // // // // A B C D E is is is is is not dynamic dynamic dynamic not dynamic dynamic
For information on subclasses, see Chapter 7, Inheritance, on page 263.
About using encapsulation
In elegant object-oriented design, objects are seen as black boxes that contain, or encapsulate, functionality. A programmer should be able to interact with an object by knowing only its properties, methods, and events (its programming interface), without knowing the details of its implementation. This approach enables programmers to think at higher levels of abstraction and provides an organizing framework for building complex systems.
Encapsulation is why ActionScript 2.0 includes, for example, member access control, so that details of the implementation can be made private and invisible to code outside an object. The code outside the object is forced to interact with the objects programming interface rather than with the implementation details. This approach provides some important benefits; for example, it lets the creator of the object change the objects implementation without requiring any changes to code outside of the object, as long as the programming interface doesnt change. An example of encapsulation in Flash would be setting all your member and class variables to private and forcing people who implement your classes to access these variables using getter and setter methods. Performing encapsulation this way ensures that if you ever need to change the structure of the variables in the future, you would need only to change the behavior of the getter and setter functions rather than force every developer to change the way he or she accesses the classs variables. The following code shows how you could modify the Person class from earlier examples, set its instance members to private, and define getter and setter methods for the private instance members:

// bad code var counter:Number = 0; function myMethod() { var counter:Number; for (counter = 0; counter <= 4; counter++) { // statements; } }
This code declares the same variable inside an inner block.
Do not assign many variables to a single value in a statement, because it is difficult to read, as you can see in the following ActionScript code samples:
// bad form xPos = yPos = 15;
// bad form class User { private var m_username:String, m_password:String; }
Have a good reason for making public instance variables, or public static, class, or member variables. Make sure that these variables are explicitly public before you create them this way. Set most member variables to private unless there is a good reason to make them public. It is much better from a design standpoint to make member variables private and allow access only to those variables through a small group of getter and setter functions.

About naming class files

Class names must be identifiersthat is, the first character must be a letter, underscore (_), or dollar sign ($), and each subsequent character must be a letter, number, underscore, or dollar sign. As a preferred practice, try to always limit class names to letters. The class name must exactly match the name of the ActionScript file that contains it, including capitalization. In the following example, if you create a class called Rock, the ActionScript file that contains the class definition must be named Rock.as:
// In file Rock.as class Rock { // Rock class body }
You name and create a class definition in the following section. See the section Creating and packaging your class files on page 226 to create, name, and package the class files. For more information on naming class files, see Naming classes and objects on page 673.
Creating and packaging your class files
In this section, you create, name, and package your class files for this example (Example: Writing custom classes on page 223). The following sections show you how to write complete (yet simple) class files. For detailed information on packages, see About packages on page 189, A comparison of classes and packages on page 191, and Working with packages on page 191. When you create a class file, decide where you want to store the file. In the following steps, youll save the class file and the application FLA file that uses the class file in the same directory for simplicity. However, if you want to check syntax, you also need to tell Flash how it can find the file. Typically, when you create an application, you add the directory in which you store your application and class files to the Flash classpath. For information about classpaths, see About setting and modifying the classpath on page 202. Class files are also called ActionScript (AS) files. You create AS files in the Flash authoring tool or by using an external editor. For example, Macromedia Dreamweaver can create AS files.

Using on and onClipEvent with event handler methods
You can, in some cases, use different techniques to handle events without conflict. Using the on() and onClipEvent() methods doesnt conflict with using event handler methods that you define. For example, suppose you have a button in a SWF file; the button can have an on(press) handler that tells the SWF file to play, and the same button can have an onPress() method, for which you define a function that tells an object on the Stage to rotate. When you click the button, the SWF file plays and the object rotates. Depending on when and what kinds of events you want to invoke, you can use the on() and onClipEvent() methods, event handler methods, or both techniques of event handling. However, the scope of variables and objects in on() and onClipEvent() handlers is different than in event handler and event listeners. See Event handler scope on page 306. You can also use on() with movie clips to create movie clips that receive button events. For more information, see Creating movie clips with button states on page 305. For information on specifying events for on() and onClipEvent(), see Specifying events for on or onClipEvent methods on page 303.
To use an on handler and onPress event handler:
Create a new Flash document and save it as handlers.fla. Select the Rectangle Tool and draw a large square on the Stage. Select the Selection Tool, double-click the square on the Stage, and press F8 to launch the Convert to Symbol dialog box. Enter a symbol name for the box, set the type to Movie clip and click OK. Give the movie clip on the Stage an instance name of box_mc. Add the following ActionScript directly on the movie clip symbol on the Stage:
on (press) { trace("on (press) {.}"); }

4. 5. 6.

Add the following ActionScript to Frame 1 of the main Timeline:
box_mc.onPress = function() { trace("box_mc.onPress = function() {.};"); };
Select Control > Test Movie to test the Flash document. When you click the movie clip symbol on the Stage, the following output is sent to the Output panel: on (press) {.} box_mc.onPress = function() {.};
Specifying events for on or onClipEvent methods
To use an on() or onClipEvent() handler, attach it directly to an instance of a button or movie clip on the Stage and specify the event you want to handle for that instance. For a complete list of events supported by the on() and onClipEvent() event handlers, see on handler and onClipEvent handler in the ActionScript 2.0 Language Reference. For example, the following on() event handler executes whenever the user clicks the button to which the handler is attached:

if (my_txt._height > 160) { my_txt.autoSize = "none"; my_txt._height = 160; }
You must add some scrolling functionality, such as a scroll bar, to allow users to view the remainder of the text. Alternatively, you can roll the mouse pointer over the text; this method is often adequate while testing this code. For samples that demonstrate how to work with text fields using ActionScript, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download the Samples zip file and navigate to the ActionScript 2.0/TextFields folder to access these samples:
About loading text and variables into text fields
You can load text into a Flash document several ways, including (but certainly not limited to) using FlashVars, LoadVars, XML, or web services. Perhaps the simplest method of passing text into a Flash document is to use the FlashVars property, which passes short strings of text into a Flash document through the object and embed tags in the HTML code that you use to embed the SWF file in an HTML page. Another easy way to load text or variables into a Flash document is to use the LoadVars class, which can load large blocks of text or load a series of URL encoded variables from a text file. As you can see from the previous examples in this section, some ways of loading text into a SWF file are easier than others. However, if you syndicate data from external sites, you might not have a choice for the format of the data that you need to load. Each way of loading and/or sending data to and from a SWF file has its pros and cons. XML, web services, and Flash Remoting are the most versatile for loading external data, but they are also the most difficult to learn. For information on Flash Remoting, see www.adobe.com/ support/flashremoting. FlashVars and LoadVars are much simpler, as demonstrated in Using FlashVars to load and display text on page 354 and Using LoadVars to load and display text on page 355, but they can be much more limited in the types and formats of data that you can load. Also, you must follow security restrictions when you send and load data. For information on security, see Chapter 16, Understanding Security. For more information on loading external data, see Chapter 15, Working with External Data.
The following sections show you different ways to load text and variables into your documents:
Using FlashVars to load and display text on page 354 Using LoadVars to load and display text on page 355 Loading variables by using LoadVars on page 357 Loading and displaying text from an XML document on page 358
For samples that demonstrate how to work with text fields using ActionScript, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download the Samples zip file and navigate to the ActionScript 2.0/LoadText folder to access these samples:

new mx.transitions.Tween(ball_mc, "_x", mx.transitions.easing.Elastic.easeOut, 0, 300, 3, true);
This ActionScript snippet creates a new instance of the Tween class, which animates the ball_mc movie clip on the Stage along the x-axis (left to right). The movie clip animates from 0 pixels to 300 pixels in three seconds, and the ActionScript applies an elastic easing method. This means that the ball extends past 300 pixels on the x-axis before using a fluid motion effect to animating back. For a sample source file that adds scripted animation using the Tween and TransitionManager classes, tweenProgress.fla, see the Flash Samples page at www.adobe.com/go/learn_fl_samples. Download the Samples zip file and navigate to the ActionScript2.0/Tween ProgressBar folder to access this sample.

Using the Tween class

If you use the Tween class in more than one place in your Flash document, you might opt to use an import statement. This lets you import the Tween class and easing methods rather than give the fully qualified class names each time you use them, as the following procedure shows.
To import and use the Tween class:
Create a new document and call it easeTween.fla. Create a movie clip on the Stage. Select the movie clip instance and type ball_mc into the Instance Name text box in the Property inspector. Select Frame 1 of the Timeline and add the following code in the Actions panel:
import mx.transitions.Tween; import mx.transitions.easing.*; new Tween(ball_mc, "_x", Elastic.easeOut, Stage.width, 0, 3, true);
This code example uses two import statements. The first statement imports the mx.transitions.Tween class only, and the second import statement uses the wildcard (*) shortcut to import each of the six easing classes by using a single line of code. The second statement imports an entire package of classes.
Select Control > Test Movie to see the animation.
Flash documentation defines package as directories that contain one or more class files and that reside in a designated classpath directory. In this case, the package resides in the C:\Program Files\Adobe\Adobe Flash CS3\language\First Run\Classes\mx\transitions\easing folder (Windows), or HD:Applications:Adobe Flash CS3:First Run:Classes:mx:transitions:easing (Macintosh). You might agree that importing an entire package is much better than having to import the six classes separately. Instead of referring to the mx.transitions.Tween class, your ActionScript directly refers to the Tween class. Likewise, instead of using the fully qualified class name for the easing classes, mx.transitions.easing.Elastic.easeOut for example, you can type Elastic.easeOut in your ActionScript code. For more information, see Working with filter packages on page 458. Using similar code, you set the _alpha property to fade instances in and out, instead of the _x property, as the next procedure shows.

Applying filters to object instances and BitmapData instances
The use of filters depends on the object instance to which you apply the filter. Use the following guidelines when you apply a filter to an object or BitmapData instance:
To apply filters to movie clips, text fields, and buttons at runtime, use the filters property. Setting the filters property of an object does not modify the object and can be undone by clearing the filters property. To apply filters to BitmapData instances, use the BitmapData.applyFilter() method. Calling applyFilter() on a BitmapData object takes the source BitmapData object and the filter object and generates a filtered image.
You can also apply filter effects to images and video during authoring using the Filters tab in the Property inspector.
About error handling, performance, and filters
One problem that arises if you use too many filters in an application is the potential to use large amounts of memory and cause Flash Player performance to suffer. Because a movie clip with filters attached has two bitmaps that are both 32-bit, these bitmaps can cause your application to use a significant amount of memory if you use many bitmaps. You might see an out-of-memory error generated by the computers operating system. On a modern computer, out-of-memory errors should be rare, unless you are using filter effects extensively in an application (for example, you have thousands of bitmaps on the Stage). However, if you do encounter an out-of-memory error, the following occurs:
The filters array is ignored. The movie clip is drawn using the regular vector renderer. No bitmaps are cached for the movie clip.
After you see an out-of-memory error, a movie clip never attempts to use a filters array or a bitmap cache. Another factor that affects player performance is the value that you use for the quality parameter for each filter that you apply. Higher values require more CPU and memory for the effect to render, whereas setting the quality parameter to a lower value requires less computer resources. Therefore, you should avoid using an excessive number of filters, and use a lower quality setting when possible.

C AU TI ON TI P N OTE

If a 100 pixel by 100 pixel object is zoomed in once, it uses four times the memory since the contents dimensions are now 200 pixels by 200 pixels. If you zoom another two times, the shape is drawn as an 800 pixel by 800 pixel object which uses 64 times the memory as the original 100 pixel by 100 pixel object. Whenever you use filters in a SWF file, it is always a good idea to disable the zoom menu options from the SWF files context menu.

lighten multiply normal

Used to specify that the pixel values of the blend image override those of the base image. Commonly used to create shading effects. Commonly used to create highlights and lens flares.

overlay screen

subtract Commonly used to create an animated darkening dissolve effect between two images.

Applying blending modes

The following procedure loads a dynamic image and lets you apply different blend modes to the image by selecting a blending mode from a combo box on the Stage.
To apply different blending modes to an image:
Create a new Flash document and save it as blendmodes.fla. Drag a ComboBox component instance onto the Stage and give it an instance name of blendMode_cb. Add the following ActionScript to Frame 1 of the Timeline:
var blendMode_dp:Array = new Array(); blendMode_dp.push({data:"add", label:"add"}); blendMode_dp.push({data:"alpha", label:"alpha"}); blendMode_dp.push({data:"darken", label:"darken"}); blendMode_dp.push({data:"difference", label:"difference"}); blendMode_dp.push({data:"erase", label:"erase"}); blendMode_dp.push({data:"hardlight", label:"hardlight"}); blendMode_dp.push({data:"invert", label:"invert"}); blendMode_dp.push({data:"layer", label:"layer"}); blendMode_dp.push({data:"lighten", label:"lighten"}); blendMode_dp.push({data:"multiply", label:"multiply"}); blendMode_dp.push({data:"normal", label:"normal"}); blendMode_dp.push({data:"overlay", label:"overlay"}); blendMode_dp.push({data:"screen", label:"screen"}); blendMode_dp.push({data:"subtract", label:"subtract"}); blendMode_cb.dataProvider = blendMode_dp; var mclListener:Object = new Object(); mclListener.onLoadInit = function(target_mc:MovieClip) { var blendModeClip:MovieClip = target_mc.createEmptyMovieClip("blendModeType_mc", 20); with (blendModeClip) { beginFill(0x999999); moveTo(0, 0); lineTo(target_mc._width / 2, 0); lineTo(target_mc._width / 2, target_mc._height); lineTo(0, target_mc._height); lineTo(0, 0); endFill(); } target_mc._x = (Stage.width - target_mc._width) / 2; target_mc._y = (Stage.height - target_mc._height) / 2; blendModeClip.blendMode = blendMode_cb.value; };
this.createEmptyMovieClip("img_mc", 10); var img_mcl:MovieClipLoader = new MovieClipLoader(); img_mcl.addListener(mclListener); img_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", img_mc); function cbListener(eventObj:Object):Void { img_mc.blendModeType_mc.blendMode = eventObj.target.value; } blendMode_cb.addEventListener("change", cbListener);

curveTo(0, boxHeight, 0, boxHeight - cornerRadius); lineTo(0, boxHeight - cornerRadius); lineTo(0, cornerRadius); curveTo(0, 0, cornerRadius, 0); lineTo(cornerRadius, 0); endFill(); } } 3.
Save the Flash document and select Control > Test Movie to test the document. A green rectangle appears on the Stage that is 240 pixels wide and 180 pixels high with 20-pixel rounded corners. You can create multiple instances of rounded rectangles by creating new movie clips using MovieClip.createEmptyMovieClip() and calling your custom drawRoundedRectangle() function.
You can create a perfect circle using the Drawing API, as the following procedure shows.

To create a circle:

Create a new Flash document and save as circle2.fla. Add the following ActionScript code to Frame 1 of the Timeline:
this.createEmptyMovieClip("circle_mc", 10); circle_mc._x = 100; circle_mc._y = 100; drawCircle(circle_mc, 100, 0x99FF00, 100); function drawCircle(target_mc:MovieClip, radius:Number, fillColor:Number, fillAlpha:Number):Void { var x:Number = radius; var y:Number = radius; with (target_mc) { beginFill(fillColor, fillAlpha); moveTo(x + radius, y); curveTo(radius + x, Math.tan(Math.PI / 8) * radius + y, Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y); curveTo(Math.tan(Math.PI / 8) * radius + x, radius + y, x, radius + y); curveTo(-Math.tan(Math.PI / 8) * radius + x, radius+ y, Math.sin(Math.PI / 4) * radius + x, Math.sin(Math.PI / 4) * radius + y); curveTo(-radius + x, Math.tan(Math.PI / 8) * radius + y, -radius + x, y); curveTo(-radius + x, -Math.tan(Math.PI / 8) * radius + y, Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y);
curveTo(-Math.tan(Math.PI / 8) * radius + x, -radius + y, x, -radius + y); curveTo(Math.tan(Math.PI / 8) * radius + x, -radius + y, Math.sin(Math.PI / 4) * radius + x, -Math.sin(Math.PI / 4) * radius + y); curveTo(radius + x, -Math.tan(Math.PI / 8) * radius + y, radius + x, y); endFill(); } } 3.

highScore1=54000&playerName1=RGoulet&highScore2=53455&playerName2= WNewton&highScore3=42885&playerName3=TJones
You might need to URL-encode certain characters, such as the plus (+) sign or ampersand (&) characters. For more information, see www.adobe.com/go/tn_14143.
For more information, see the following topic: Using the LoadVars class on page 596. Also, see loadVariables function, getURL function, loadMovie function, and the LoadVars entry in the ActionScript 2.0 Language Reference.

Using the LoadVars class

If you are publishing to Flash Player 6 or later and want more flexibility than loadVariables() offers, you can use the LoadVars class instead to transfer variables between a SWF file and a server. The LoadVars class was introduced in Flash Player 6 to provide a cleaner, more objectoriented interface for the common task of exchanging CGI data with a web server. Advantages of the LoadVars class include the following:
You dont need to create container movie clips for holding data or clutter existing movie clips with variables specific to client/server communication. The class interface is similar to that of the XML object, which provides some consistency in ActionScript. It uses the methods load(), send(), and sendAndLoad() to initiate communication with a server. The main difference between the LoadVars and XML classes is that the LoadVars data is a property of the LoadVars object rather than of an XML Document Object Model (DOM) tree stored in the XML object. The class interface is more straightforwardwith methods named load, send, sendAndLoadthan the older loadVariables interface. You can get additional information about the communication, using the getBytesLoaded and getBytesTotal methods. You can get progress information about the download of your data (although you cant access the data until it is fully downloaded). The callback interface is through ActionScript methods (onLoad) instead of the obsolete, deprecated onClipEvent (data) approach required for loadVariables. There are error notifications. You can add custom HTTP request headers.
You must create a LoadVars object to call its methods. This object is a container to hold the loaded data. The following procedure shows how to use ColdFusion and the LoadVars class to send an email from a SWF file.

NO TE 596

You must have ColdFusion installed on your web server for this example.
To load data with the LoadVars object:
Create a CFM file in Macromedia Dreamweaver or in your favorite text editor. Add the following text to the file:
<cfif StructKeyExists(Form, "emailTo")> <cfmail to="#Form.emailTo#" from="#Form.emailFrom#" subject="#Form.emailSubject#">#Form.emailBody#</cfmail> &result=true <cfelse> &result=false </cfif>

For more information, see the XMLSocket entry in the ActionScript 2.0 Language Reference. For more information on local file security, see About local file security and Flash Player on page 633.
Sending messages to and from Flash Player
To send messages from a SWF file to its host environment (for example, a web browser, a Macromedia Director movie, or the stand-alone Flash Player), you can use the fscommand() function.This function lets you extend your SWF file by using the capabilities of the host. For example, you could pass an fscommand() function to a JavaScript function in an HTML page that opens a new browser window with specific properties. To control a SWF file in Flash Player from web browser scripting languages such as JavaScript, VBScript, and Microsoft JScript, you can use Flash Player methodsfunctions that send messages from a host environment to the SWF file. For example, you could have a link in an HTML page that sends your SWF file to a specific frame. For more information, see the following topics:
Using the fscommand() function on page 618 About using JavaScript to control Flash applications on page 621
About Flash Player methods on page 621
Using the fscommand() function
N OTE quit fullscreen 618 N OTE NOT E
The External API is a replacement for fscommand() in Flash 8 and later for interoperating with a HTML page or a container application. The External API offers more robust functionality than fscommand() in this situation. For more information, see About the External API on page 621.
You use the fscommand() function to send a message to whichever program is hosting Flash Player, such as a web browser.
Using the fscommand() to call JavaScript does not work on the Safari or Internet Explorer browsers for the Macintosh.
The fscommand() function has two parameters: command and arguments. To send a message to the stand-alone version of Flash Player, you must use predefined commands and arguments. For example, the following event handler sets the stand-alone player to scale the SWF file to the full monitor screen size when the button is released:
my_btn.onRelease = function() { fscommand("fullscreen", true); };
The following table shows the values you can specify for the command and arguments parameters of fscommand() to control the playback and appearance of a SWF file playing in the stand-alone player, including projectors.
A projector is a SWF file saved in a format that can run as a stand-alone applicationthat is, embedding Flash Player with your content in an executable file.

Command

Arguments

true or false

Purpose
Closes the projector. Specifying true sets Flash Player to full-screen mode. Specifying false returns the player to normal menu view. Specifying false sets the player so that the SWF file is always drawn at its original size and never scaled. Specifying true forces the SWF file to scale to 100% of the player.

 

Technical specifications

Full description

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. Wersquo;ve designed it so that itrsquo;s easy to annotate as you progress. Learning ActionScript 2.0 for Macromedia Flash 8shows you how to write proper ActionScript syntax to create useful and interactive Flash applications. This book includes examples of object-oriented programming, and teaches you how to write custom classes for your Flash applications.Learning ActionScript 2.0 for Macromedia Flash 8also includes numerous hands-on examples on how to apply expressive and interactive features to your files using ActionScript code, such as file upload, filter effects, scripted animation, and anti-alias text using the FlashType font rendering engine. InLearning Actionscript 2.0 for Macromedia Flash 8,learn how to: bull;nbsp;nbsp;nbsp; Write proper ActionScript syntax using the fundamentals of the ActionScript language. bull;nbsp;nbsp;nbsp; Use object-oriented programming techniques to build Flash applications. bull;nbsp;nbsp;nbsp; Use ActionScript classes to add interactivity and expressive features to your Flash applications. bull;nbsp;nbsp;nbsp; Use best practices and coding conventions to optimize, structure, and write consistent ActionScript.

 

Tags

9-5-2001 Mypal A696 CFD-C1000 CLP260 DS-10BH Monitor FW-C85 CS-21K40ML K7S5a PRO TL502 V-touch Adventure DX Master 1000 VGN-AR21SR 50PG7000 MS07AH Nq0 Controller Monitors MD230X3 BDS-1860 BC785D EX-Z25 Aspire ELD DR-BT25NX 5I-2003 PEG-TG50 SPC1030NC Kodak Z981 6-30 MM SPF-71ES RW52dass WI-FI CTK-2000 Fostex RD-8 BH-602 Coolpix S10 Moulinex AT7 GM-V42c-gm-v42 DV-RW60 Dvdr70-051 Powerlook III CCD-TRV87 35-50 IWC 6105 ETX-60AT 5xi MV600 AF400T AK77333 KRC-191 PSR 12 MAX-WS730 1220S DVP-SR200P 732N Plus Cascade 7944 PPD01 9488 C FE-280 Review LQ-550 2156 CWH FT-8900R Laver 5023 MAX-DN87 Matrix 12 Montana 2002 Probe DE1102 9636T 10IN1 Spirit FX8 Optio 750Z T-405X TXP42S20ES KH 2355 Lenovo B460 Huskystar 224 SRE 702 Seiko 8F56 NV-SJ4130PN Maxxum 7000 Control Force Touch Hd1 UX-F24CL AL1516W Esga21 HT-S5200 KDC-4070RA Defense NN-A574sbbpq LP425Z Binatone B430 Mouse Brandt A210 GK1000 X-press 1000 SGH-T959 DCR-TRV355E Printer

 

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