g5604
April 6, 2006, 5:10pm
1
Hi,
i am trying to define a dynamic object name… here my code, but i guess it is wrong. any ideas?
i = 0
var knobListen = "knob"+i;
var knobListen:Object = new Object();
};
//add the event listener to the knob
myKnob_mc.addEventListener("onRotate", knobListen)
Well, for one you defined knobListen twice.
instead when you define a new object go.
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]var [/COLOR] knobListen = [COLOR=#000000]new [/COLOR] [COLOR=#0000ff]Object[/COLOR]COLOR=#000000 [/COLOR];
[/LEFT]
[/FONT]
You also don’t need that };
I’m not even sure what this line is supposed to do
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#000000]var [/COLOR] knobListen = [COLOR=#ff0000]“knob”[/COLOR]+i;
[/LEFT]
[/FONT]
since you seem to want knobListen to be a new object. Try this. And put it after the line that defines the new object.
ActionScript Code:
[FONT=Courier New][LEFT]knobLister.property = [COLOR=#ff0000]"knob+i; [/COLOR]
[/LEFT]
[/FONT]
g5604
April 6, 2006, 7:19pm
3
Hi,
thanks for your reply… i am just trying to name a object dynamically … so everytime i load into a my main movie the object has a different name.
I think eval can help you
eval(“knob”+i) = something