Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error # 1120, Access of undefined property ERROR. AS3

Explorer ,
Apr 11, 2014 Apr 11, 2014

I have a code inside of an actionscript file, and i receive multiple errors when attempting to debug:

1120: Access of undefined property square.

1180: Call to a possibly undefined method addChild.

1120: Access of undefined property square.

1120: Access of undefined property square.

1120: Access of undefined property fl_click.

1120: Access of undefined property myTimer.

1120: Access of undefined property timerListener.

1120: Access of undefined property myTimer.

Here is my code for my main actionscript file:

package

{

    import flash.events.MouseEvent;

    import flash.display.MovieClip;

    import flash.utils.Timer;

    import flash.events.TimerEvent;

    public class Game extends MovieClip

    {

        public var myTimer:Timer = new Timer(50);

        public var square:Square;

        square.addEventListener(MouseEvent.CLICK, fl_click);

        myTimer.addEventListener(TimerEvent.TIMER, timerListener);

        myTimer.start();

        private function timerListener(e:TimerEvent):void

        {

            square.edgeCorrect;

        }

        private function fl_click(event:MouseEvent):void

        {

            square.moveDownABit();

        }

        public function Game();

        {

            square = new Square();

            addChild( square );

        }

I am a beginner, so please tell me specifically what to do with my code, thanks!

TOPICS
ActionScript
6.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 11, 2014 Apr 11, 2014

The big problem is this line:

public function Game();

Remove semicolon and try to compile again.

Translate
LEGEND ,
Apr 11, 2014 Apr 11, 2014

What do you expect to see when instance of Square is spawned?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2014 Apr 11, 2014

A black square, with a random height, width, and location on the screen, i drew the black square in flash and it is a library file.

The object of this application is for you to click on the square, and it will change locations and dimensions.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2014 Apr 11, 2014

When you double-click on Square library symbol and Flash opens it - do you see black square there?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2014 Apr 11, 2014
LATEST

Nevermind, i accidentaly deleted the square from its own file in the library, i redrew it and it works perfectly. Thx, and cheers!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2014 Apr 11, 2014

And no, I am not suggesting manual placement of Square on stage. Square is supposed to be some visual, isn't is? In order for it to display any visual - Square itself has to have something on ITS timeline/display list - not main timeline/stage..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2014 Apr 11, 2014

How do i place itself on its own timeline? Sorry for my confusion, i am new to AS3 and have not worked with timelines before. And yes, it is supposed to be visual.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2014 Apr 11, 2014

Also, timer handler should be:

private function timerListener(e:TimerEvent):void

{

          square.edgeCorrect();

}

Because egdeCorrect is a method - not property.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2014 Apr 11, 2014

Oh yes i fixed edgeCorrect(), but doesn't addChild put things on my timeline and displaylist?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 11, 2014 Apr 11, 2014

I think you should name your Square Symbol in your library SquareMC, and then when you create the square in the constructor, say

square = new SquareMC();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines