Skip to main content
August 15, 2007
Question

Stuck... Pease need help passing variable

  • August 15, 2007
  • 1 reply
  • 238 views
Hi all....

I have an event listener added and it calls a function. Adding the event listener passes the event to the function automatically but what if i want to pass additional information to it?

So this:
addEventListener(Event.ENTER_FRAME, doEveryFrame);

Becomes this
addEventListener(Event.ENTER_FRAME, doEveryFrame(extra_var_passed));

function doEveryFrame(event:Event, extra_var_passed:Number):void {
//code here
}

It seems because I am trying to pass a new variable it no longer passes the event for me auto-magically.... how I go about passing that event myself?

Is it possible to even pass another variable like this??
This topic has been closed for replies.

1 reply

August 17, 2007
This is AS3, correct?
You need to create your own event object that has the properties you need to pass.
Take a look at the tutorial on custom events here:

http://www.8bitrocket.com/newsdisplay.aspx?newspage=5776