Creating New Movie Clips

I l @ ve RuBoard

So far, all the drawing we have done has been on the background of the stage. Everything will appear behind movie clips. All this drawing is also static; it can't be moved or altered , just drawn over.

You don't have to draw onto the stage, however. You can draw into any movie clip. Just use the same drawing commands but with references to the movie clip. For instance:

 myMoveClip.lineStyle(0,0x000000,100); myMoveClip.moveTo(100,100); myMovieClip.lineTo(200,200); 

You can also use terms such as _root , _parent , and this to define where the line gets drawn. You need to set the lineStyle in that movie clip first. You can also place your code on a movie clip, or in a frame inside that movie clip. The this prefix or just using the commands by themselves then refers to that movie clip.

Flash MX also lets you create blank movie clips to store your drawings. You can do this with the createEmptyMovieClip command. It takes two parameters: the name of the new movie clip and its level. Both should be unique. For instance, to create an empty movie clip and then draw a line in it, you can do something like this:

 this.createEmptyMovieClip("myMovieClip",1); myMoveClip.lineStyle(0,0x000000,100); myMoveClip.moveTo(100,100); myMovieClip.lineTo(200,200); 

You can now move that movie clip around by changing its _x and _y properties. You can rotate it, scale it, change its alpha, and do anything that you would normally do with a movie clip. The drawing inside it follows along as if it were created while you were authoring the movie in Flash.

graphics/bulb.gif

The createEmptyMovieClip command can be used for much more than just drawing. You can use attachMovie or duplicateMovieClip to add other elements inside the new movie clip. Later in this hour , you will see how to create new text fields ”these can also be added to the new movie clip.


I l @ ve RuBoard


Sams Teach Yourself Flash MX ActionScript in 24 Hours
Sams Teach Yourself Flash MX ActionScript in 24 Hours
ISBN: 0672323850
EAN: 2147483647
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net