class MyWidget {
 function myWidget(xmlFile) { // constructor
case problem in your code - myWidget needs to be MyWidget to be the constructor.

is there another pattern for doing this?
I'd declare xmlData as a property of the MyWidget class, so it will have scope throughout the class and use 'Delegate' to run init within your class scope rather than in the xmlData object scope.

Then you will have access to it in your init function without having to somehow pass it in, in the way you are attempting.

So adjusting your code as per my advice (Not tested)...

class MyWidget
{
 private var xmlData:XML;

 function MyWidget( xmlFile ) // constructor
 {
   xmlData = new XML();
   xmlData.load( xmlFile );
   xmlData.onLoad = mx.utils.Delegate.create( this, init );
 }
 function init( bSuccess ):Void
 {
   if( bSuccess )
   {
     // do layout stuff here
     // you have scope access to the loaded xmlData object
     // and scope of the rest of MyWidget
   }
 }
}


hth

Paul
--
[ http://www.creative-cognition.co.uk/ ]


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to