Archive for September, 2007

Assigning a class (Florida web design) to a movie clip symbol

Sunday, September 30th, 2007

Assigning a class to a movie clip symbol Using ActionScript 2.0, you can create your own class that extends the behavior of the built-in MovieClip class, and then assign that class to a movie clip library symbol using the Linkage Properties dialog box. Whenever you create an instance of the movie clip to which the class is assigned, it assumes the properties and behaviors defined by the class assigned to it. (For more information about ActionScript 2.0, see Chapter 9, Creating Classes with ActionScript 2.0, on page 155.) In a subclass of the MovieClip class, you can provide method definitions for the built-in MovieClip methods and event handlers, like onEnterFrame and onRelease. In the following procedure, you ll create a class called MoveRight that extends the MovieClip class; MoveRight defines an onPress handler that moves the clip 20 pixels to the right whenever the user clicks the movie clip. In the second procedure, you ll create a movie clip symbol in a new Flash (FLA) document and assign the MoveRight class to that symbol. To create a movie clip subclass: 1 Create a new directory called BallTest. 2 Create a new ActionScript file by doing one of the following: (Flash MX Professional 2004) Select File > New, and select ActionScript file from the list of document types. (Flash MX 2004) Create a text file in your preferred text editor. 3 Enter the following code in your script: // MoveRight class — moves clip to the right 5 pixels every frame class MoveRight extends MovieClip { function onPress() { this._x += 20; } } 4 Save the document as MoveRight.as in the BallTest directory. To assign the class to a movie clip symbol: 1 In Flash, select File > New, select Flash Document from the list of file types, and click OK. 2 Using the Oval tool, draw a circle on the Stage. 3 Select the circle, then select Modify > Convert to Symbol. In the Convert to Symbol dialog box, select Movie Clip as the symbol s behavior and enter Ball in the Name text box. 4 Open the Library panel (Window > Library) and select the Ball symbol. 5 Select Linkage from the Library panel s options menu to open the Linkage Properties dialog box. 6 In the Linkage Properties dialog box, select the Export for ActionScript option, and type MoveRight in the AS 2.0 Class text box. Click OK. 7 Save the file as Ball.fla in the BallTest directory (the same directory that contains the MoveRight.as file). 8 Test the movie (Control > Test Movie). Each time you click the ball movie clip, it moves 20 pixels to the right. Assigning a class to a movie clip symbol 133
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Ipower web hosting - Using movie clips as masks You can use

Sunday, September 30th, 2007

Using movie clips as masks You can use a movie clip as a mask to create a hole through which the contents of another movie clip are visible. The mask movie clip plays all the frames in its Timeline, just like a regular movie clip. You can make the mask movie clip draggable, animate it along a motion guide, use separate shapes within a single mask, or resize a mask dynamically. You can also use ActionScript to turn a mask on and off. You cannot use a mask to mask another mask. You cannot set the _alpha property of a mask movie clip. Only fills are used in a movie clip that is used as a mask; strokes are ignored. To create a mask: 1 On the Stage, select a movie clip to be masked. 2 In the Property inspector, enter an instance name for the movie clip, such as image. 3 Create a movie clip to be a mask. Give it an instance name in the Property inspector, such as mask. The masked movie clip will be revealed under all opaque (nontransparent) areas of the movie clip acting as the mask. 4 Select Frame 1 in the Timeline. 5 Open the Actions panel (Window > Development Panels > Actions) if it isn t already open. 6 In the Actions panel, enter the following code: image.setMask(mask); For detailed information, see MovieClip.setMask() on page 533. About masking device fonts You can use a movie clip to mask text that is set in a device font. In order for a movie clip mask on a device font to work properly, the user must have Flash Player 6 release 40 or later. When you use a movie clip to mask text set in a device font, the rectangular bounding box of the mask is used as the masking shape. That is, if you create a nonrectangular movie clip mask for device font text in the Flash authoring environment, the mask that appears in the SWF file will be the shape of the rectangular bounding box of the mask, not the shape of the mask itself. You can mask device fonts only by using a movie clip as a mask. You cannot mask device fonts by using a mask layer on the Stage. Handling movie clip events Movie clips can respond to user events, such as mouse clicks and keypresses, as well as system-level events, such as the initial loading of a movie clip on the Stage. ActionScript provides two ways to handle movie clip events: through event handler methods and through onClipEvent() and on() event handlers. For more information, see Chapter 4, Handling Events, on page 83. 132 Chapter 7: Working with Movie Clips
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Drawing shapes (Web hosting billing) with ActionScript You can use methods

