Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 Error: '1172: Definition fl.controls:Button could not be found.'

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.

like image 948
Andrew Magill Avatar asked Dec 18 '22 03:12

Andrew Magill


1 Answers

You are using the wrong type of button. As 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 to be a SimpleButton instead.

like image 90
sberry Avatar answered Jan 21 '23 13:01

sberry