----- Original Message -----
From: "steve linabery" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Tuesday, September 30, 2008 7:09 PM
Subject: [Flashcoders] Shared variable scope between mxml and
ActionScriptclasses
Hello Flashcoders,
Let's say I have two files, myApp.mxml:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
applicationComplete="EntryClass.main()">
<mx:Panel>
<mx:VBox id="myChart" width="900" height="300" />
</mx:Panel>
</mx:Application>
and EntryClass.as:
package {
public class EntryClass {
public static function main():void {
myChart.graphics.drawRect(100,100,100,100);
}
}
}
Why does "mxmlc myApp.mxml" complain with this error message:
quote:
/path/to/EntryClass.as(4): col: 7 Error: Access of undefined
property myChart.
myChart.graphics.drawRect(100,100,100,100);
^
Because classes are self contained. There is no notion that any class can
access any variable outside the class unless there is a direct reference to
it via a static reference or a parameter. EntryClass has no default access
to the application.
You can probably do what you want by referring to
Application.application.myChart...
This is also best asked on flexcoders..
Paul
Any suggestions appreciated!
Thanks,
Steve
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders