I just started getting more into Flash CS4 today and decided to learn how to use it (lol) and I know how to make basic animations and everything now, and starting to learn basic coding. Now i need some help with making buttons for a game. I asked this on Yahoo! Answers but i know I'll get better help here so I'll copy and paste what i said there:
"I wanna make a button for a game I'm making with flash CS4, what i need it to do is delete itself when i click it. I wanna have 5 buttons, and the only way to pass that room is to click them all, and for each one to delete when you click it. I just started using flash but i know some basic stuff with coding, but this is the only problem I've had with making a game so far. Please give me a code to do this, tell me which code to put in which button (button 1, button 2...) and BTW, I'm using ActionScript 2.0"
Also, of course, I'll make more more levels with more buttons you'll have to click. So can you help me some with making it so you'll have to click the same button more than once? I'm making each room/level in different keyframes, which each keyframe has the action " stop(); ", will it work with that setup?
Okay, can you help me with doing that using AS3? This is kinda like the game I'm trying to make, except i want the buttons to get deleted after i press them: http://armorgames.com/play/2578/the-timewaster-ultra
Nope, not what i was looking for. I want to have 5 buttons on screen at once, when you click one it disappears, and you have to click every button on the screen for it to go to the next level. I don't want it to change colors like that, cause some buttons will be hiding. So can anyone else help with what i wanna do?
What you should do, is instead of having the button already on the screen, put it in a movieClip and attach it (the movieClip) to the stage with the attachMovie() function, then remove it with the removeMovieClip() function.
Well i just started using Flash CS4 so i don't know exactly where to put the code at, do you mean put it in the keyframe? When i did that it said "attribute used outside class" what does that mean?
You would most likely want to put the attachMovie() function in the keyframe. Click the keyframe and open the actions panel and put it there. If you test it and a button is on the screen (without it having been there prior to publish) then it worked.
The code for the removeMovieClip() would go inside the movie clip on the instance of the button
using something like: on(release){ removeMovieClip(this); }
I got the button on the screen, but how do i enter the removeMovieClip code on it? I'm still using AS2 BTW, since i didn't want to learn AS3 yet. This is my first real game for flash, so I'm not really sure how to get to the actions panel for the movieclip/button without it being placed on the screen by me.
Ok, so you have a movieClip that has the button inside of it right? Open up the movieClip from the Library and then click on the button, open the actions panel and add the code: (the code is on the button, not a keyframe)
on(release){ removeMovieClip(this); }
-This makes the MovieClip (and the button) remove itself from the stage.