Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

swap members using Actionscript 1

Status
Not open for further replies.

wilcdr

Programmer
Jan 4, 2001
19
CA
Hi all,

Can someone tell me if it is possible to swap a sprite on stage with another item from the library? What I want to do is, depending on the action of the user, it will display different movie clips. And I can't just hard code in a long movie clip to do this because there will be around 50 different movie clips that can be played (more will be added later on).

I know some of you hate Director, but in Director, all I have to do is say something like:

sprite(3).member = member("memberToSwapTo")

and that will change the member of sprite 3 on the stage to the member "memberToSwapTo"

Is there anything similar in Flash?

Thanks!

Willy
 
hi Willy

There is something 'similar' in flash. You can 'attach' movie-clips from the library to other movie-clips on stage (and remove them).

For this to work best you would create an empty mc and drag it onto the main stage, give it an instance name (Ctrl+I) say "mainmc".

You then go into the Library (Ctrl+L) and right click on one of the mc's you want to enable for attachment, select the 'Linkage...' property, select "Export this symbol" radio button and enter an export name for the mc. Do this for all mc's you wish to be enabled for attachment.

Now, the reason I say it is best to use a blank mc is that when you 'attach' one mc from the library onto another in the main stage dynamically, the contents of the 'host' mc remain and cannot be removed or 'alpha-ed' out.

The action you use to attach a movie-clip from the library onto the empty one you've created on your main stage is:

mainmc.attachMovie("linkage-name-of-mc-in-Library", newmcname, depth-you-want-to-put-it-in);

where 'mainmc' in the example above is the instance name of the host mc you created above.

For example, if you set the export linkage name of an mc in your library to "attachmc1", you wanted it to be at depth5, and you give the attached mc an instance name "willysmc" then the action would look like:
Code:
mainmc.attachMovie("attachmc", "willysmc", 5);

And to remove the movie-clip:
Code:
mainmc.willysmc.removeMovieClip();


You can add and remove as and when you need it provided your careful about 'linkage', naming the mc instance(ie: willysmc), and targetting it correctly.

does this answer your question?

dave


dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top