Binding Data in a Flex

Leave a comment

About binding data in a flex..

Singleton pattern in flex

Leave a comment

Flex 3 does not support private or protected constructors preventing common implementation techniques for the singleton pattern. By using a check in the constructor & static method to instantiate the class , it is possible to ensure only a single instance of a class is created.

As constructor is not public we should restrict the user to invoke the class.

Sample:-

package com.blog.preenu
{
public class SingletonClass
{
private static var s_singletonClass : SingletonClass;

public function SingletonClass(singletonEnforcer:SingletonEnforcer)
{
if ( singletonEnforcer == null )
{
throw new Error( “Only one SingletonClass instance should be instantiated” );
}
}

public static function getInstance() : SingletonClass
{
if(s_singletonClass == null)
{
s_singletonClass = new SingletonClass(new SingletonEnforcer());
}

return s_singletonClass;
}
}

}
class SingletonEnforcer {

}

what is difference between argument and parameter ?

Leave a comment

  • While defining the method , variable passed in the method is called parameter.
  • while using those method, value passed to those variable is called as arguments.