Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

Animating Dynamic MovieClips - Page 8
       by kirupa  |  30 August 2006

We wrapped up the main part of the tutorial on the previous page. In this, the last page, we tie up some unfinished ends!


Putting it All Together
At this point, you re-created the mouse-trail like effect as well as learned about how each line of code works. In this section, let's go back and re-visit some of the important concepts beyond just the code that I hope this tutorial communicated.

Obviously, learning how to use attachMovie is a big part of this tutorial. Creating re-usable movie clip is both a great way to reduce file size, but it also makes maintenance and future updates much easier when all you have to do is change one movie clip instead of several individual movie clips.

Using attachMovie has its own set of issues that need to be addressed. One major issue is being able to assign unique values to the the newly attached movie clip's properties and variables. There is no easy way to use an onLoad event handler with a dynamically generated movie clip placed on stage via attachMovie, loadMovie, createEmptyMovieClip, etc. So, in this tutorial, I explained how to pass in the values for the properties of your movie clip object as part of the attachMovie function's argument itself. There are other, more indirect ways, of simulating onLoad, and the following code provides one way of using the onEnterFrame event handler and deleting it after it has gone through one iteration:

var newMC:MovieClip = this.attachMovie("blueCircle", "blue"+count, 10000+count);
newMC.onEnterFrame = function() {
this._x = xPos;
this._y = yPos;
this._alpha = 10+Math.random()*40;
this._xscale = this._yscale=scale;
delete this.onEnterFrame;
};

The above method approach has its drawbacks also. For example, it is tricky to both assign your initial properties using onEnterFrame, deleting onEnterFrame, and then creating another onEnterFrame event handler to deal with the animation. Until, hopefully, future versions of Flash address this issue, you can read senocular's FAQ on this as well as take a look at some solutions at the always-useful http://proto.layer51.com/ site.

Finally, keeping each movie clip's properties and variables from interfering requires some planning. If a variable happened to accidentally be declared outside the scope of an individual movie clip, then you will find that this particular variable's data is shared across all movie clips. That might be useful in some cases, but when each movie clip is part of an animation with its own scale and alpha values, a global variable is not preferable.


Phew! With that, I hope this tutorial helped give you a better understanding of using attachMovie and dealing with some of the issues that you can encounter with it. I have provided the source file for my version of the example animation you saw on the first page.

I hope the information helped. If you have any questions or comments, please don't hesitate to post them on the kirupa.com Forums. Just post your question and I, or our friendly forum helpers, will help answer it.

The following is a list of related tutorial and help resources that you may find useful:

How to use the Forums
New, Upcoming, and In-Progress Tutorials
How to Help out kirupa.com
Writing Tutorials
 
Cheers!
Kirupa Chinnathambi
kirupaBlog

 

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components

Flash Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Learn how to advertise on kirupa.com