Saturday, September 29th, 2007

Drawing shapes with ActionScript You can use methods of the MovieClip class to draw lines and fills on the Stage. This allows you to create drawing tools for users and to draw shapes in the movie in response to events. The drawing methods are beginFill(), beginGradientFill(), clear(), curveTo(), endFill(), lineTo(), lineStyle(), and moveTo(). You can use the drawing methods with any movie clip. However, if you use the drawing methods with a movie clip that was created in authoring mode, the drawing methods execute before the clip is drawn. In other words, content that is created in authoring mode is drawn on top of content drawn with the drawing methods. You can use movie clips with drawing methods as masks; however, as with all movie clip masks, strokes are ignored. To draw a shape: 1 Use createEmptyMovieClip() to create an empty movie clip on the Stage. The new movie clip is a child of an existing movie clip or of the main Timeline, as in the following example: _root.createEmptyMovieClip (”triangle”, 1); 2 Use the empty movie clip to call drawing methods. The following example draws a triangle with 5-point magenta lines and no fill: with (_root.triangle) { lineStyle (5, 0xff00ff, 100); moveTo (200, 200); lineTo (300, 300); lineTo (100, 300); lineTo (200, 200); } For detailed information on these methods, see their entries in Chapter 12, ActionScript Dictionary, on page 205. Drawing shapes with ActionScript 131
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Determining the next (Web hosting compare) highest available depth To determine

Saturday, September 29th, 2007

Determining the next highest available depth To determine the next highest available depth within a movie clip, use MovieClip.getNextHighestDepth(). The integer value returned by this method indicates the next available depth that will render in front of all other objects in the movie clip. The following code creates a new movie clip, with a depth value of 10, on the Timeline of the movie clip named menus_mc. It then determines the next highest available depth in that same movie clip, and creates a new movie clip at that depth. menus_mc.attachMovie(”menuClip”,”file_menu”, 10); var nextDepth = menus_mc.getNextHighestDepth(); menus_mc.attachMovie(”menuClip”, “edit_menu”, nextDepth); In this case, the variable named nextDepth contains the value 11, because that s the next highest available depth for the movie clip menus_mc. To obtain the current highest occupied depth, subtract 1 from the value returned by getNextHighestDepth(), as shown in the next section (see Determining the instance at a particular depth on page 130). Determining the instance at a particular depth To determine the instance at particular depth, use MovieClip.getInstanceAtDepth(). This method returns a reference to the instance at the specified depth. The following code combines getNextHighestDepth() and getInstanceAtDepth() to determine the movie clip at the (current) highest occupied depth on the root Timeline. var highestOccupiedDepth = _root.getNextHighestDepth() - 1; var instanceAtHighestDepth = _root.getInstanceAtDepth(highestOccupiedDepth); For more information, see MovieClip.getInstanceAtDepth() on page 503. Determining the depth of an instance To determine the depth of a movie clip instance, use MovieClip.getDepth(). The following code iterates over all the movie clips on a SWF file s main Timeline and displays each clip s instance name and depth value in the Output panel. for(each in _root) { var obj = _root[each]; if(obj instanceof MovieClip) { var objDepth = obj.getDepth(); trace(obj._name + “:” + objDepth) } } For more information, see MovieClip.getDepth() on page 503. Swapping movie clip depths To swap the depths of two movie clips on the same Timeline, use MovieClip.swapDepths(). For more information, see MovieClip.swapDepths() on page 535. 130 Chapter 7: Working with Movie Clips
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

To populate a movie clip with parameters by (Web server extensions)

Saturday, September 29th, 2007

