开发者

Flex: type was not found or was not a compile-time constant: Button

I am trying to build a pure as3 projec开发者_如何学Got in flex and I got the following error:

type was not found or was not a compile-time constant: Button

type was not found or was not a compile-time constant: TextField

My code is:

    import fl.controls.TextInput;  // import my textinput

import flash.display.Shape;
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import fl.controls.Button;   //import my button


public class SearchYoutube extends Sprite
{
    private var textBx:TextField=new TextField();
    private var controls:Controls;
    private var bground:Sprite=new Sprite();
    private var searchButton:Button;

/************************Constructor*********************/
        public function SearchYoutube()
        {
        /*********************Create Search Form****************************/
            createSearchForm("Please Enter Your Keyword");

        }



    /*********************Search Form****************************/
    private function createSearchForm(title:String):void{

        var searchInput:TextInput = new TextInput();  //error here
        searchInput.width = 200;
        searchInput.x=150;
        searchInput.y=450;
        searchKeyword=searchInput.text;
        addChild(searchInput);

        searchButton = new Button();   //error here
        searchButton.x = 380;
        searchButton.y = 450;
        searchButton.label = "Search";
        addChild(searchButton);
    }

}

}

I appreciate any helps!


Agree with the above answer, and add that Button is in package mx.controls.


Use imports

import mx.controls.Button;
import mx.controls.TextInput;

Also to address other comments, doesn't "actionscript only" just mean no mxml and .mxml files? It's still a .as files only.


Haven't done any Flash coding for a while, but I seem to remember that all of the fl. Your Flex Builder can't see those two classes. Scrolling through the language reference there is no fl package, so I would say you need to change those two classes to something that exists in Flex like flash.display.Sprite (with buttonMode on) and flash.text.TextField

http://livedocs.adobe.com/flex/3/langref/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