开发者

Why the actionscript 3.0 snippet below failed to import Button and TextInput?

开发者 https://www.devze.com 2023-01-03 15:25 出处:网络
package { import fl.controls.Button; import fl.controls.TextInput开发者_运维技巧; public class MinRecord extends Sprite
package
{
    import fl.controls.Button;
    import fl.controls.TextInput开发者_运维技巧;
    public class MinRecord extends Sprite
    {
          private var recordBtn:Button;
          private var stopBtn:Button;
          private var textInput:TextInput;
...

When I run it reports:

Type was not found or was not a compile-time constant: Button.
Type was not found or was not a compile-time constant: TextInput.

Can someone point out what's wrong here?


Did you add the TextInput and Button components to the library ?

  • Drag a TextInput component from the Components panel to the Library panel.
  • Drag a Button component from the Components panel to the Library panel.

Make sure that there are in your library.

These should be GUI components of Flash CS5.

Edit: I see you have not also set a document class or maybe not properly

The document class is the top level class that associates with your FLA when it is published as a SWF. When you click Test Movie or Publish and instance of this class is produced to the object on the highest level in your swf, allowing properties and methods to be accessed.

You want to deselect all objects on the main stage and click on a blank area. Then you will see the Property window with the Document Properties (width ,framerate etc) . You will be looking for the Document class box and inserting the name of your actionscript file. Say you had all your main code in Main.as you want to insert Main (no .as extenstion)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号