It sounds like you are trying to access the .text property before it has been instantiated.
Suppose you have an mxml file that looks like:
<?xml version="1.0" encoding="utf-8"?>
<test:LabelTester pageTitle="Label Test"
xmlns:test=".*"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:Label id="hallo" text="hallo"/>
</test:LabelTester>
and an application class called LabelTester that looks something like this:
public class LabelTester extends Application {
public var hallo:Label;
function LabelTester() {
this.traceText();
}
private function traceText():void {
var halloText:String = this.hallo.text;
trace(halloText);
}
}
Then you will get the runtime error that you describe.
But then change the constructor to this:
function LabelTester() {
// this.traceText();
this.addEventListener(FlexEvent.CREATION_COMPLETE, this.handleCreation);
}
and add:
private function handleCreation(creation:FlexEvent):void { this.traceText(); }
and if you run it in the debugger you should see the correct value in the console window.