views:

33

answers:

1

I define a variable which is dynamicaly changes based on the user interactions, for example ID of an object sets to variable when user touches on it. After the ID sets I call a function in a custom component which is related to that object. Like this;

activeObject.videoPlay(event) ---> if the activeObject is video1 ---> video1.videoPlay(event) function will be called.

I tried several variable types when defining the variable activeObject, such as String , Array but didnt work out. By the way the data set to variable is String. When I use String type it gives this error;

Error #1061: Call to a possibly undefined method videoPlay through a reference with static type String.

Is there any way to use a string as a dynamic variable?

A: 

Is there any way to use a string as a dynamic variable?

Bracket notation -- obj["dynamicPropertyName"] as Type or in your case (activeObject['videoPlay'] as Function).apply(abc, [event]); You'll obviously want null object checks etc.

jeremy.mooer