Singleton in Flex

Singleton in Flex

hi.....

please tell me about
How can you implement Singleton in Flex Application?
please give me the procedure so i can implement.......

Thanks

View Answers

October 19, 2010 at 5:32 PM

Ans:

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object. If you create the class as a singleton then no way to create more than one instance. But, you can get that single instance in any number of classes. So all the classes will share the same properties and behaviours of that singleton object.

For example:

<SettingsDialog xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>

        private static var singleton:SettingDialog;

        public static function getInstance():SettingsDialog
        {
            if ( SettingsDialog.singleton )
            {
                return SettingsDialog.singleton;
            }else{
                SettingsDialog.singleton = new SettingsDialog();
                return SettingsDialog.singleton;
            }            
        }

    </mx:Script>

    <mx:TextInput id="name" width="100">
    <mx:TextInput id="age" width="100">
    <mx:TextInput id="rank" width="100">
    <mx:TextInput id="serial" width="100">
    <mx:ColorPicker id="uiColor" >

<SettingsDialog>


Usage:
//call popupmanager with getInstance
mx.managers.PopUpManager.addPopUp( SettingsDialog.getInstance() , basePanel , true );









Related Tutorials/Questions & Answers:
Singleton in Flex
Singleton in Flex  hi..... please tell me about How can you implement Singleton in Flex Application? please give me the procedure so i can implement....... Thanks
singleton class
singleton class  What is singleton class
Advertisements
Java singleton
Java singleton  What is singleton
singleton
singleton program
singleton program  import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; public class Emp{ public
Singleton & Threadsafe in struts - Struts
Singleton & Threadsafe in struts  Hi, How to implement singleton and threadsafe in struts . same in jsp and servlet. Thanks in advance
singleton pattern - Java Beginners
singleton pattern  how i use singleton pattern in my web aplication project.plz give an example.its urgent
ModuleNotFoundError: No module named 'singleton'
ModuleNotFoundError: No module named 'singleton'  Hi, My Python... 'singleton' How to remove the ModuleNotFoundError: No module named 'singleton' error? Thanks   Hi, In your python environment you
Java Singleton Pattern
In this section, you will learn about singleton pattern in Java
What is singleton? - Java Beginners
What is singleton?   Hi, I want to know more about the singleton in Java. Please explain me what is singleton in Java? Give me example of Singleton class. Thanks   hello, Singleton is a concept in which you
singleton - Java Interview Questions
singleton  what is singleton class.give one example of implementation of singleton class?  hi friend, import java.io.*; public class SingletonExam implements Serializable { public static SingletonExam single
Is Singleton Default in Struts - Struts
Is Singleton Default in Struts   Hi Friend, Is Singleton default in Struts ,or should we force any technique Thanks Prakash  Hi friend, Use of singletons is normally
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
Flex - Framework
Flex  database conectivity in flex
ModuleNotFoundError: No module named 'nocycle-singleton'
ModuleNotFoundError: No module named 'nocycle-singleton'  Hi, My... named 'nocycle-singleton' How to remove the ModuleNotFoundError: No module named 'nocycle-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My... named 'python-singleton' How to remove the ModuleNotFoundError: No module named 'python-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'singleton-admin'
ModuleNotFoundError: No module named 'singleton-admin'  Hi, My... named 'singleton-admin' How to remove the ModuleNotFoundError: No module named 'singleton-admin' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'jupyter-singleton'
ModuleNotFoundError: No module named 'jupyter-singleton'  Hi, My... named 'jupyter-singleton' How to remove the ModuleNotFoundError: No module named 'jupyter-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'm-singleton'
ModuleNotFoundError: No module named 'm-singleton'  Hi, My Python... 'm-singleton' How to remove the ModuleNotFoundError: No module named 'm-singleton' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'pmc-singleton'
ModuleNotFoundError: No module named 'pmc-singleton'  Hi, My... 'pmc-singleton' How to remove the ModuleNotFoundError: No module named 'pmc-singleton' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'python-singleton'
ModuleNotFoundError: No module named 'python-singleton'  Hi, My... named 'python-singleton' How to remove the ModuleNotFoundError: No module named 'python-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'rigger_singleton'
ModuleNotFoundError: No module named 'rigger_singleton'  Hi, My... named 'rigger_singleton' How to remove the ModuleNotFoundError: No module named 'rigger_singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'singleton-decorator'
ModuleNotFoundError: No module named 'singleton-decorator'  Hi, My... named 'singleton-decorator' How to remove the ModuleNotFoundError: No module named 'singleton-decorator' error? Thanks   Hi
ModuleNotFoundError: No module named 'singleton_factory'
ModuleNotFoundError: No module named 'singleton_factory'  Hi, My... named 'singleton_factory' How to remove the ModuleNotFoundError: No module named 'singleton_factory' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'celery-singleton'
ModuleNotFoundError: No module named 'celery-singleton'  Hi, My... named 'celery-singleton' How to remove the ModuleNotFoundError: No module named 'celery-singleton' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-singleton'
ModuleNotFoundError: No module named 'django-singleton'  Hi, My... named 'django-singleton' How to remove the ModuleNotFoundError: No module named 'django-singleton' error? Thanks   Hi, In your
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider   You can visit the following link for detailed tutorial on the topic. May this will be helpful to you. http://www.roseindia.net/flex/flex-combo-box.shtml
Flex and Java
Flex and Java  hi..... Please give similiarities between Java and Flex. Thanks
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Flex basic
Flex basic  Hi...... please just tell me about Can we run Flex applications in MAC? Thanks
J2EE Singleton Pattern - Design Pattern Tutorials
J2EE Singleton Pattern Singleton Design Pattern This design pattern governs... only one instance of object is required. The Constructor in a Singleton class is private and a public static method is used to get the Object of the Singleton
Flex and Java
Flex and Java  Hi...... Give the name of Collection which can be mapped to java and Flex and vice-versa. please give the name of all collections which is used in flex and java.. Thanks
Flex and Java
Flex and Java  Hi.... What are the config files that are used to connect Java and Flex applications? Please provide the solution of this prob so i connect java and flex.... Thanks
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
singleton class in struts - Java Beginners
singleton class in struts  hi, This balakrishna, I want to retrive data from database on first hit to home page in struts frame work
Flex Updates
Flex Updates  Sir, first Thanks For Good Resource for Every One! i am New to Flex... but,in Current Updates Tell Us Flex Becomes To down!(Sorry To say).. May I know Future groom & Advantage of Flex Over Other Web
Flex as a Service
Flex as a Service  Hi....... just tell me about How do I run Flex as a service? please give me an example if possible Thanks  Ans: Flex is not a server. It is the pert of your web application. you can use
Flex application
Flex application  Hi..... What kind of applications you can create from flex? please give the name of these applications....... Thanks
Flex basic
Flex basic  Hi.... can you tell me about Is Flex OS specific or operating system independent? please give the description about it....... Thanks
Flex basic
Flex basic  Hi.... I want to know Do we need any plugins to run Flex applications? please give the ans ASAP....... Thanks
Flex basic
Flex basic  Hi.......... I want to know about What is localToGlobal and globalToLocal in flex? please give me ans ASAP..... Thanks
Flex difference
Flex difference  Hi.... please tell me about What is the difference between Flex 2.0 and Flex 3.0? Thanks  Ans: There are some advantages of Flex3.0 over Flex 2.0 they are following: 1. Faster compilation time
How singleton in struts - Java Interview Questions
How singleton in struts  Hi, How to implement singleton and threadsafe in struts . same in jsp and servlet. Thanks Prakash
What is difference between singleton and prototype bean?
What is difference between singleton and prototype bean?  Hi, What is difference between singleton and prototype bean? Thanks
What is an efficient way to implement a singleton pattern in Java?
What is an efficient way to implement a singleton pattern in Java?  What is an efficient way to implement a singleton pattern in Java
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
Singleton class
Singleton class       Singleton Design Pattern: The singleton design pattern allows to have one...:  Singleton pattern provides  -- access only to the unique instances
Flex basic
Flex basic  Hi.... Can flex application communicate with each other on the client? please give me the answer ASAP.....ADS_TO_REPLACE_1 Thanks   Ans: See the LocalConnection API In the flex documentation. ADS

Ads