RR23850
RR23850

Reputation: 3

actionscript 3.0 How to pass event as variable in addEventListener

I want to pass Event.type in a variable to EventDispatcher like this:

public var e:String = "Event.ENTER_FRAME";
addEventListener(e, moveBox);

Instead of:

addEventListener(event.ENTER_FRAME, moveBox);

It is compiling okay but while running the Event is not dispatching. Is there anything I am doing wrong, please help.

Thanks in advance

Upvotes: 0

Views: 54

Answers (1)

BotMaster
BotMaster

Reputation: 2223

Don't do this:

public var e:String = "Event.ENTER_FRAME"; 

do this:

public var e:String = Event.ENTER_FRAME; 

Upvotes: 1

Related Questions