flash.Q ; )
- Started
- Last post
- 2 Responses
- tonks
Is anyone familer with this 5 button tutorial?
How do you actually assign any actions to the individual buttons? As in how do I tell the separate buttons to do different things?
http://www.canfieldstudios.com/flashmx/btnstat5/index.html
thanks. if you understand??!
- ********0
are you familiar with your mouse button?
- davi-t0
Here's on way that I can think of off of the top of my head. I'm sure there's a better way but its pretty easy to understand if you aren't that great at AS. Should work fine.
- Make button movieclips (1st frame a button(up and over states), 2nd frame the 'hit' state)..stop actions in both frames.
- Give instance names to the MC that holds them.
- Create a function to reset the previously hit button. Create another function that the button MC will call when pressed.
- Add Actionscript to a frame after the button MC frame.currentBtn = undefined; //-->Variable used to tell what button is currently in it's HIT state.
// FUNCTION for resetting buttons --->
function resetBtn () {
if (currentBtn != undefined) { currentBtn.gotoAndStop(2);curren... = undefined;}// FUNCTION for making the button show its HIT state --->
function hitBtn (btn) {
resetBtn(); // Reset previous btn if it was in its hit state.
btn.gotoAndStop(2);
// add other code here.
currentBtn = btn;
}// CODE for buttons. (make sure the button MC's are available on whatever frame this code is on.
btn1_mc.onPress = function(){hitBtn(btn1_mc);}btn2_mc.onPress = function(){hitBtn(btn2_mc);}
btn3_mc.onPress = function(){hitBtn(btn3_mc);}
btn4_mc.onPress = function(){hitBtn(btn4_mc);}
btn5_mc.onPress = function(){hitBtn(btn5_mc);}
and so on and so on for more buttons...
Hope that helps.