|
-
[AS2] Attaching / gotoAndPlay();
Hi guys,
This might seem like a simple question, but I just can't seem to figure out whats wrong. Maybe it's because it's past midnight and I'm extremely tired, but either way I'll just post it here.
Let me just explain the situation in a mock setup:
You have a button. When the button is pressed, you call a function that attaches a movieclip inside of a tile (another movieclip). Simple. You then tell this newly attached movieclip that is inside the tile to gotoAndPlay(2);, which is essentially a tween animation.
In this example lets say its the following: you press a button which calls a function. This function attaches a movieclip of a character inside another movieclip which is a tile. You then tell this character movieclip to gotoAndPlay(2); which is of, say, him moving to the right.
Function code:
PHP Code:
moveChar = function(){
tileName = "b"+charRow+"_"+charCol;
_root[tileName].attachMovie("char","char",_root[tileName].getNextHighestDepth());
_root[tileName].char.gotoAndPlay(2);
charCol ++;
}
What happens is that although you tell the char movieclip to play from frame two, once attached, it automatically appears on the last frame of the animation.
Weird, I know.
Any thoughts?
-
Just to make sure. The problem seems to come from the tween:
you have a separate layer for actions, on frame #1 there's a stop, on frame#2 there's a play, on the last frame a stop. On the 2nd layer a motion tween with a graphic or movieclip animating.
yes?
gparis
-
Wow that is odd.
It was actually all on the same layer. A stop(); on the first frame, and it would the function would ask the tween to play from frame 2 to the end and result back on frame 1. That was the idea.
Anyways, I just went with your confirmation and simply added a play(); on frame 2 and it works. Any idea why it would need a play(); on frame 2 even though I had called it from the function: gotoAndPlay(2);?
-
always needs a play() in that case. that's how it goes.
gparis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|