views:

52

answers:

3

Hi guys.. I am trying to build a pure as3 project 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!

+1  A: 

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/

Matti
+1  A: 

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

Wade
Yeah, but that breaks his goal of creating a pure actionscript project since the mx stuff is part of the flex framework :)
Wade Mueller
+1  A: 

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.

Crusader