0

I was programming something and when I thought everything was nice and good, Flash throws an error to me!?

At first I was dumbstruck. Then after checking my code, I couldn't see the culprit. So what I did was 'simple it down', and changed it to just a trace statement.

I was still however getting the error. I don't know what is wrong.

   package  {

     import flash.display.MovieClip;
     import src.data.DActors;

     public class DocumentClass extends MovieClip {

        public var dActors:DActors = new DActors;

        public function DocumentClass() {
        trace (dActors);
        trace ("Main");
        }

    }

}

This is the DActors Class:

package src.data 
{
  public class DActors
   {
       public var me:int = 1;

      public function DActors();
       {    
          trace(me);
       }

  }

}

Some scope I'm not aware of or something?

Oh, and by the way, it throws that ''me' is not defined'!?

EDIT: Actually, I failed to realize the real problem, why the hell is my constructor not accepting variables!

 package src.data 
 {
public class DActors
{
    public var actors:Array = new Array();
    public var dActor:DActor = new DActor();

    public function DActors();
    {   
        actors.push(dActor);
    }

}

}

outputs:

1120: Access of undefined property actors.

1120: Access of undefined property dActor.

???? This worries me greatly. Either my eyes are fooling me or I'm missing something very basic.

1
  • @Kolyunya The 'FlashDevelop with Flash CS6 workflow'.
    – Secret
    Aug 24, 2012 at 8:45

4 Answers 4

1
public function DActors();

Constructor function will not end with ;(semicolon).

2
  • FACEPALM Haha. Thanks. I'm just getting used to the 'put your curly brackets after the method name' that I prematurely add semicolons. Can't believe how incredibly stupid that mistake was, I got so wrapped up in all the data structure and inheritance shenanigans that I put out a bat eye on that.
    – Secret
    Aug 24, 2012 at 9:31
  • I think you are novice to as3. cooool.
    – Benny
    Aug 24, 2012 at 9:36
0
public var dActors:DActors = new DActors;

Should be:

public var dActors:DActors = new DActors();
2
  • If you're using Adobe Flash Pro. Then: FILE -> PUBLISH SETTINGS -> Flash (.swf) [on the left panel] -> EXPAND ADVANCED -> CHECK: PERMIT DEBUGGING.
    – Zhafur
    Aug 24, 2012 at 9:15
  • Right, still check the permit debugging. Will help you a lot.
    – Zhafur
    Aug 24, 2012 at 9:35
0

Call the constructor properly

public var dActors:DActors = new DActors();
2
  • Try this.me and this.dActors
    – Kolyunya
    Aug 24, 2012 at 9:03
  • trace seems to be a static method; 1042: The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code.
    – Secret
    Aug 24, 2012 at 9:06
0

The semicolon after your DActors constructor breaks your code.

public function DActors();

if you change the DActors class to this it will work:

package src.data
{
    public class DActors
    {
        public var me:int = 1;

        public function DActors()
        {
            trace(me);
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.