Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE FLASH:HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

swapping out movie clip on different layer

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Sterling Youngmanswapping out movie clip on different layer
by on Jul 20, 2008 at 4:45:07 am

Hi everyone,

I know this is simple, but I'm new, so don't know what I'm doing.

I have a simple flash file with a movie clip on one layer and two buttons, each on their own layers. I would like to swap out the movie clip with an alternate clip, depending on which button is clicked.

Can some one explain how this is done, or point me to an example FLA file?

Cheers,

Sterling



Return to posts index
Reply   Like  

Sterling YoungmanRe: swapping out movie clip on different layer
by on Jul 20, 2008 at 6:43:30 am

here's where I am so far:

on (release) {
var theDepth:Number = originalClip.getDepth();
attachMovie("clip2","originalClip",theDepth);
}

THis is the Action Script on one of the buttons. It actually does bring the new clip onto the stage, but not in place of the original clip. I'm guessing it is coming in at (0,0).

Furthermore, the second button, with similar code, will not bring up it's movieclip. It seems that it only works for whichever button is clicked first.

Cheers,

Sterling



Return to posts index
Reply   Like  

Pieter HelsenRe: swapping out movie clip on different layer
by on Jul 20, 2008 at 10:06:05 am

Here you go.

If you have any questions about the code, do ask, but it's pretty straightforward :)

From now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.

Kind regards,
Pieter


Return to posts index
Reply   Like  


Sterling YoungmanRe: swapping out movie clip on different layer
by on Jul 21, 2008 at 6:36:16 am

Thanks for your file.

I'm using CS3, so AS3 is fine.

I'm still stuck in the same place.

Fir some reason, the original_mc (depth,x,y) values are not loading into the variables, in my version. Canyou think of why this might happen. I copied and pasted your code and swapped out the names of the movieclips, so it has to be some other thing I have over looked.

Cheers,

Sterling



Return to posts index
Reply   Like  

Sterling YoungmanRe: swapping out movie clip on different layer
by on Jul 21, 2008 at 7:11:52 am

more info:

Even using a line like:

var yVar:Number = 200;

does not hardcode the coordinate.

If I use:

attachMovie("newMovie","new Movie", myDepth,{_x:400, _y:150});

Then it will position the clip at that location.

Also, if I use:

original_mc.attachMovie("newMovie","new Movie", myDepth,{_x:xVar, _y:yVar});

Then the clip jumps the right place, but the original can be seen underneith.

Cheers,

Sterling



Return to posts index
Reply   Like  

Sterling YoungmanRe: swapping out movie clip on different layer
by on Jul 21, 2008 at 7:35:18 am

PROBLEM SOLVED!!!!!

The code that was suggested in the third posting of this thread is perfect.

My further problems were a result of the original flash animator setting the file to AS1.

Thanks for the help.

Cheers,

Sterling



Return to posts index
Reply   Like  


Chris LindemanRe: swapping out movie clip on different layer
by on Jul 23, 2009 at 11:43:43 pm

I know this thread is old, but it's what I want to do (essentially), and the linked file no longer works.

In addition to swapping movie clips, I would also like be able to tell the clip where to start playing from, based on which frame the original clip was at, when the button was pressed.

anyone know how?


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]