Monday, February 21, 2011

What is acessof undefined property Event and how do I resolve it? I use actionscript 3.0

public function assgn()
{
    var recA:Sprite = new Sprite();

    graphics.beginFill(0xFFF010);
    graphics.lineStyle(1);
    graphics.drawRect(0, 380, 50, 20);
    addChild(recA);

    recA.x = 300;
    recA.y = 300;
    recA.scaleX = 2;
    recA.scaleY = 2;
    recA.addEventListener(Event.ENTER_FRAME, moveRecA);
From stackoverflow
  • It looks to me like you might not have the correct import statements at the top of your Actionscript file. Try placing an import at the top of the file, as follows:

    package
    {
        import flash.events.Event;
        ...
        public class Xxxx
        {
            ...
            public function assgn()
            {
                var recA:Sprite = new Sprite();
    
                graphics.beginFill(0xFFF010);
                graphics.lineStyle(1);
                graphics.drawRect(0, 380, 50, 20);
                addChild(recA);
    
                recA.x = 300;
                recA.y = 300;
                recA.scaleX = 2;
                recA.scaleY = 2;
                recA.addEventListener(Event.ENTER_FRAME, moveRecA);
                ...
            }
    
            ...
        }
    }
    

0 comments:

Post a Comment