Error AS3: "1172: fl.controls definition: button not found."

I'm trying to create a class called LinkButton, which is a simple class that loads a URL with a click (im does this to make it easier for designers to switch to AS3). Although I import the button definition, the AS file gets a compilation error: 1046: The type was not found or was not a compile time constant: Button. and 1172: Definition of fl. Controls: Button not found. I created a button by making a simple shape, converting it to a character (F8) like 'Button'. In my FLA file, I have this code:

import AS3classes.mouse.LinkButton; var link1:LinkButton = new LinkButton(testLink, "http://www.example.com"); 

Simple? In my AS file, I import the button definition by declaring the constructor and the "linkTo" Behavior. Here is my code in the AS file:

 package AS3classes.mouse { import fl.controls.Button; import flash.events.*; import flash.net.*; public class LinkButton { private var _pageURL:String; private var _button:Button; public function LinkButton(button, pageURL) : void { _button = button; _pageURL = pageURL; _button.addEventListener(MouseEvent.MOUSE_UP, LinkTo); } private function LinkTo(e:Event) : void { var request:URLRequest = new URLRequest(_pageURL); } } } 

When Iโ€™m Google, I see that people get this error because they donโ€™t have a button in their library. I have a button that I created from a simple form. Am I importing the correct definition? I have no problem importing a movieClip definition in another script with the same method. I do not understand the difference, and I am sure that I am not stupid.

+4
source share
3 answers

You are using the wrong type of button. When you describe it, you want

 flash.display.SimpleButton 

fl.controls.Button is a Button component, not a button defined in the library. Make sense? Try importing flash.display.SimpleButton and setting _button instead of SimpleButton.

+6
source

You need to go to the Components window and drag the Button into the Library window.

To use a component, simply import it using the import fl.controls.Button; command import fl.controls.Button; . Now you can use the "Button" with its label, etc.

+6
source

Matt Dales - right. I definitely had a problem right now. "Button" tricked me. In the panel ctrl + f7 = components, I looked at the Video group and tried the button from there. Doesn't work like a "Button". Look in the User Interface group. Get the "Button" from there and drag it into the library. Then the fl.controls.Button and Button () functions are executed.

0
source

Source: https://habr.com/ru/post/1299045/


All Articles