Building An AS3 Project Without MXML
Usually you'll find yourself using MXML to quickly build Flash applications. There are times, however, when you really just want to work with the underlying ActionScript and not use MXML at all. Here's how.
The best way to do this is to subclass the Sprite class. So you would create a class that looks something like the following:
package
{
import flash.display.Sprite;
class TestApp extends Sprite
{
}
}
Once you've done this, you can create new components (such as text fields, buttons etc.) and add those components to the display list by using addChild(). So your code would look something like this:
package
{
import flash.display.Sprite;
import flash.text.TextField;
class TestApp extends Sprite
{
public function TestApp()
{
var TestText:TextField;
TestText = new TextField();
TestText.x = 50;
TestText.y = 50;
TestText.text = "This is a test";
addChild(TestText);
}
}
}


0 comments:
Post a Comment