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.
source share