To populate a movie clip with parameters by using attachMovie(): 1 In a new Flash document, create a movie clip symbol by selecting Insert > New Symbol. Type dynamic in the Symbol Name text box and select the Movie Clip behavior. 2 Inside the symbol, create a dynamic text field on the Stage with an instance name of name_txt. 3 Select the first frame of the movie clip s Timeline and open the Actions panel (Window > Development Panels > Actions). 4 Create a new variable called name, and then assign its value to the text property of name_txt, as shown here: var name:String; name_txt.text = name; 5 Select Edit > Edit Document to return to the main Timeline. 6 Select the movie clip symbol in the library and select Linkage Properties from the Library panel s options menu. The Linkage Properties dialog box appears. 7 Select the Export for ActionScript option, and click OK. 8 Select the first frame of the main Timeline and add the following code to the Actions panel s Script pane: _root.attachMovie(”dynamic”, “newClipName”, 10, {name:”Erick”}); 9 Test the movie (Control > Test Movie). The name you specified in the attachMovie() call appears inside the new movie clip s text field. Managing movie clip depths Every movie clip has its own z-order space that determines how objects overlap within its parent SWF file or movie clip. Every movie clip has an associated depth value, which determines if it will render in front of or behind other movie clips in the same movie clip Timeline. When you create a movie clip at runtime using MovieClip.attachMovie(), MovieClip.duplicateMovieClip(), or MovieClip.createEmptyMovieClip(), you always specify a depth for the new clip as a method parameter. For example, the following code attaches a new movie clip to the Timeline of a movie clip named container_mc with a depth value of 10. container_mc.attachMovie(”symbolID”, “clip_1″, 10); This creates a new movie clip with a depth of 10 within the z-order space of container_mc. For example, the following code attaches two new movie clips to container_mc. The first clip, named clip_1, will render behind clip_2, because it was assigned a lower depth value. container_mc.attachMovie(”symbolID”, “clip_1″, 10); container_mc.attachMovie(”symbolID”, “clip_2″, 15); Depth values for movie clips can range from -16384 to 1048575. The MovieClip class provides several methods for managing movie clip depths: see MovieClip.getNextHighestDepth() on page 504, MovieClip.getInstanceAtDepth() on page 503, MovieClip.getDepth() on page 503, and MovieClip.swapDepths() on page 535. Managing movie clip depths 129
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Fedora web server - To attach a movie clip to another movie

Friday, September 28th, 2007

To attach a movie clip to another movie clip: 1 Assign a linkage identifier to a movie clip library symbol, as described above. 2 With the Actions panel open (Window > Development Panels > Actions), select a frame inthe Timeline. 3 In the Actions panel s Script pane, type the name of the movie clip or level to which you wantto attach the new movie clip. For example, to attach the movie clip to the root Timeline, type _root. 4 In the Actions toolbox (at the left of the Actions panel), click the Built-in Classes category, the Movie category, and the MovieClip category, and double-click attachMovie(). 5 Using the code hints that appear as a guide, enter values for the following parameters: For idName, specify the identifier you entered in the Linkage Properties dialog box. For newName, enter an instance name for the attached clip so that you will be able to target it. For depth, enter the level at which the duplicate movie clip will be attached to the movie clip. Each attached movie clip has its own stacking order, with level 0 as the level of the originating movie clip. Attached movie clips are always on top of the original movie clip. Here is an example: myMovieClip.attachMovie(”calif”, “california”, 10); For more information, see MovieClip.attachMovie() on page 488. Adding parameters to dynamically created movie clips When you create or duplicate a movie clip dynamically using MovieClip.attachMovie() and MovieClip.duplicateMovie(), you can populate the movie clip with parameters from another object. The initObject parameter of attachMovie() and duplicateMovie() allows dynamically created movie clips to receive clip parameters. The initObject parameter is optional. For more information, see MovieClip.attachMovie() on page 488 and MovieClip.duplicateMovieClip() on page 498. To populate a dynamically created movie clip with parameters from a specified object, do one of the following: Use the following syntax with attachMovie(): myMovieClip.attachMovie(idName, newName, depth [, initObject]) Use the following syntax with duplicateMovie(): myMovieClip.duplicateMovie(idName, newName, depth [, initObject]) The initObject parameter specifies the name of the object whose parameters you want to use to populate the dynamically created movie clip. 128 Chapter 7: Working with Movie Clips
From our experience, we can recommend PHP5 Web Hosting services, if you need affordable webhost to host and run your web application.

Attaching a movie clip symbol to the Stage (Affordable web design)

Friday, September 28th, 2007

