Skip to main content
Participant
July 29, 2008
Question

How to use a variable as object name? in actionscript?

  • July 29, 2008
  • 2 replies
  • 258 views
I am working on a flash menu and have a problem in it.
here is the code i am using.
I wanna use the variable mnu instead of this[mnu] but do not know how to do it. Any body can help me?
This topic has been closed for replies.

2 replies

Inspiring
July 30, 2008
>> var mnu = 'menu1';
this[mnu].onRollOver = function(){
<<

Close, but it needs to be like this:

var mnu = 1;
this["menu" + mnu].onRollOver = function(){

--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


kglad
Community Expert
Community Expert
July 29, 2008
you have use something (if not "this") to reference the parent of your object with instance name "menu1".