The purpose of this Flash movie is to show that even though textField2 is created with ActionScript, it can be accessed from inside a function. The text box's scope is such that a function can access it. This is fortunate, since it's a lot harder in AS3 to create global variables than it was in AS2.
Download the FLA file// The purpose of this Flash movie is to show that even though textField2 is // created with ActionScript, it can be accessed from inside a function. The // text box's scope is such that a function can access it. This is fortunate, // since it's a lot harder in AS3 to create global variables than it was in AS2. // EXAMPLE 1 USES A TEXT FIELD PLACED ON THE STAGE: myButton1_btn.addEventListener(MouseEvent.CLICK, updateTextField1); function updateTextField1(myEvent:MouseEvent) { textField1.text = "Button 1 was clicked"; } // EXAMPLE 2 USES A TEXT FIELD CODED WITH ACTION SCRIPT: var textField2:TextField = new TextField(); textField2.border = true; textField2.width = 150; textField2.height = 30; textField2.x = 30; textField2.y = 85; addChild(textField2); myButton2_btn.addEventListener(MouseEvent.CLICK, updateTextField2); function updateTextField2(myEvent:MouseEvent) { textField2.text = "Button 2 was clicked"; }