Attaching a movie clip symbol to the Stage The last way to create movie clip instances at runtime is to use attachMovie(). The attachMovie() method attaches an instance of a movie clip symbol in the SWF file s library to the Stage. The new clip becomes a child clip of the clip that attached it. To use ActionScript to attach a movie clip symbol from the library, you must export the symbol for ActionScript and assign it a unique linkage identifier. To do this, you use the Linkage Properties dialog box. By default, all movie clips that are exported for use with ActionScript load before the first frame of the SWF file that contains them. This can create a delay before the first frame plays. When you assign a linkage identifier to an element, you can also specify whether this content should be added before the first frame. If it isn t added in the first frame, you must include an instance of it in some other frame of the SWF file; if you don t, the element will not be exported to the SWF file. To assign a linkage identifier to movie clip: 1 Select Window > Library to open the Library panel. 2 Select a movie clip in the Library panel. 3 In the Library panel, select Linkage from the Library panel options menu. The Linkage Properties dialog box appears. 4 For Linkage, select Export for ActionScript. 5 For Identifier, enter an ID for the movie clip. By default, the identifier is the same as the symbol name. 6 You can optionally assign an ActionScript 2.0 class to the movie clip symbol. (See Assigning a class to a movie clip symbol on page 133.) 7 If you don t want the movie clip to load before the first frame, deselect the Export in First Frame option. If you deselect this option, place an instance of the movie clip on the frame of the Timeline where you d like it to be available. For example, if the script you re writing doesn t reference the movie clip until Frame 10, then place an instance of the symbol at or before that frame in the Timeline. 8 Click OK. After you ve assigned a linkage identifier to a movie clip, you can attach an instance of the symbol to the Stage at runtime by using attachMovie(). Creating movie clips at runtime 127
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Creating movie clips at runtime Not only can (Web hosting account)

Thursday, September 27th, 2007

Creating movie clips at runtime Not only can you create movie clip instances in the Flash authoring environment, but you can also create them at runtime. ActionScript provides three ways to create new movie clips at runtime: By creating a new, empty movie clip instance By duplicating an existing movie clip instance By attaching an instance of a movie clip library symbol to the Stage Each movie clip instance you create at runtime must have an instance name and a depth (stacking, or z-order) value. The depth you specify determines how the new clip overlaps with other clips on the same Timeline. (See Managing movie clip depths on page 129.) Creating an empty movie clip To create an empty movie clip on the Stage, use the createEmptyMovieClip() method of the MovieClip class. This method creates a movie clip as a child of the clip that calls the method. The registration point for a newly created empty movie clip is the upper left corner. For example, the following code creates a new child movie clip named new_mc at a depth of 10 in the movie clip named parent_mc. parent_mc.createEmptyMovieClip(”new_mc”, 10); The following code creates a new movie clip named canvas_mc on the root Timeline of the SWF file in which the script is run, and then invokes loadMovie() to load an external JPEG file into itself. _root.createEmptyMovieClip(”canvas_mc”, 10); canvas_mc.loadMovie(”flowers.jpg”); For more information, see MovieClip.createEmptyMovieClip() on page 494. Duplicating or removing a movie clip To duplicate or remove movie clip instances, use the duplicateMovieClip() or removeMovieClip() global functions, or the MovieClip class methods of the same name. The duplicateMovieClip() method creates a new instance of an existing movie clip instance, assigns it a new instance name, and gives it a depth, or z-order. A duplicated movie clip always starts at Frame 1 even if the original movie clip was on another frame when duplicated, and is always in front of all previously defined movie clips placed on the Timeline. To delete a movie clip you created with duplicateMovieClip(), use removeMovieClip(). Duplicated movie clips are also removed if the parent movie clip is deleted. For more information, see duplicateMovieClip() on page 373 and removeMovieClip() on page 605. 126 Chapter 7: Working with Movie Clips
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Changing movie clip position and appearance To change (Free web hosting services)

Thursday, September 27th, 2007

