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

Getting error 1120: access of undefined property

Community Beginner ,
Jun 26, 2017 Jun 26, 2017

Copy link to clipboard

Copied

I am trying to make a menu in a flash builder mobile action script project.  the following is the code for my menu screen that is loaded as a class file into the Main.as file with a addChild command.  The problem began when I added a event listener and associated function to respond to a button being clicked on.  The code is as follows:

package

{

import flash.display.Loader;

import flash.display.Shape;

import flash.display.Sprite;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.net.URLRequest;

import flash.text.TextField;

import support.RoundRectButton;

public class MenuScrn extends Sprite

{

 

  public function MenuScrn()

  {

   super();

  

   this.addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);

     

  }

 

  private function onAddedToStage(e:Event):void

  {

   var rectAndCircle:Shape = new Shape();

  

   rectAndCircle.graphics.lineStyle(1);

  

   rectAndCircle.graphics.beginFill(0x0000FF,1);

   rectAndCircle.graphics.drawRect(125,0,150,75);

  

   rectAndCircle.graphics.beginFill(0xFF0000,1);

   rectAndCircle.graphics.drawCircle(50,100,50);

  

   rectAndCircle.x=125;

   rectAndCircle.y=100;

  

   addChild(rectAndCircle);

  

   var greeting_txt:TextField = new TextField();

   greeting_txt.text="Hello World";

  

   greeting_txt.x=300;

   greeting_txt.y=300;

  

   addChild(greeting_txt);

  

   var testbtn:RoundRectButton = new RoundRectButton(240, 50, 20, 2, 0xFF0000, "Round Rect Button",0x0000FF, "Helvatica", 24, false)

   testbtn.x=10;

   testbtn.y=10;

   addChild(testbtn);

  

  }

 

  testbtn.addEventListener(MouseEvent.CLICK, onClk);

 

  private function onClk(e:MouseEvent):void

  {

   trace(e.target);

   }

}

}

I get a 1120 Error access of undefined property for both testbt.addEventListener and OnClk in the highlighted line. 

Views

643

Translate

Translate

Report

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