View Single Post
Old 09-08-2012, 11:21 AM   PM User | #3
djpaul1963
New Coder

 
Join Date: Apr 2012
Location: Athens GR
Posts: 58
Thanks: 0
Thanked 6 Times in 6 Posts
djpaul1963 is an unknown quantity at this point
About step 1, the solution you need is to forget about button and hit states and replace with a movie clip that you treat like a button. This way, the movie clip will have the frames you want, each one with a different color. Every time a user clicks right, you move the movieclip playhead to the correct frame.
For example, you will have a white square on frame 1, a green on frame 2 and a red on frame 3. you name this movieclip as anything you like (answer_button for eaxmple) and then from your actionscript you do:

answer_button.buttonMode = true; // this needed to change the mouse cursor to pointer when the mouse hovers the answer_button
answer_button.addEventListener(MouseEvent.CLICK, onAnswerClick);

protected function onAnswerClick(e:MouseEvent):void
{
// here you implement your game logic like:
if (answer == "correct") e.currentTarget.gotoAndStop(2); // the 'button' shows green
else e.currentTarget.gotoAndStop(3); // the 'button' shows red
}

About step 2, you need a global int variable (I hope you know what global variables are) to keep the score. Also, you need an array of Booleans to keep the questions status. If the user selected question 2 for example, you set true that Boolean and deny further interaction.

About step 3, not sure I understood what exactly you mean, but if I got it right:

the health movie clip is an animation of lets say 100 frames, changing a gradient form green to red. You add a second layer to that movieclip with an action keyframe on frame 1 where you write stop(); You name this as health_bar or whatever. When you place that on the main timeline you see only one frame (because the 100 frames are the animation of that particular movie clip, they are INSIDE the movie clip). So, even if you extend the frames of that layer to have the movie clip active till the end of the timeline, the health_bar will be just a single frame. Now, each time you want the health_bar to show a different life status you do a health_bar.gotoAndStop(XX) where XX is the frame you want.

I hope I helped. If you need more help upload your .fla and .as file to show you in practice.

Last edited by djpaul1963; 09-08-2012 at 11:27 AM..
djpaul1963 is offline   Reply With Quote