Changing movie clip position and appearance To change the properties of a movie clip as it plays, write a statement that assigns a value to a property or use the setProperty() function. For example, the following code sets the rotation of instance mc to 45: mc._rotation = 45; This is equivalent to the following code, which uses the setProperty() function: setProperty(”mc”, _rotation, 45); Some properties, called read-only properties, have values that you can read but not set. (These properties are specified as read-only in their ActionScript Dictionary entries.) The following are read-only properties: _currentframe, _droptarget, _framesloaded, _parent, _target, _totalframes, _url, _xmouse, and _ymouse. You can write statements to set any property that is not read-only. The following statement sets the _alpha property of the movie clip instance wheel, which is a child of the car instance: car.wheel._alpha = 50; In addition, you can write statements that get the value of a movie clip property. For example, the following statement gets the value of the _xmouse property on the current level s Timeline and sets the _x property of the customCursor instance to that value: onClipEvent(enterFrame){ customCursor._x = _root._xmouse; } This is equivalent to the following code, which uses the getProperty() function: onClipEvent(enterFrame){ customCursor._x = getProperty(_root, _xmouse); } The _x, _y, _rotation, _xscale, _yscale, _height, _width, _alpha, and _visible properties are affected by transformations on the movie clip s parent, and transform the movie clip and any of the clip s children. The _focusrect, _highquality, _quality, and _soundbuftime properties are global; they belong only to the level 0 main Timeline. All other properties belong to each movie clip or loaded level. For a list of movie clip properties, see Property summary for the MovieClip class on page 484. Dragging movie clips You can use the global startDrag() function or the MovieClip.startDrag() method to make a movie clip draggable. For example, you can make a draggable movie clip for games, drag-anddrop functions, customizable interfaces, scroll bars, and sliders. A movie clip remains draggable until explicitly stopped by stopDrag(), or until another movie clip is targeted with startDrag(). Only one movie clip can be dragged at a time. To create more complicated drag-and-drop behavior, you can evaluate the _droptarget property of the movie clip being dragged. For example, you might examine the _droptarget property to see if the movie clip was dragged to a specific movie clip (such as a trash can movie clip) and then trigger another action. For detailed information, see startDrag() on page 645 or MovieClip.startDrag() on page 534. Dragging movie clips 125
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

Web site design and hosting - When contents.swf loads into the movie clip in

Wednesday, September 26th, 2007

When contents.swf loads into the movie clip in container.swf, the value of userName that s attached to the root Timeline of the hosting SWF file (container.swf) would be set to “Mary”. This could cause code in container.swf (as well as contents.swf) to malfunction. To force _root to always evaluate to the Timeline of the loaded SWF file, rather than the actual root Timeline, use the _lockroot property. This property can be set either by the loading SWF file or the SWF file being loaded. When _lockroot is set to true on a movie clip instance, that movie clip will act as _root for any SWF file loaded into it. When _lockroot is set to true within a SWF file, that SWF file will act as its own root, no matter what other SWF file loads it. Any movie clip, and any number of movie clips, can set _lockroot to true. By default, this property is false. For example, the author of container.swf could attach the following code to the target_mc movie clip: // Attached to target_mc movie clip: onClipEvent (load) { this._lockroot = true; } This would ensure that references to _root in contents.swf or any SWF file loaded into target_mc will refer to its own Timeline, not the actual root Timeline of container.swf. Equivalently, the author of contents.swf could add the following code to its main Timeline. // Within contents.swf: this._lockroot = true; This would ensure that no matter where contents.swf is loaded, any reference it makes to _root will refer to its own main Timeline, not that of the hosting SWF file. For more information, see MovieClip._lockroot on page 515. Loading JPEG files into movie clips You can use the loadMovie() function, or the MovieClip method of the same name, to load JPEG image files into a movie clip instance. You can also use the loadMovieNum() function to load a JPEG file into a level. When you load an image into a movie clip, the upper left corner of the image is placed at the registration point of the movie clip. Because this registration point is often the center of the movie clip, the loaded image may not appear centered. Also, when you load an image to a root Timeline, the upper left corner of the image is placed on the upper left corner of the Stage. The loaded image inherits rotation and scaling from the movie clip, but the original content of the movie clip is removed. For more information, see Loading external SWF and JPEG files on page 194, loadMovie() on page 420, MovieClip.loadMovie() on page 512, and loadMovieNum() on page 421. 124 Chapter 7: Working with Movie Clips
In case you need quality webspace to host and run your web applications, try our personal web hosting services.