flash help / conversion
- Started
- Last post
- 5 Responses
- lnu
Hello, can you help me out?
I have this number (i.e. the number of the active button in a menu) and I want to put that number in the name of a movieclip that I want to do something with. Like, my buttons are called btn1, btn2 etc. And the number/expression for the active button is activebtn. So what I would like to do is to use them both in a command, like: with(_root.btn[activebtn]) do this and that. What is the syntax for this? Hope you understand what I mean. Thankulations.
- lnu0
That is, I want to take a numeric value, put it in a string and use the string as an instance name.
Bump.
- jaybee0
*bumpity bump*
- unfittoprint0
First, use a movieclip instead of a button.
You can turn your buttonMC into a component [right click on the library item - component], create a variable for it called [for example] ID.
Place them and using the properties inspector, give those instances the ID number [1,2,3, etc...]
Inside the symbol you can put some action like:
this.onPress = function(){
_root.active = this["btn"+ID];
}
- lnu0
Thanks. It's already a mc and I have several instances of it. But can I use this["btn"+ID] directly in dot notation (as an instance name)?
- unfittoprint0
I think the best way to make an inactive/active status [you don't even need to name the instance]:
Inside the buttonMC create two frames and name them "inactive' and 'active'.
//press event
this.onPress = function (){
_root.active.gotoAndStop("inacti...
_root.active = this;
this.gotoAndStop("active");
}
stop();You don't even have to name the instance [Flash creates an automatic name for it]. If you call directly _root.active.myVar would be the same as calling your button's variable, becuae active is a 'mirror' of it...