Changing MovieClip (AS2)

Subscribe to Changing MovieClip (AS2) 7 posts

Sign in to reply


 
avatar for XsiX XsiX 20 posts
Flag Post

Hello Kongregators.

I am new to Flash developing, and I am currently developing a game, where my character is breathing while standing still, and then I have some graphics for when he is walking, but I do not know how to change the MovieClip to the walking part or however it is possible to do it?

Hope you understand what I mean, if not please reply and I will try to explain it in a different way.

Kind Regards
XsiX

 
avatar for Supersausagedog Supersausagedog 522 posts
Flag Post

gotoAndPlay/gotoAndStop?
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/

 
avatar for XsiX XsiX 20 posts
Flag Post

Not really sure if that would work, but now I am just trying to use _visible however it is not really working, and I think it might because of the path I am using.

I have a MovieClip and class called David, in David I have 2 layers on the timeline, one called DavidStand and one called DavidWalk.

So I want to hide DavidWalk at first by doing:
root.David.DavidWalk.visible = false;
But it is not working, any idea why?

Edit: I have a _ infront of root and visible, but due to formatting on kongregate’s forum, it changes it to italics instead.

 
avatar for Supersausagedog Supersausagedog 522 posts
Flag Post

Well I can’t tell you if this is the best way or not, but what I do is having all the animations in one movieclip, but at different times. If, for example, the breathing loop was in frames 1 to 10, then frame 10 would have code to gotoAndPlay(1), thus stopping it from intefering with the other animations.

 
avatar for XsiX XsiX 20 posts
Flag Post

Ahh I was just not sure how to make it loop without having separate layers.
Got it now, and it is working, thanks Supersausagedog! :D

Edit: Not really working, I of course want my walk graphics to show when I press the RIGHT button, but what I did was I added this code for when I press the button:
_root.DavidInstance.gotoAndPlay(25);

But now instead of playing from 25 to 44, it just stays at frame 25 as long as I hold down the button.

 
avatar for XsiX XsiX 20 posts
Flag Post

Okay I made it work now, by adding some walking locks :P

 
avatar for MaToMaStEr MaToMaStEr 628 posts
Flag Post

You can have, in each frame of the Character MovieClip, another MovieClip containing the animations for the actions you want.
Then on the onEnterFrame method cath for the Keypress

if(Key.isDown(Key.RIGHT)) this.gotoAndStop(“walk”);
else this.gotoAndStop(“stand”);

for example,

Sign in to reply