How do I get external classes to work in AS3? Sample included.
I'm trying to make this work, and something basic must be missing. Its straight out of the Adobe help file example.
CS4, Actionscript 3
Here's what I'm doing:
1. create an .as file and name it "HelloWorldExample"
2. Put the script below in it and save it.
3.create a new .fla file and save it to the same directory.
4.in that .fla file, put "HelloWorldExample" in the Document properties Class field
5. Save it and run the movie.
I get a white screen. Nothing. I've tried a few other examples as well, but I haven't been able to get ANY external .as files to run. This is the simplest one.
Do I need to import them or call them in some way other than step 4?
Did I miss something?
package
{
import flash.text.engine.*;
import flash.display.Sprite;
public class HelloWorldExample extends Sprite
{
public function HelloWorldExample()
{
var str = "Hello World! This is Flash Text Engine!";
var format:ElementFormat = new ElementFormat();
var textElement:TextElement = new TextElement(str, format);
var textBlock:TextBlock = new TextBlock();
textBlock.content = textElement;
var textLine1:TextLine = textBlock.createTextLine(null, 300);
addChild(textLine1);
textLine1.x = 30;
textLine1.y = 30;
}
}
}
