I have two mxml files in a flex project: But when I trace a.cBtn, it is null. Why should it be?
test.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="runIt()">
<mx:Script>
<![CDATA[
public function runIt():void
{
var a:abc = new abc();
trace(a.cBtn);//a.cBtn is null here
}
]]>
</mx:Script>
</mx:Application>
And, abc.mxml :
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Button x="108" y="73" label="Button" id="cBtn"/>
</mx:Canvas>