Hello!
I'm new to as3 and although I'm getting my head around it I'm struggling with one problem. I've been working through lots of tutorials and am able to build classes that don't error but also don't put anything on the stage.
I have Starter_1.as file stored in a folder called com...this is the script for that file:
Code:
package com {
import flash.display.Sprite;
import flash.text.TextField;
public class Starter_1 extends Sprite {
private var tField:TextField;
public function Starter_1 () {
myTest();
}
private function myTest():void {
tField = new TextField();
tField.autoSize = "left";
tField.background = true;
tField.border = true;
tField.x = 20;
tField.y = 75;
tField.text = "Hello You, what is your name?";
addChild(tField);
}
}
}
this is a simple tutorial I worked through.
From what I can see the problem is because the addChild(tField) is not referencing the stage in anyway because the script is in an external .as file and not on the timeline (good coding practice I read somewhere?)
I use this on the timeline to try put the text field on the stage:
Code:
import com.Starter_1;
var f1:Starter_1 = new Starter_1();
How do I get this working?
Thanks for your help