How to implement a singleton model in a Flex project

After too much reading, I would use a singleton model in my Flex application to contain global variables.  What I can't determine, however, is how to do this.  Is there a good tutorial/example available who could guide me through this for a Flex project?

Thank you!

Put the variables you want to be globally available on the static singleton instance object:

Singleton.instance.var1 = "whatever";

Let me know if that helps...

Ben Edwards

Tags: Flex

Similar Questions

  • How to implement the observer model?

    Hello guys,.

    I have some problems with the implementation of the model of the observer. So I m making a good app and I put a meter change with volume.

    I have already designed counter and the volume is calculated.

    So I have a class called Application (is the main class) and this class have the application designer, makes the audio capture and calculate the volume.

    And I have the MeterMic class and in this class, I have the graphic meter where I send this graphic multimeter to the application via JPanel.

    In MeterMic I have the variable 'value' and this variable will make the changes in the bars of the counter and I want equal to the value of the volume of the application. I try referencing the Application object, but does not have the value of the volume.

    So, I want to implement the model of the observer.

    I need to observed the variable volume and the volume changes I want to send this change of variable value in MeterMic.

    My problem is: who is the observer and observed? And what I need to do to implement the model.

    My best,
    David

    DavidHenriques wrote:
    Thanks for the help guys. People really nice here in the forum.

    So be sure to mark this thread as a response.
    ~ and reward of points ofcause... ~.
    (o).

    Good bye
    DPT

  • How to implement the AutoComplete feature / autotype in Flex 3?

    In my application:

    User has entered a name-> name text box is sought in a xml file that is external-> other fields in the xml file are displayed.

    I want that as soon as the user starts typing the name, suggestions should see similar entries in the xml file. The user can then simply click on the correct name.

    Any help would be great.

    Thanks in advance.

    Kind regards

    POOJA

    This is the best Flex AutoComplete component I've seen.  I used to work with remote db sources (XML should be substantially the same).  I had to tweak it a bit, but much better to start from scratch.

    http://hillelcoren.com/Flex-AutoComplete/

  • How to implement the class Singleton cascading C++

    I tried to use the standard C++ to implement the Singleton class. It can be compiled well, there's always a mistake to link "Description Resource path location Type cannot declare the member function ' static globalsettings * globalsettings::instance() ' static linking [-fpermissive] problem of C/C++.

    Can anyone have a look of my source code to know what is the problem of it? Thank you.

    /*
     * globalsettings.h
     */
    
    #ifndef GLOBALSETTINGS_H_#define GLOBALSETTINGS_H_
    
    class Globalsettings {public:    Globalsettings();    virtual ~Globalsettings();
    
        int get_value();    void set_value(int v);
    
        static Globalsettings &instance();
    
    private:    int m_value;
    
        static Globalsettings *s_instance;};
    
    #endif
    

    Wrong with the CPP:

    /*
     * globalsettings.cpp
     *
     */
    
    #include "globalsettings.h"
    
    Globalsettings*  Globalsettings::s_instance = 0;
    
    Globalsettings::Globalsettings() {
        s_instance = 0;
        m_value = 0;
    }
    
    Globalsettings::~Globalsettings() {
        s_instance = 0;
    }
    
    static Globalsettings& Globalsettings::instance() {
        if (!s_instance)
          s_instance = new Globalsettings();
        return *s_instance;
    }
    
    int Globalsettings::get_value()
    {
        return m_value;
    }
    void Globalsettings::set_value(int v)
    {
        m_value = v;
    }
    

    CPP revised (it works)

    /*
     * globalsettings.cpp
     *
     */
    
    #include "globalsettings.h"
    
    Globalsettings*  Globalsettings::s_instance = 0;
    
    Globalsettings::Globalsettings() {
        s_instance = 0;
        m_value = 0;
    }
    
    Globalsettings::~Globalsettings() {
        s_instance = 0;
    }
    
    Globalsettings& Globalsettings::instance() {
        if (!s_instance)
          s_instance = new Globalsettings();
        return *s_instance;
    }
    
    int Globalsettings::get_value()
    {
        return m_value;
    }
    void Globalsettings::set_value(int v)
    {
        m_value = v;
    }
    

    UPD:

    1)

    static globalsettings *s_instance;
    

    This should be in the private section.

    2)

    static globalsettings *instance();
    

    This should be public, so the user can call.

    3)

    Delete 'static' keyword to the .cpp file.

    Even easier approach with late initialization:

    all in 1):

    static MyClass *sharedInstance();
    

    (2) in the .cpp:

    MyClass *MyClass::sharedInstance()
    {
      static MyClass instance;
      return &instance;
    }
    
  • How can implement you not with Tim Capsule and AirPort their simulation on the iMac?

    Hello

    How can implement you not with Time Capsule and AirPort their simulation on the iMac?

    I don't know what you're asking.

    AirPort Extreme is a wireless router.

    A Time Capsule airport is an AirPort Extreme with a built-in hard drive for data storage.

    An iMac is a Mac computer.

    An iMac is not a wireless router, so he is unable to perform the functions of a wireless router.

  • How we implemented personal signatures in Thunderbird?

    How we implemented personal signatures in Thunderbird?

    http://KB.mozillazine.org/Signatures_%28Thunderbird%29

  • How many slots for RAM, model HP 250 G5 (W4M85EA)?

    How many slots for RAM, model HP 250 G5 (W4M85EA)?  What is the maximum amount of RAM supported HP 250 G5 (W4M85EA)?

    @Frodo9911

    Two memory non-customer-accessible/extendable module slots

    Supports up to 16 GB of RAM

    Your manual here.

    http://h10032.www1.HP.com/CTG/manual/c05087748

    REO

  • How can I buy iphone model A1723 - free online contract? will be model a1723 works with GSM (AT SIM cards

    (1) how can I buy iphone model A1723 - free online contract?

    (2) A1723 model Will work with cards SIM GSM (AT & T etc.)?

    Yes, you can buy it SIM free online.

  • How can I know the model of my Satellite M100 series?

    just my last thought. How can I tell which model I use, it's satellite m100 series, but I still don't know what specific it is...

    Thanks for the help

    Hi Enrique

    It of very simple for this knowledge.
    At the bottom of the unit, you will find the label that provides all these useful information.
    You should also find the number start with the PSM.

    This number is important to identify your model of laptop for example
    to download driver.

  • How to implement point filters fixed for FPGA

    Hello!

    I am applying the bandpass filter Butterworth for FPGA.

    I managed to develop filters of fixed point that suits my needs, but I don't know how to implement on a table in a project after the FPGA code generation. I tried to understand it in the examples, but I was not very successful.

    My time to finish what runs, any help would be really appreciated...

    Any suggestions?... some examples?

    Thanks in advance

    I've already done that and solved the problem.

    In any case thank you and have a nice day

    Ljubica

  • How to implement the reading of data from a matte file on a cRIO?

    Hi all!

    I'm still not sure, it is plausible, but I'll ask rather before you begin complicating. So far, I found no useful information on reading in the data to a device of RT from a file (type of a simulation test - data is simulated).

    I have the MatLab plugin that allows the storage of data read a MAT file, which has a number of columns that represent the different signals and lines representing the samples at a time (depending on the time of the sample - sample every time has its own line of signal data).

    I have no idea how to implement this at cRIO.

    The idea is:

    I have some algorithms running on the controller of RIO in a timed loop. As the entries of these algorithms I need to access each of the values of columns in the row, which is the time of the sample (sort of a time series - without written actual times).

    I am fairly new to RT and LV development, so any help would be appreciated.

    Thank you

    Luka

    Dear Luka!

    I think the reading of all the samples in a single channel is exactly what you need here, because reading the files may take some time and is not deterministic, so it is best to read all the data in memory (or if this is not feasible due to problems of size, fairly large pieces may be sufficient). The table read can be provided and then in the loop simulating outings, something like this:

    I used here separate channels so it's more graphic, but you can build all the channels in a 2D array and array index corresponding to the samples fom 1 who. You can also use for loops with indexing as tunnels are setup and then you won't need the index functions and the number of iterations is also set automatically, but you have to take care of synchronization settings.

    Best regards:

    Andrew Valko

    National Instruments

  • How to implement the wafer map using LabVIEW?

    Hello LabVIEW Masters!

    I have a project which includes control and searching for information on a PROBER. One of the difficulties I have now is how to implement a WAFER card using LabVIEW. According to the requirements of my client, the element of pads varies between 6 k and 23 k. I guess that do everything (a = a ctl/indicator led) will be a hell of a task, especially on how to effectively manipulate each elements. Does anyone have a better idea on the way whose that?

    Please, I seriously need your help...

    Thank you and best regards,

    Dennis DG

    Hi Dennis,

    This wafer GerdW post card appears to me as a sort of histogram (for example http://www.ni.com/white-paper/4158/en#toc3);

    Altenbach post well this example that shows how to use a plot of intensity to create a 2d histogram:

    http://forums.NI.com/T5/LabVIEW/overlay-plots-as-intensity-graph/m-p/211222#M119248

    Learn how it works and try to adapt it to your specific task.

    Alex

  • How to implement Canopen on FPGA to run the engine using NOR-9881?

    Dear,

    Your support will be highly appreciated,

    There is only one available for NOR-9881 example.
     
    Please note that the following materials were properly connected:
    cRIO-9024, cRIO-9113, OR-9881 and motor Nanotec (SMCI36 against L2818L0604-T5X5), the following
    sites Web shows the engine Nanotec in details:
     
    http://us.Nanotec.com/products/660-L28-linear-actuators-with-trapezoid-spindle/
     
    http://us.Nanotec.com/products/1041-SMCI36-stepper-motor-and-BLDC-motor-position ing-control /
     
    The main problem is how to configure the inputs and outputs, where, in most examples, the entry and exit have been automatically
    configured.
     
    the following three examples and I wonder how to start:

    1 - example Nanotec: dependent VISA controls for data transfer
     
    http://us.Nanotec.com/support/application-notes/LabVIEW-example/
     
    2 - reference example CANopen for series C OR - 9853 Module CAN:
    the NOR-9853 has default Can0 which was used in the code

    http://zone.NI.com/DevZone/CDA/EPD/p/ID/6093
     
    3 - from finder labView example: search for 9881 then choose
    NOR - CANopen_cRIO.lvproj, which depended on SDO orders for transfer orders
     
    The attached picture shows that NEITHER-9881 can be seen, after compilation and
    loading the bitfile FPGA.
     
    Please, please advice me:
    1. how to start?
    2. how to create variables of entry for NI9881?
    3. how to implement CANopen mode FPGA? where there is no CANopen palette.

    Thanks in advance and

    Hello!

    From my understanding, the 9881 can be treated from the FPGA, but only from the application of the RT. I think that the point 3 of your post examples of the use of the module fine.

    Kind regards

    Georg

  • How to connect my laptop model n °-pcg-7d1m to sony hdtv 32 "

    Hello

    How to connect my laptop model n °-pcg-7d1m to sony hdtv 32 "

    http://Windows.Microsoft.com/en-in/Windows-Vista/connect-your-computer-to-a-TV

  • How to implement interfaces or inheritance in LabVIEW?

    Hi all

    I try to implement oriented OBJECT in my LabVIEW code and require heritage or just an interface (such as might be required in java).  I have a good knowledge of OOP is just how do me in LabVIEW, I'm curious.

    I'll try to stick with my own example for now, so that someone is able to tell me exactly how to implement this.

    in any case, I have two different DMM and each come with their own GPIB commands to get the measures and set the measurement configurations.  This seems to be a perfect example to learn how to use inheritance.  I figured out how to make a class for each DMM but was curious as to how I might be able to create a parent class for each of them because they both require the same fields in their configuration (AC/DC, Measurment Type, rank, address VISA).  I think that I could create a parent class with these fields, then the methods of use of these fields and have then child classes inherit fields and override the methods of the parent class so that depending on what the user selected DMM, it would be able to use the correct class to issue the right GPIB commands.

    If anyone can point me to a good example or explain how this could be implemented in labview that would be super.  I'm also browsing the forums LVOOP to LavaG trying to figure this out, thanks!

    Brent

    Brent,

    LabVIEW help contains a lot of detailed information on the use of classes.  I recommend reading through it, before we begin with OOP in LabVIEW.  In the content of the Help window tab, search for "Fundamentals > LabVIEW Object - Oriented Programming > How - to's»  There is an article entitled 'change the legacy of a LabVIEW class' that should be what you're looking for.

    Chris M

Maybe you are looking for