Question

`

public class names extends MovieClip
{
   public function names(YourName:String)
    {
      this.addEventListener(Event.ENTER_FRAME,doThis);
    }
    public function doThis(e:event,Name:String)
    {
      trace(Name);
    }
}

Im trying to pass the value "YourName" form the consturctor to the doThis class. I dono if im just really stupid or not but i cant understand how to do it. is there a way i can have 2 parameters for the doThis class?? or is there another solution

`

Was it helpful?

Solution

This code may help you:

package {

public class Names extends MovieClip
{
   private var name:String ;

   public function Names(name:String)
    {
      this.name = name ;
      this.addEventListener(Event.ENTER_FRAME, doThis);
    }

    public function doThis(event:Event):void
    {
      trace(this.name);
    }
}
}

All functions, that are called after events being dispatched accept only 1 parameter:Event.

All you do is just use instance variables. Good luck, hope it helps :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top