Sharing variables between mxml files

I have two mxml files...

Say file1.mxml and file2.mxml

I have a class class1 in the file 'action_script.as '.

Problem is, I have an obj_class1 of the object of class class1 in file1.mxml. I want to use the same obj_class1 object, created in file1.mxml in file1.mxml.

I don't know how to share variables / cdata in the mxml files.

The cutting-edge solution for this is to use a singleton class. There are a lot of articles about it.

An example:

Create a class as follows:

This class has a getInstance method that returns an instance of the GlobalVariables class (or any name you choose)

By calling this method, you are sure that there is only one instance of this class your application. By adding the properties of this class, you can share anywhere.

package myPackage
{
   
[Bindable]
public class GlobalVariables
{
           
private static var _instance:GlobalVariables;
       
       
       
public void GlobalVariables()
{
}
       
Public Shared function getInstance (): GlobalVariables
{
If (GlobalVariables._instance is nothing)
{
GlobalVariables._instance = new GlobalVariables();
}
Return GlobalVariables._instance;
}
       
Public Shared function deleteInstance (): void
{
If (GlobalVariables._instance! = null)
{
GlobalVariables._instance = null;
}
}
       
PROPERTIES
       
       
myGlobalVar
private var _myGlobalVar:String;
public function get myGlobalVar (): String
{
Return _myGlobalVar;
}
public function set myGlobalVar(value:String):void
{
_myGlobalVar = value;
}
       
       
}
}

Now, how to store and retrieve these properties:

Store:

GlobalVariables.getInstance (.myGlobalVar) = "the value of this property."

Recover:

MyLabel.set_Text = GlobalVariables.getInstance () .myGlobalVar;

It's really very simple. Just adapt to this design model and you'll be a happier developer in the future

Dany

Tags: Flex

