I am trying to create a class called LinkButton, which is a simple class that loads a URL on a click (im doing this to simpify my designers' transition to AS3). Even though I am importing the button definition, the AS file gets a compile error: 1046: Type was not found or was not a compile-time constant: Button. and 1172: Definition fl.controls:Button could not be found. I created the button by making a simple shape converting it to a symbol (F8) of type 'Button'. In my FLA file i have this code:
import AS3classes.mouse.LinkButton;
var link1:LinkButton = new LinkButton(testLink, "http://www.example.com");
Simple right? In my AS file I am importing the button definition, declaring the constructor and 'linkTo' Behaviour. 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 Google this, I see people getting this error because they don't have a button in their library. I do have a button I created from a simple shape. Am I importing the right definition? I have no problem importing the movieClip definition in a different script with the same method. I don't understand the difference, and I'm pretty sure I'm not stupid.