Quantcast
Channel: Adobe Community : Discussion List - Using Flash Builder
Viewing all articles
Browse latest Browse all 1802

Getting error 1120: access of undefined property

$
0
0

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. 


Viewing all articles
Browse latest Browse all 1802

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>