Similar Questions

  • Shared variable between 2 LabVIEW executables via the network

    Hello, I need to create a number of network shared variables by two (built with LabVIEW 8.6) executables running on two different computers on a local network. The library to invoke node returns an error when you use a different IP than localhost. even more, it is not clear to me what exactly I have to do (what executable deploys the library, on which targets, activate the link or not, so on...). Thanks for any help, if you have already managed to make this communication works properly...

    Thanks for the replies. I've found the last two documents, but the first one is the most interesting: if I can't put the sources of two applications in a single project, I will move to another solution (data as suggested by Mike sockets or TCP). The two original projects are larger, and their merger would lead to such a huge thing!

  • use a hard file as a shared disk between two vm

    Hi guys,.

    I wanted to know if there is a possible way to create a hard file as a shared disk between two virtual machines.

    That's my idea:

    I want to create a mscluster between two vm one before I need to a shared disk - I don't want to use the external storage, so I thought that maybe there is a way to use a file hard like a disk storage shared "external".

    Is it possible to do this? If there is, I enjoy an explanation how to do that.

    Thank you very much

    Martin.

    Take a look at the cluster configuration guide - http://www.vmware.com/pdf/vsphere4/r40/vsp_40_mscs.pdf.

    Dave

    VMware communities user moderator

    New book in town - Start Guide quick vSphere -http://www.yellow-bricks.com/2009/08/12/new-book-in-town-vsphere-quick-start-guide/.

    You have a system or a PCI with VMDirectPath?  Submit your specifications to the unofficial VMDirectPath HCL - http://www.vm-help.com/forum/viewforum.php?f=21.

  • Flex sharing functions between the functions of mxml

    Problem is I want to perform a function of a different mxml file.
    Possible, but something stupid, if somone can put me on the way...

    The solution is the use of parentDocument.
    ------------------------------------------------------------------------------------------ -------------------------------
    MXML that calls the function:
    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Canvas xmlns:mx = ' http://www.adobe.com/2006/mxml " width ="400"height ="300">
    < mx:Form >
    < mx:FormItem label = "Search" direction = "horizontal" >
    "" < mx:TextInput id = change "search" = " parentDocument. filterDemo()" / >
    "" < mx:Button label = click "Clear search" = " parentDocument. clearSearch()" / >
    < / mx:FormItem >
    < / mx:Form >
    < mx:DataGrid dataProvider = "{dataList}" width = "400" height = "400" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Name" dataField = "name" / >
    < mx:DataGridColumn headerText = "City" dataField = "City" / >
    < / mx:columns >
    < / mx:DataGrid >
    < / mx:Canvas >
    -------------------------------------------------------------------------------------
    a page that stores the function:

    <? XML version = "1.0" encoding = "utf-8"? >
    "" < mx:Application xmlns:mx = ' http://www.adobe.com/2006/mxml ' layout = "vertical" xmlns:comp = "components.*" creationComplete = "initData ()" >
    < mx:Script >
    <! [CDATA]
    Import mx.collections.ArrayCollection;

    [Bindable]
    private var dataList: ArrayCollection collection;

    private void initData (): void {}
    dataList = new ArrayCollection([)
    {name: 'Kennedy Memorial hospitals/UMC Stratford', city plan: 'Stratford'},
    {name: 'Kennedy Memorial hospitals/UMC Washington Twp', city plan: "Turnersville"},
    {name: "Kessler Memorial Hospital" in the city: "Hammonton"},
    {name: "Saint reported hospital/Sussex', city plan: 'Sussex'"},
    ])
    }

    public function filterDemo (): void {}
    dataList.filterFunction = searchDemo;
    dataList.refresh ();
    }

    private void searchDemo(item:Object):Boolean {}
    var isMatch:Boolean = false
    var tevergelijken:String = weergave.search.text.toLowerCase ();
    If (Item.Name.toLowerCase (). Search (tevergelijken)! = -1) {}
    isMatch = true
    }
    return isMatch;
    }

    private void method clearSearch (): void {}
    dataList.filterFunction = null;
    dataList.refresh ();
    COMP:Weergave. Search.Text = ";
    }
    []] >
    < / mx:Script >
    < mx:ViewStack id = "bookPages' resizeToContent ="true"x ="118"y ="185">
    < comp: weergave height = "50%" width = "50%" label = "Weergave" id = "weergave" / >
    < / mx:ViewStack >
    < / mx:Application >

    Problem is I want to perform a function of a different mxml file.
    Possible, but something stupid, if somone can put me on the way...

    The solution is the use of parentDocument.
    ------------------------------------------------------------------------------------------ -------------------------------
    MXML that calls the function:

    http://www.Adobe.com/2006/mxml"width ="400"height ="300">













    -------------------------------------------------------------------------------------
    a page that stores the function:


    http://www.Adobe.com/2006/mxml"layout ="vertical"xmlns:comp ="components.*"creationComplete =" initData () ">"

    Import mx.collections.ArrayCollection;

    [Bindable]
    private var dataList: ArrayCollection collection;

    private void initData (): void {}
    dataList = new ArrayCollection([)
    {name: 'Kennedy Memorial hospitals/UMC Stratford', city plan: 'Stratford'},
    {name: 'Kennedy Memorial hospitals/UMC Washington Twp', city plan: "Turnersville"},
    {name: "Kessler Memorial Hospital" in the city: "Hammonton"},
    {name: "Saint reported hospital/Sussex', city plan: 'Sussex'"},
    ])
    }

    public function filterDemo (): void {}
    dataList.filterFunction = searchDemo;
    dataList.refresh ();
    }

    private void searchDemo(item:Object):Boolean {}
    var isMatch:Boolean = false
    var tevergelijken:String = weergave.search.text.toLowerCase ();
    If (Item.Name.toLowerCase (). Search (tevergelijken)! = -1) {}
    isMatch = true
    }
    return isMatch;
    }

    private void method clearSearch (): void {}
    dataList.filterFunction = null;
    dataList.refresh ();
    COMP:Weergave. Search.Text = ";
    }
    ]]>




  • Shared variable RT FIFO (multi element) - read both

    Hi all!

    I'm trying to collect data from analog inputs on my cRIO with a time step of 1 second. For this I use a timed loop and a variable shared with RT FIFO active (several table of doubles). Along with the timed loop, I also use a while loop that is significantly slower (lets say 10 sec period) who must read all the berries stored in the FIFO and write it in a .txt file (everything is run locally on target RT). Is it possible to empty the shared variable RT FIFO at the same time, and if not how can I get a number of tables that are currently stored in a shared variable?

    What is the difference between one created using the palette of FIFO of Real-Time/RT and RT FIFO created by a shared variable? I prefer to use the shared variable instead of Real-Time/RT FIFO allowing also time stamp.

    Best regards

    Marko.

    Marko,

    We recommend that the nondeterministic loop run faster than your deterministic loop and remove samples when they become available. If you don't want to do this, you can simply place your RT FIFO loop for the value to perform 10 iterations and then put that in your loop. For more information about the differences between the RT FIFO and Variables shared with RT FIFO active, please see pages 32 to 35 of the CompactRIO Developers Guide link below.

    http://www.NI.com/PDF/products/us/fullcriodevguide.PDF

    I hope this helps!

  • It is possible to switch between mode 'file separate globals' to 'share the same globals file mode' during the test run.

    Hi all

    It is possible to switch between mode 'file separate globals' to 'share the same globals file mode' during the test run.

    Or there is another option to use variables separated and shared at the same time for 2 parallel Sockets (ParallelModel.seq).

    Thank you

    Thank you

    I think it's useful!

  • Question about different types of shared variables

    Hello

    I'm trying to use shared variables to pass data between several screws but I do not understand the types. Like, what is the difference between unique process and publish shared network variable?  Also between absolute and relative target.

    I've been thorugh all the post, PDF files, and links. But everything seems vague, at least for me. Anyone can share ideas in a simple way? I mean the absolute basics. What I'm trying to do is move some data to host VI to myRIO VI.

    (I won't use the global variable because I might need to transfer data over the network in the future.)

    Thank you.

    Absolute run on the target in which you created the shared variable.  So if you created on your myRIO, then everyone should point towards the myRIO to access this variable.

    The target always connects to the variable on the target your VI is running.  Target-parent can only connect to the variables on the same target.  So if you put the variable on the myRIO, your host will not be able to access.

    So in conclusion: you want a variable absolute shared on the network.

  • shared variables does not

    Hello, I'm writing because I'm having a problem with the use of shared variables. I am doing a project for College and I use the DSC for his shared variable function. The problem im having is that shared variables do connect it no more. I followed a document "Getting started with LabVIEW Datalogging and supervisory Control Module" and managed to build an IOServer and shared variables in accordance with the document to deploy successfully. It was a few days ago. Today when I opened the project file even shared variables would not connect. IM also having the same problem with other projects that I made over the weekend that worked, but do not work now.

    Does anyone else have this problem?

    Hi Justin,

    I am pleased to see that you are able to work with your LabVIEW installation now. 0x0000002A error message reported only in what concerns the communication between the shared variable engine and part mutual FUND of the DSC module is blocked.  This was usually resolved by inspecting the security settings Windows for the firewall, as discussed earlier.

    As for your second question, it might be better to start a new post.  However, please specify what files you want to move and what wisely win. Where would you like the directory that is to be held and for what benefits?  If you are hoping to achieve a gain of performance or similar, there may be different approaches other than moving files.

    Kind regards

  • SQL and shared Variable communication failure when you run an .exe application

    Salvation OR engineers,

    I'm faced with a problem. I have already tried almost everything under my bottom to solve, but I just couldn't get over it.

    I have a VI on my PC accessing a SQL database via the connection string and some share of variables in a server. Both shared variables and the SQL database are on the same server. There is a firewall between this server and my PC and the server is located in a DMZ environment.

    Design Labview environment, everything works fine. Even when I run the .exe on this computer file, everything works fine. But, when I created an application and install it on another computer, it just doesn't work.

    I'm using Labview 2013.

    Someone of you can help me with this bug?

    Thanks in advance!

    Hello world

    Back to share with you the solution:

    The problem was with the "SQL Native Client". Windows 7 doesn't have it as a default installation, if the application could not find the OLE DB provider for ODBC drivers. After installation, the connection has been established.

    As the server was within a demilitarized zone, I had to open some specific ports as follows:

    UDP/1434

    TCP / / 2343,49163

    59110-59115

    In fact, I have not experienced problems with the OAS. The error was generated when you try to connect to the database and sent to the rest of the code through the cluster of the error.

    Thanks for the support!

    Best regards to everyone.

    Luiz

  • Passing variables between LabVIEW and TestStand

    Hello

    I'm just learning how to use TestStand and although there are a multitude of resources available, I always find me at a loss on how to pass variables between TS and LV, leaving me to think that there is one fundamental thing that I'm missing which is likely, given that I have a weeks experience with LabVIEW and a days of experience with TestStand.

    I took a glance to the example of 'Clusters' to the Code Modules in TestStand examples (I use TS 2016 if it matters) because I thought it would be quite ideal for what I hope. In this case, I hope to be able to pass a string (a file path) to LabVIEW and VI power take this string and use it as part of an order for the Exec.VI system.  Then, I would be able to pass strings back to TestStand to show the user if an error occurred, but I thought I should get the first part of work.

    I guess my question is what do I have to wait to see in clusters to the example of the Modules of Code? The Watch window displays all defined variables premise on which has the ContainerOut in the Variables pane, but I don't see any kind of update on facades (VI1.vi and VI2.vi) LabVIEW code. Should I be?

    I looked at a few other discussions of the forum here and here, as well as the document of the basis of knowledge here, but could not recreate their solutions. It seems that the connector pane would be a viable way to go, but I'm not sure on how we create and use effectively. According to this document , it makes it seem like it should be simple enough to makes these terminals, but I am still missing a key step. I was able to follow all the steps on the knowledge base document and run the sequence, but then had no idea if it worked or not; I have the report show me the values of the variables I put, but I have no idea whether or not he actually did anything with the LabVIEW VI, or how I could see that.

    Please let me know if you need further information or clarifaction everything I ask.

    Thank you for your time,
    JColvin

    Digilent, a company of National Instruments

    If you want to enter values, you must create a vi for instance dialog box

    The OK button will allow new values to pass to the output terminals.

    A Cancel button will pass just the original through the output values without alteration. The VI will close when either the OK button or cancel were pressed.

    Concerning

    Ray

  • published RT cRIO-9030 with network-a project of shared variables cannot communicate with host VI when compiled and deployed as executable startup.

    I have a project including a VI RT running on a cRIO-9030 and a host VI running on a desktop computer.  The two programs communicate via shared variables that are hosted on the cRIO.  As shows, when I run the screw of the project, everything works as expected.  When I compile the RT VI in a start-up executable can deploy for the cRIO, as well as the libraries of shared variables (the record of support in the build specification-oriented), I am unable to connect to the executable running in real time.

    I have 'Disable Autodeploy Variables' checked on the cRIO target, if I no longer get the prompt to stop the currently running application to deploy the variables.  The host VI opens and appears to run, but has no connection with shared variables (data does not update).  Compilation of the host VI as an executable file and it works outside the project result in the same behavior.

    I read some relevant posts / knowledge base articles related to this problem, but still can't seem to find a way around it.  I note a number of articles on the series in double bond of variables, but this is in contradiction with my possible behavior for this system: I finally have a number of cRIO controllers identical all runnning the same executable RT and want to be able to have a single host VI which allows the user to select from a list of available controllers (using the screw system configuration) and extract the host name of the controller selected, that would be later used for programmatic addressing of the variables on the host of part VI.

    In any case, I want to start with the simple fact of being able to get that first controller running without an open connection to the RT VI project.  With the deployed executable start, I checked via programmed behavior of LED application of the RT and FPGA are running on the cRIO.  The problem, I think, has to do with shared variables, but I'm not sure where to go from here.  I want to connect to RT executable running from the VI to the host (in project) to verify that the compiled executable of RT works as expected and then the subsequently compile host VI in an executable that can be run from any desktop on the local subnet.

    Thoughts?

    It seems that the error has now been corrected.  There were three things, I changed: the file startup.aliases in the startup on the target directory (Home: / lvuser/natinst/bin) put in 'localhost' as an alias for the controller.  I changed it to the IP address of the controller.  Then, I got some features of IO files in my application RT relative paths using the path obtained by the 'current path VI' VI.  As this path changes according to the location / delivery system, I had to create a VI that has used the Application property: type with a case properly structure band / build railroads desired regardless of the runtime system data files.  This may have broke my RT request.  Finally, I got a property node in one of my RT SubVIs, who attempted to change an indicator in the Subvi, which is not taken care of in an RT compiled executable.  I can't do this for debugging purposes somewhere along the way, but in any case, I removed it, and after a recompilation and the deployment of the executable of RT, everything seems to work as expected today.  The host VI on the desktop can connect to the application of the RT project, and when it is compiled into an executable file, which also works.

  • Pass a reference to the shared variable

    I use two shared variables in a loop where I write one and read each other.  I need to repeat this loop 5 times, but each loop uses a different pair of shared variables.  These variables are shared between a vi on the computer and a cRio.

    It would be ideal to incorporate this loop into a Subvi where I can pass a reference to the two shared variables in and then read and write in threw these references.  Then I could just call this Subvi 5 times, instead of copying and pasting the loop 5 times.

    Is it possible that I can accomplish this?  I can't find an example that would achieve this.

    Thank you

    If I understand correctly, you can use the mode programmatic access to shared Variables and it would work.

    http://zone.NI.com/reference/en-XX/help/371361H-01/lvconcepts/sv_usingdynvarapi/

    http://zone.NI.com/reference/en-XX/help/371361G-01/lvconcepts/usingdynvarapi/

  • Embedded FPGA vi - network shared variable not updated

    Hello

    I work with an ethernet RIO 9149 of data acquisition. I use a hybrid programming mode.

    I have a very simple FPGA VI that I downloaded on the flash memory. I used the indicator led to show my VI runs once the power of the RIO. Everything is fine, except that my shared network variables are not updated in the DSM ("no known values" displayed). However when I run the FPGA VI of my laptop, only once then stop and close (with 'interactive execution'), then my shared variables are updated in the DSM.

    Any ideas why is this and how do I get the RIO update automatically shared variables without having to run the VI once?

    Thank you very much.

    Hello

    I did a few tests and research and discovered that it doesn't seem to be possible. It is important to note the difference between Network-Published static (NSPV) and Variables of e/s of Network-Published.

    The other are "user defined variable I/O" to communicate between FPGA and RT (RT absent on chassis Ethernet as the NI 9149) host. If these variables are checked to be published-network (in properties). They are accessible by VI running on the hosts of the same LabVIEW project, so you need to run a VI to access, as you mention. This is explained on the next page, Variable IO data custom FPGA of e/s (real-time Module or Module FPGA):

    https://zone.NI.com/reference/en-XX/help/371361H-01/lvioscanhelp/io_vars/#user_IOV

    I did find a way without a host (host RT or Windows PC) running a VI. If you have a cRIO with RT and NPSV host in the RT VI it is possible.

  • Weird shared Variable dialog box message

    I came across a strange in the dialog box behavior, while I created a new shared variable.

    That I was typing in the name, I kept see a warning will appear in the dialog box.  It would come and go as typed.  I realized that whenever I typed a space, and it is thus temporarily the last letter in the name SV, the warning popped up.  Type the next letter, the warning would leave.  You can see the space ending the name right before the cursor in the top image and name that ends with a normal character in the background image.

    Now, it is logical to me that ends a name shared with a space variable would be a bad practice and should be warned against.  But the warning never actually says that you cannot end with a space.  To be more precise, it says that you can not the slash code \s in the name of the variable.  Now I'm not really in the slash codes, but I'm in the spaces.  And they seem to work in variable name, just not if it is the last character very well.

    It just seems to be a disconnect between what says the warning, and what you can and can't do.

    Can you have spaces in the name SV?  From my experience, you can.

    In addition, in its LV 8.6 on a machine XP SP3.

    Thank you.  Please post the CAR ID # to the thread once you have it, then I'll put a link on the bug thread.

    Just to clarify, I see basically three questions.

    1. the error message is incorrect because spaces are allowed in the shared name of the variable, but the unclearly error that says they aren't.

    2. the spaces at the beginning or at the end of the shared variable, in my view, should not be allowed, but Ben could have an instance where he "backdoored" one in there.

    3. nuisance of user interface.  If spaces are not allowed at the end of the OAS, there is no need of an error message flashing on the screen that appears whenever you finish a word followed by a space before the next word begins.  The error message should really popup only once you click OK to save the variable.

  • Impossible to programmatically access a shared variable

    Hello

    I am attaching a file in project where I created 2 shared variables

    When I try to access it programmatically im getting this error "error-1967362038 occurred to read Variable in Untitled 1." "vi IAK_SHARED: (Hex 0x8ABC700A) not found."

    can someone tell me where im going wrong?

    Woof...

    found the solution

    has not deployed the library file containing the shared variable

    After you deploy the library file so I was able to programmatically access a shared variable

Maybe you are looking for

  • How to rotate the screen, my screen has suddenly gone upside down,

    My Dell notebook was hit and now the entire screen is upside down.  The mouse responds to this as having returned also well (scroll down to get to the top, etc.).  I know it's a Windows problem as the screen is round the right way when the computer i

  • How can I reset my password. I've forgotten the answer to my secret question.

    How can I reset my password when I forgot the answer to my secret question?

  • Replication files and vswp

    Hi - I'm trying to reduce the amount of replicated data get, I'm running out of bandwidth. I'm trying to understand if move the files from vswp to another not replicated lun will help. The memory isn't overcommited, so the machines should not use thi

  • HP 6600AIO with ePrint

    I have this printer via ethernet, and printing is no problem. My question: since I am connected via ethernet, can I turn on wireless at the same time and ePrint to print from my iPad? If not, I "need to guidance on how to use ePrint, that I installed

  • damaged says CS5 installation cannot open

    try to download cs5 design premium for my new iMAC, but whenever I try to open the installation, it is said that it is damaged and cannot be opened. How can I install cs5 which I have already for my laptop on my new iMac?