A singleton class will have a static getInstance() method.

 

Anywhere you need to access members of the singleton, call that method.
Just import the class, do not use the normal instantiation procedures,
like new, or using an mxml tag.

import mypackage.MyModel;

[Bindable]private var _myModel:MyModel; //optional var reference

 

Private function init(): void

  _myModel = MyModel.getInstance();

  Alert.show(_myModel.myFunction())

 

<mx:Text ...text="{_myModel.myBindablePublicProperty}"

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Scott
Sent: Wednesday, July 16, 2008 12:42 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Anyone have a good resource on singletons?

 

I'm trying to find information on using singletons in AS3/Flex.  I've
got an .AS file set up but I'm having issues calling the data/functions
within that function in other classes.  Does anyone have a good resource
on the web for creating and using singletons?

 

Thanks!

 

Reply via email to