- Original Message -
From: malik_robinson [EMAIL PROTECTED]
To: flexcoders@yahoogroups.com
Sent: Friday, July 28, 2006 12:18 AM
Subject: [flexcoders] Can someone explain this code, its related to
Cairngorm?
Hi,
I am trying to understand the ModelLocator and how Cairngorm works.
I have been reading, but I think I need some additional information
on the code below if possible.
1. What is the difference between Public function and Public Static
function. I assume Public functions can be called from anywhere in
the application. But what about the public static
When something is declared as static there can only be one class instance.
There's no need to instantiate the class as an object in order to call a
static function or access a public static member.
2. Any info about the ModelLocator would be helpful.
[Bindable]
public class ModelLocator implements
com.adobe.cairngorm.model.ModelLocator
This is the interface the class implements
{
private static var
modelLocator:code.model.ModelLocator;
A class (static) variable for use by a class (static) function.
public static function getInstance() :
code.model.ModelLocator
Call this to get the instance of the ModelLocator.
{
if ( modelLocator == null )
If the ModelLocator has never been instantiated then create it, otherwise
return it.
This inforces that only one ModelLocator instance exists - a singleton.
modelLocator = new
code.model.ModelLocator();
return modelLocator;
}
//---
--
public function ModelLocator()
This is the Class constructor. If this is called and the reference to the
ModelLocator exists then something has gone wrong - the constructor is
called by the static function above. If the constructor is called twice
there's a problem - there can only be one ModelLocator.
{
if ( code.model.ModelLocator.modelLocator !=
null )
throw new Error( Only one
ModelLocator instance should be instantiated );
}
//---
--
public function initialise() : void
{
}
Thanks,
Malik
Hope that helps
Paul
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/