Need coding advice

A place for tutorials on how to get the most out of Flash

Need coding advice

Postby Mr D » Sat Dec 08, 2012 11:43 pm

First: I am sorry I am posting an request here but I didnt find out how to do it online and was not able to figure it out from .fla files that have that code. And I know that a lot of people here know how to do that.

Ok here is what I need to know (btw using AS2). I want to be able to change costumes with one button click. So for example I want that on press of the button for it to change frames from 1 to 2 or 3 in symbols named Helmet,Body,legs. If someone is so nice to explain it to me step by step and so I can understand how it actually works and see why it works like that.

thanks
1 game (oh I mean story slideshow -_-) and 5 flash loop FINISHED...fuck yea
My mini flashes link : http://legendofkrystal.com/forum/viewto ... f=7&t=1972
Also I am working on a project right now.But remember, it's a secret to everybody >:D
User avatar
Mr D
 
Joined: Tue Jun 01, 2010 12:44 am
Location: Alphabet

Re: Need coding advice

Postby Thaedael » Sun Dec 09, 2012 3:26 am

Brought this to KatsuO_O's attention, I know he has done it before in animations for me so hopefully he will be able to help you!
Thaedael
 

Re: Need coding advice

Postby KaTsuO_O » Sun Dec 09, 2012 3:43 am

First of all you need to give your movieclips instance names, it is the name that the program will use to communicate with the movieclips. It is not the same thing as the name you give it when you create it, if you click on a symbol and then open properties you'll see where you can enter an instance name. you can write what ever you want, but it is recommended to keep it simple so that you can remember it.

Let's say we start with the Helmet, give it the instance name helmet. If the helmet is inside a head symbol then you need to give the head an instance name as well, which should be head. Same if the head is inside a character movieclip.

Then for the different helmets, make keyframes inside the helmet movieclip, add one on each frame and put the "stop();" action on all of them.

The code for the button is basically:

on (release) {
helmet.play();
}

It means that when you release it will play the frames inside the helmet, however since you got stop(); on each it will stop on the next one and loop back to the first frame again.

but if the helmet is inside a head movieclip then you need to change it to:

head.helmet.play();

if the head is inside a character movieclip then you need to change it to:

character.head.helmet.play();

So it gives the path for the program to follow.

If it still doesn't work then that should be because the button is not in the root of the file. It would just be confusing to explain so I can just say, add _root. before helmet.play(); or how you chose to structure it.
Don't create a porn game if you're only interested in porn.
Wise words regarding criticism http://www.youtube.com/watch?v=-98ZFl1sKt4
User avatar
KaTsuO_O
 
Joined: Tue Nov 02, 2010 6:03 pm

Re: Need coding advice

Postby Mr D » Sun Dec 09, 2012 4:02 am

Thanks KaTsu it works great. I was even able to figure out how to make go to specific frame inside the symbol. Thank you time million :D
1 game (oh I mean story slideshow -_-) and 5 flash loop FINISHED...fuck yea
My mini flashes link : http://legendofkrystal.com/forum/viewto ... f=7&t=1972
Also I am working on a project right now.But remember, it's a secret to everybody >:D
User avatar
Mr D
 
Joined: Tue Jun 01, 2010 12:44 am
Location: Alphabet

Re: Need coding advice

Postby Thaedael » Sun Dec 09, 2012 4:17 am

Another case solved by KatsuO_O furry coder extra-ordinaire! Going to move this to the tutorial section I think and keep it pinned in there <3
Thaedael
 

Re: Need coding advice

Postby OwnerOfSuccuby » Sun Dec 09, 2012 12:13 pm

By the way - you can read 1a and 1b and 1d about it there ;)
viewtopic.php?f=29&t=2370

You may need to work with global variables too some times if you will need to make the game and you already need to change components animation.
OwnerOfSuccuby
 
Joined: Fri Jun 11, 2010 9:33 pm

Re: Need coding advice

Postby GoRepeat » Thu Dec 13, 2012 12:49 pm

Word of advice: set a variable then use gotoAndStop instead. For some reason, I have no idea why, flash will start to lag to hell with too many Play commands (even if they are followed by a stop). On the base level of your animation put in:

Var myVar: Number = 1

Then just use that number to represent the sub frame for armor you want to display across the character. (Like 1 = nude, 2 = gentleman's mustache, etc).
ex:

myMovieClip.gotoAndStop(_root.myVar)
Picarto LiveStream: https://picarto.tv/GoRepeat
Other Stuff: Click Here
User avatar
GoRepeat
Moderator
 
Joined: Wed Jul 21, 2010 2:26 am
Location: Behind the Looking Glass


Return to Tutorials



Who is online

Users browsing this forum: No registered users