Jump to content
Search Community

duplicateMovieClip/tween

Pique test
Moderator Tag

Recommended Posts

Hey Everyone,

 

I have a mc (rocket_puff) inside another mc (rocket) that tweens on rollover

 

this.rocket.onRollOver = puff;
function puff ()
{
TweenMax.to(rocket.rocket_puff, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
}

 

 

On rollover i want to duplicate/add another "rocket_puff" while the original one is still tweening. So everytime you rollover, another puff is added and tweened.

 

I tried both of the "duplicateMovieClip" clips...

this.rocket.onRollOver = puff;
function puff ()
{
TweenMax.to(rocket.rocket_puff_1, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
i = i + 1;
duplicateMovieClip (rocket.rocket_puff_1, "puff" + i, i);
//duplicateMovieClip("rocket.rocket_puff_1", new_object, iCount + 1);
}

 

They kinda work but adds the extra mc wherever the current one is.

 

 

Any suggestions?

Link to comment
Share on other sites

Wouldn't you just duplicateMovieClip() first and then tween that new (duplicated) MovieClip instead of the other way around? That way the original always stays put. If that's not what you want, then just explicitly set the _x and _y properties after you duplicate it.

Link to comment
Share on other sites

Sounded like a good idea at first but it didn't work.

 

this.rocket.onRollOver = puff;


function puff ()
{
i = i + 1;
duplicateMovieClip (rocket.rocket_puff_1, "puff" + i, i);
//duplicateMovieClip("rocket.rocket_puff_1", new_object, iCount + 1);
TweenMax.to(rocket.rocket_puff_1, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
}

 

 

...quick question about the duplicate snippet...

which one of these methods is better?

 

i = i + 1;
duplicateMovieClip (rocket.rocket_puff_1, "puff" + i, i);
or
duplicateMovieClip("rocket.rocket_puff_1", new_object, iCount + 1);

 

I tried with both and it still does the same thing.

 

So, while the original mc is tweening, the new one (duplicated mc) is placed along the path of the tween and stays put where ever the original was at the time of duplication. When you rollover again, the duplicated one just jumps to the originals current location on the tween path again and just stays put again. So only one mc is being added.

Link to comment
Share on other sites

Looks like it's because you're always tweening the same (original) one instead of the new one.

 

function puff ()
{
  i = i + 1;
  var puff:MovieClip = rocket.rocket_puff_1.duplicateMovieClip ("puff" + i, i);
  TweenMax.to(puff, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
}

Link to comment
Share on other sites

Oh, I thought that's exactly what you wanted.

 

So you want there to be no puff, then on rollover a puff appears and animates? If so, you could just set _visible to false on your original.

 

rocket.rocket_puff_1._visible = false;
function puff ():Void {
  i = i + 1;
  var puff:MovieClip = rocket.rocket_puff_1.duplicateMovieClip ("puff" + i, i);
  puff._visible = true;
  TweenMax.to(puff, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
}

Link to comment
Share on other sites

Right, but i want a new puff to appear every time you rollover, without the other puffs going away until they finish animating. So essentially if you rollover 5 times, there would be 5 puffs animating.

Ummm....right....isn't that exactly what that code does? Well, it doesn't get rid of it after animating, but that's as simple as using an onComplete to removeMovieClip(). Or am I missing something?

Link to comment
Share on other sites

Yeah, I'm as confused as you are. I thought you wanted it to keep duplicating the original each time you rolled over, and the puff would start at the same spot as the original and animate from there. I just tested my code and it worked exactly as you described (or as I interpreted it at least). Could you post a super simple example FLA that demonstrates the issue and maybe describe in a little more detail what's supposed to happen? Sorry if I'm being totally thick-skulled but I'm pretty sure that what I provided does precisely what you asked for.

Link to comment
Share on other sites

Oh, you just forgot to set your "i" variable initially (I thought you had done that already outside your function).

 

var i:Number = 10;
rocket.rocket_puff_1._visible = false;
function puff ():Void {
  i = i + 1;
  var puff:MovieClip = rocket.rocket_puff_1.duplicateMovieClip ("puff" + i, i);
  puff._visible = true;
  TweenMax.to(puff, 5, {_y:"-155", _x:"100", _yscale:300, _xscale:300, _alpha:0, ease:Linear.easeNone});
}

Link to comment
Share on other sites

Oh i see. Didn't think I needed that part since "i" was already delacred. Cool works fine now.

 

Now I just need to figure out how to make the remove the 'mc' from the stage after the tween is complete, because if the alpha was 100 instead of 0 in the tween you'll notice that the 'mc's' are actually still on the stage stacking up.

 

But... many thanks for your help!

 

Pique

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...