Functions variables (and Classes)

Hi, I was wondering if ActionScript was a way to call functions and classes of variables, as they do in PHP:

function funcname() {
     print "Potatoes come from tree";
}
$function = "funcname";

print $function;   // Prints out "funcname"
$$function();      // Prints out "Potatoes come from tree"

Where you don't know the syntax of PHP, you should know that all perpended with a symbol $ is a variable. Is something like this possible with ActionScript?

Flash uses array notation to convert strings into objects:

function funcname() {
     trace("Potatoes come from tree");
}
var fS:String = "funcname";this[fS]();

Tags: Adobe Animate

Similar Questions

  • read the type of variable and the value of LabView

    With the help of the TS. Class sequence that I try to get the type of variable and the values of local variables, parameter, fileglobal and stationglobal. Unfortunately I'm not able to find the right function. Hope someone can help me.

    Kind regards

    Lars

    Hello

    Maybe this simple TestStand example will help you.

    The API calls for LabView are the same...

    Hope that helps

    Jürgen

  • Flatten XML bug with unit variables in classes

    Hello

    I just spent 5 hours trying to understand why some of my data class kept itself set to zero.  It turns out that the part that kept resetting is the part that had a variable of the unit in it, and who fails to load correctly of the VI XML Unflatten.  It works very well if it's just a cluster, it is to be in a class that is the problem.

    I attached the zip file with the example of screw

    Can I ask someone with LV 2014 try this to see if the bug exists?

    Right now we are running 2011, but we anticipate a change of scale of the company until 2015, as soon as he gets out (and so, 2011 drops of extended support).  I would like to know if I can just wait for the upgrade and then it will work, or if I need to redo everything ~ 15 variables in classes with units on them that I had counted on the loading and saving by using built-in XML functions.

    For the benefit of future people who have the same problem and find this post, NOR contacted me and told me fact knowledge as a workaround if a digital solution is placed in a cluster in the private class data control, it will flatten and unflatten successfully.  I have confirmed that it works by adding a 3rd member to my example.

  • Using a function from another class

    Information: Blackberry JDE 7.1.0

    BlackBerry 9930 Simulator - V 4.0.0.141

    The title of the topic seems simple, but I'm actually trying to use a X of class A function inside a function Y of class B and the GET, the value returned by X to a variable in B.

    Let me start by explaining what I currently have and then go on what I'm doing.

    I am using this class, the code for which I found online, to create a scrollable multi-line textbox.

    public class TextBoxField extends VerticalFieldManager {
    
          //define some variables to be used
          //in the class
          private int managerWidth;
          private int managerHeight;
          private EditField editField;
    
          public TextBoxField(int width, int height) {
                super(Manager.NO_VERTICAL_SCROLL);
                managerWidth = width;
                managerHeight = height;
    
                VerticalFieldManager vfm =
                    new VerticalFieldManager
                      (Manager.VERTICAL_SCROLL);
    
                  editField = new EditField(){
                    public void paint(Graphics g) {
                    getManager().invalidate();
                    super.paint(g);
                  }
                };
    
                vfm.add(editField);
                add(vfm);
              }
    
          public void paint(Graphics g) {
              super.paint(g);
              g.drawRect(0, 0, getWidth(), getHeight());
            }
    
          public void sublayout(int width, int height) {
              if (managerWidth == 0) {
                managerWidth = width;
              }
              if (managerHeight == 0) {
                managerHeight = height;
              }
              super.sublayout(managerWidth, managerHeight);
              setExtent(managerWidth,managerHeight);
            }
    
          public String getText() {
                return editField.getText();
              }
              public void setText(String text) {
                editField.setText(text);
              }
            }
    

    Then in another class that I created a "Set" function that instantiates the class textbox, to create two text boxes and a richfieldtext, add them to a HorizontalFieldManager and return the HorizontalFieldManager.

     HorizontalFieldManager Set(int set){
            HorizontalFieldManager hr1=new HorizontalFieldManager(FIELD_HCENTER);
    
            RichTextField set1 = new RichTextField("SET " + set + ":"){
                protected void layout(int width, int height)
                {
                    super.layout(75,30);//Width and height according to the button name;
                    setExtent(75,30);//width and height according to the button name;
                }
            };
            set1.setPadding(10, 5, 10, 10);
            TextBoxField set1W = new TextBoxField(40,25);
            set1W.setPadding(10, 5, 10, 0);
            TextBoxField set1R = new TextBoxField(40,25);
            set1R.setPadding(10, 5, 10, 0);
    
            hr1.add(set1);
            hr1.add(set1W);
            hr1.add(set1R);
    
            return hr1;
        }
    

    Now in my main class I call this function to add a 'Set' on the screen using:

    add(Set(1));
    

    For the creation of the 'Set' function instead of using the instance of the textbox class in the main class itself, it is because I will create several 'sets '.

    Now, as you can see, there is a public String getText() function in the TextBoxField() that returns the value of the editField. What I need to do, is to get the value in this field, once you press a button.

    I have the code for the function button, so this isn't a matter of concern. However I do not know how to retrieve the editField value when the button is pressed. I can get the value inside the Set()function, using the:

    String getval = set1W.getText();
    

    but can't reach it from the outside. I don't even know if it's possible in the first. If it is not could someone suggest a way where I could retrieve these values.

    Any help is appreciated.

    Thank you.

    Thanks for the suggestion. I found another workaround solution. Essentially implementation of an array of TextBoxFields and then pass them one by one the "Set()" method

    I tried this at the start before posting here, but due to a careless mistake when you declare the array of TextBoxFields, I couldn't make it work.

    In any case, the topic can be closed now, because the problem has been resolved. Thank you.

  • Variables and global imports

    Hi, I have; m using views on my new project and I was wondering if in actionscript I can do imports coming into the world to my entire application.

    For example.

    I have MyApplication.as that does it:

    import flash.data.SQLConnection;
    import views.Home;
    
    --
    private var home:Home;
    protected var dbConnection:SQLConnection = new SQLConnection;
    var dbFile:File = File.applicationDirectory.resolvePath("assets/mydb.db");
    dbConnection.open(dbFile);
    --
    
    home = new Home();
    addChild(home);
    

    The above code is obviously well separated in all methods and everything, but I just put online so you can see what I am trying to accomplish.

    On my home.as, I would then be able to use my connection (dbConnection) started the MyApplication.as, and I also want to import all the necessary libraries that will use throughout my application. For example. import flash.data.SQLStatement;

    I'm sure I'll have to use several times in different points of view, and if I import it every time, it gets a bit redundant.

    Could someone tell me how to make a variable and an overall import throughout the application? And 'global' the best way to do it?

    Thanks in advance,

    mplacona wrote:
    Could someone tell me how to make a variable and an overall import throughout the application? And 'global' the best way to do it?

    Furthermore, you essentially asked two unrelated things in your post, but you may not have realized given how you thought (possibly) imports worked.

    I addressed the issue of imports, while JRab gave you a way to deal with the other half of your question on access to variables in your application.

    In addition to using a singleton approach, you can count on the fact that your high class (what you call your "home.as", I guess) is instantiated in general only once in the application.  This makes it practically equivalent to a singleton.  (Singleton term is generally used for a class that you can't instantiate more of once, I think, but is probably too (put?-) used for a class that is instantiated only once, as with the main class.)

    If you want to set these variables in your main class, just make variable static.  This makes them directly accessible from any class that can 'see' your main class, which is usually everything within a single package.  Example follows:

    // in main class, e.g. Home.as
    
    public class Home extends Sprite {
        public static var version:String;
    
        // other vars here, maybe non-public or non-static
    
        public function Home() {
            Home.version = '1.2.3'; // store global reference
    
            // initialize app here
        }
    }
    
    ---------------------------
    
    // in some other module, e.g. Model.as
    public class Model {
    
        public function Model() {
            trace('version', Home.version);
        }
    
  • Calling functions from another class

    How one accesses a function from another class?

    Let's say I have a file called .as hand. My flash file uses this as this is the main class to make it work when you test the program. Let's say I have another class named Test that looks like this:

    package

    {

    public class Test

    {

    public void Test()

    {

    trace ("why don't you work?');

    }

    }

    }

    I want call the Test function when the game takes place (in the appellant to hand), how would he enter the main run file? I imported to it, made sure that the functions were public/static, created as a variable and it still doesn't work.

    Any help would be good

    the constructor for a class is different from a 'normal' function

    If you can't do something like

    meow: Test of var = new Meow();

    To call it thus:

    test: Test of var = new Test();

    test. Meow();

  • Call the function of FLA class

    This simple perhaps, but I have two files and I want to call a function inside a class and I don't know how to do this. EX I want to call the Main() function, after that I imported packages.  Can anyone help?

    Package CODE:

    package code

    {

    import flash.display.Sprite;

    import flash.display.MovieClip;

    public class allActivities extends flash.display.Sprite

    {

    public static var testGlobal:String = "testValue";

    private void Main (): void

    {

    trace ("initialize Global Variables");

    }

    }

    }

    package code

    {

    public class activityone

    {

    private void Maintwo (): void

    {

    trace ("testGlobal" + allActivities.testGlobal);

    }

    }

    }

    FLA CODE

    Import code.*;

    1. main must be public

    2. There must be an allActivities instance reference in the main of your fla timeline if that's what you mean by appeal to fla

  • How the names of variables and units used in the binary output file

    My colleague will give me LabView generated from the binary files (*.dat). There are more than 60 variables (columns) in the binary output file. I need to know the names of variables and units, which I think he has already configured in LabView. Is there a way for him to produce a file that contains the name of the variable and unity, so that I'll know what contains the binary file? It can create an equivalent ASCII file with a header indicating the name of the variable, but it does not list the units of each variable.

    As you can tell I'm not a user of LabView, so I apologize if this question makes no sense.

    Hi KE,.

    an ASCII (probably the csv format) file is just text - and contains all data (intentially) written to. There is no special function to include units or whatever!

    Your colleague must save the information it records the names and values in the same way...

    (When writing to text files, it could use WriteTextFile, FormatIntoFile, WriteToSpreadsheetFile, WriteBinaryFile even could serve...)

  • Need help with TS to read the list of variables and/or LV

    Hello

    I use Labview adapter in Teststand to open WinIDEA and read the values of the variables. Basically LV lib files are used to read the value of the variable at run time, and returns the value of the variable. Contribution to this labview function i.e. variable name string and output type cluster.

    I need to read the list of variables and compare it to the value limits for each variable. I perhaps need to read at least 50 to 60 variables in one step if possible or a variable at a time in a loop. I want to add these variables in a txt file with the limits and read of Teststand as a string array and compare the result. In this way is easy to add or remove variables from the list and therefore their expected value. I tried to use the shipper of the property, but there need a stage name or local/global variable.

    Another way is to add the code in labview for comparison of variables value read, then I lose teststand power and flexibility.

    I am struggling to find the best way to achieve this. Any ideas?

    I would like it.  Basically, you have a file limit with 2 data tables.  A table contains your variables and the other your limits.  Then you wrap on a test of a string value.

    Let me know if you have any questions.

  • Problem with the window "Variables and stack calls ': Options / interpret as

    Hello NO,.

    I found a way to run the JIT-debugger LabWindows/CVI on ICB itself...

    This is the procedure:

    1. I put a breakpoint, run the code, and the breakpoint, I opened the window "Variables and stack calls" by right clicking on a variable and selecting 'Display Variable View.
    2. Any variable shown, I right click and choose Options / interpret as

    You're right, I could now reproduce as well. It seems as if the presence of a function pointer, if set or not, causes interpret as shatter the debugger. The ADE does not seem to be affected, but you will probably have to restart your debugging session when this happens.

    I created the bug report 425151.

    I really appreciate the time spent in this narrowing for me. Thank you!

    Luis

  • Allocation of buffer in functional variable drives me crazy

    Hello

    I have a functional variable that holds 16 waveforms. You attends waveforms of theses in time. For more efficient memory, I try to use the data tables pre-allocating (say that 300000 double rooms).

    But it seems that there is a new allowance of buffer in the shift register and it is slowing down my app time.

    Since I'm pre-allocating and using inplace structure, I do not see why LabVIEW is a duplication of all waveforms.

    Any idea to achieve functional variable effectiveness?

    Here is the code of my functional variable.

    Thanks in advance!

    Vincent

    I don't think that that dot allocation memory buffer is your problem. Which will appear on a register to offset uninitialized and is just the LV medium to tell you it's going to store data.

    To improve performance, I would like to add a new folder named Get Data that displays the waveform buffer, rather than having the shift register directly connected to an indicator of output. Forcing all LV to make a copy of the whole buffer each time this FG is called, even just to write or initialize the data. The case of the Get Data would be the thread of the fork offset register and send it to an output. Select use the default value for this output to the output terminal, so that other cases (writing, initialization, etc) out just an empty array of waveforms, which allows to make very effectively LV.

  • Question of variables and file download.

    Hello

    I have a uploader of file in AS3 and can successfully save a file using php.

    I would also like to send variables with the file, php to process variables and display in Flash.

    Separated, I was able to include flash-flash-php variables in a project, but I can't work on how to do this while also downloading a file.  I get a null reference error in the completeHandler function when flash tries to display the reactive power coming back from php.

    Here is my AS3:

    create a file from a string of text, it records, the bed, then download:

    var newFile:File;

    newFile = File.desktopDirectory.resolvePath ("my.xml");
    var stream: FileStream = new FileStream();
    Stream.Open (newFile, FileMode.WRITE);
    stream.writeMultiByte (str, "utf - 8")
    Stream.Close ();
    stream.openAsync (newFile, FileMode.READ);

    stream.addEventListener (Event.COMPLETE, uploadFile);

    function uploadFile(evt:Event):void {}

    var URLrequest:URLRequest = new URLRequest ("http://www.mysite.com.au/uploader_script.php");
    var variables: URLVariables = new URLVariables();
    variables.todayDate = new Date();
    variables. Name = "Dude."
    variables. Email = "[email protected]"; ""
    variables.saveThisXML = "test record this";
    variables.passwordString = 'parse ';
    URLrequest.method = URLRequestMethod.POST;
    URLrequest.data = variable;

    newFile.addEventListener (Event.COMPLETE, completeHandler);
    newFile.addEventListener (ProgressEvent.PROGRESS, progressHandler);
    newFile.upload (URLrequest);

    }

    function completeHandler(evt:Event):void {}

    var phpVar1 = evt.target.data.var1;
    var phpVar2 = evt.target.data.var2;

    result1_txt. Text = phpVar1;
    result2_txt. Text = phpVar2;

    uploaderMC.status_txt.text = newFile.name + 'has been uploaded.';

    }

    My PHP:

    <? PHP

    $Name = $_POST ['name'];
    $filename = $_FILES ['Filedata'] ['name'];
    $filetmpname = $_FILES ['Filedata'] ['tmp_name'];

    $uname = $_POST ['email'];

    Print two vars back-Flash, you can also use 'echo' instead of printing
    print ' var1 = the domain name with a variable of $uname was sent to PHP and is back.';
    print '& var2 = $uname is also defined in the variable 2 php.';

    File on the server:
    move_uploaded_file ($_FILES ['Filedata'] ['tmp_name'], $filename);

    ? >

    It works fine download, but falls into the AS3 to var phpVar1 = evt.target.data.var1;

    Is there an obvious reason that I'm missing?

    Thanks for your time.

    Shaun

    Add your variables in your URLs and use $_GET in your php file to analyze the variables:

    create a file from a string of text, it records, the bed, then download:

    var newFile:File;

    newFile = File.desktopDirectory.resolvePath ("my.xml");
    var stream: FileStream = new FileStream();
    Stream.Open (newFile, FileMode.WRITE);
    stream.writeMultiByte (str, "utf - 8")
    Stream.Close ();
    stream.openAsync (newFile, FileMode.READ);

    stream.addEventListener (Event.COMPLETE, uploadFile);

    function uploadFile(evt:Event):void {}

    var URLrequest:URLRequest = new URLRequest ("http://www.mysite.com.au/uploader_script.php?var1=" + all + "& var2 =" + whateverelse);
    var variables: URLVariables = new URLVariables();
    variables.todayDate = new Date();
    variables. Name = "Dude."
    variables. Email = "[email protected]";
    variables.saveThisXML = "test record this";
    variables.passwordString = 'parse ';
    URLrequest.method = URLRequestMethod.POST;
    URLrequest.data = variable;

    newFile.addEventListener (Event.COMPLETE, completeHandler);
    newFile.addEventListener (ProgressEvent.PROGRESS, progressHandler);
    newFile.upload (URLrequest);

    }

    function completeHandler(evt:Event):void {}
           
    var phpVar1 = evt.target.data.var1;
    var phpVar2 = evt.target.data.var2;
       
    result1_txt. Text = phpVar1;
    result2_txt. Text = phpVar2;
     
    uploaderMC.status_txt.text = newFile.name + 'has been uploaded.';

    }

    My PHP:

    <>


    $var1 = $_GET ['var1'];

    $var2 = $_GET ['var2'];

    $Name = $_POST ['name'];
    $filename = $_FILES ['Filedata'] ['name'];
    $filetmpname = $_FILES ['Filedata'] ['tmp_name'];

    $uname = $_POST ['email'];

    Print two vars back-Flash, you can also use 'echo' instead of printing
    print ' var1 = the domain name with a variable of $uname was sent to PHP and is back.';
    print '& var2 = $uname is also defined in the variable 2 php.';

    File on the server:
    move_uploaded_file ($_FILES ['Filedata'] ['tmp_name'], $filename);

    ?>

  • Access the function of custom class which is stored in a table?

    Hello guys..,.


    I hope I am making stopper, with the title of the thread, because I'm a bit confused, how do you explain in Word...

    anyway I'll describe what I mean and hope you guys can help out me..,.

    Here I am doing some object of action script..,.

    What about this object that is in the constructor function of this object is as I do to send a parameter of sprite that will act as it's parent..,.

    var anObject:myObject = new myObject (parentSprite);

    and in my main project, I used those object and store in a table after it is added to the scene...

    I store it in a table cause I have to be able to return to the it...

    everything was fine until I have to call the function inside this object which I already stored in a table..,.

    so, how should I call the function in this table object that has stored the object?

    hope that I specify me...

    Thanks in advance guys..,.

    Well, the error is tell you that removeChild() destroy() function in the class Newsticker is having a problem because you try to remove a child does not belong to the parent. How your destroy() function looks like?

  • Call a function of another class

    Hi!, I have a Flex project with this code inside the package 'package ':

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   backgroundColor="black"
                   creationComplete="init();callLater(showInitTime);" currentState="Inicial"
                   frameRate="24" preloader="paquete.CustomPreloader" >
    ...
    <fx:Script source="Principal.as" />
    ...
    

    File "Principal.as" has this function:

    public function loquesea():void{
         ...
    }
    

    And for the preloader, I have this class:

    package paquete
    {   
        imports ...
        
        public final class CustomPreloader extends DownloadProgressBar
        {
           
            public function CustomPreloader() 
            {
                
               //HOW I CALL FROM HERE loquesea() FUNCTION in Principal.as ????
                super(); 
            }
    
    

    Well, my question is in the code above

    Thank you!

    Hi Raulkirm,

    If you include this script in your main mxml file (remember not in another mxml component) you can call this function using the class of toplevel as shown

    FlexGlobals.topLevelApplication.loquesea ();

    Also don't forgtet to import the namespace corresponding to the...

    Thank you

    Jean Claude

  • Timeline variables in class

    I don't understand how I can get my main script variable in a class.

    example of

    Variable timeline

    getPage var = 1;

    class where I need

    package

    {

    public class myClass

    {

    public var myVar:int = getPage.

    }

    }

    If someone could explain how to do this, I would jump for joy.

    You mean you want to read the value of variable a chronology of a class? If you would just pass a reference chronology to the class and then go from there... something like this:

    package

    {

    import flash.display.MovieClip;

    public class MyClass

    {

    private var myVar:int;

    public void MyClass(timelineRef:MovieClip)
    {
    myVar = timelineRef.getPage;
    trace (MyVar);
    }
    }
    }

    And then you instantiate in Flash as:

    getPage var = 1;

    var myObject:MyClass = new MyClass (this);

    and you will see 1 track

    And class names are capitalized by convention.

Maybe you are looking for

  • XP Home Edition Multiboot not required

    Hello world Greetings! My Dell laptop is to have two drives C and E. The problem is that I installed Windows XP Home edition on both discs by mistake. Thus, the system has now facilitated multiboot. I want to uninstall one of them... According to the

  • R61i; audio device after loading sp2 May 30 problems

    Friday, May 30 my r61i sp2 downloaded and when sytem restarted my speaker didn't have a red X and a msg no audio device found. Also on the keyboard volume controls do not work. I am online with the support of mircosoft and with their help reloaded th

  • PC said there are two versions of Windows after upgrade from 32 to 64-bit

    After update Win7 32 to 64 bits, at startup the PC says I must choose between Win7 and an older version of Windows installed on your PC.  There is no earlier version installed on the PC.  Any way to convince the boot process that's true, so I don't h

  • Remove older versions

    Hello is it possible to delete older versions? I want to remove the earlier versions because they don't work that well. I have an app that has as the minimum os version 10.0.10 and has published a fix that has 10.1. Is user with 10.0.10 still gets th

  • DOM + missing sign

    I have not + icon in the Panel of DOM.  I have to go somewhere to start?