Passing variable to functions

Try to pass the t.content variable to a function called mp3player. trace works when the function is called, but not inside the function.

No idea why?
Thank you.
-CK

Try after the line:
var mp3player:MovieClip = this.attachMovie("mp3player","mp3player",1);
Mp3Player.xmlFile = xmlFile;

Tags: Adobe Animate

Similar Questions

  • newbie on passing variables between functions

    Hi, I'm new to flash development and did only Java, C++, assembler before. This issue will be probably fairly simplistic. I want to click on a button, which will then call on another method, pass it several integers (ints) and the method returns an int after certain operations. Here is a snippet of my code.

    package
    {
        import flash.display.Sprite;
        import flash.events.MouseEvent;
        import flash.media.Sound;
        import flash.text.TextField;
        import flash.text.TextFormat;
    
        import mx.controls.Text;
    
        import qnx.ui.buttons.Button;
        import qnx.ui.buttons.LabelButton;
        import qnx.ui.text.TextInput;
    
        import spark.components.TextArea;
    
        // The following metadata specifies the size and properties of the canvas that
        // this application should occupy on the BlackBerry PlayBook screen.
        [SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
        public class AIRHelloWorld extends Sprite
        {
            public function AIRHelloWorld()
            {
                //var R1 R2 and R3 are declared and read from here. 
    
    //here is where the call should happen
    //calculation button
                var total:Button = new Button();
                total.addEventListener(MouseEvent.CLICK, calculate, R1, R2, R3); //this should return an int
    
                //textformat for the calculate button
                var Calformat:TextFormat = new TextFormat();
                Calformat.color = 0xAA0000;
                Calformat.color = 0xAA0000;
                Calformat.size = 24;
                Calformat.italic = true;
                Calformat.align = "center";
    
                //text for the button
                var text:TextField = new TextField();
                text.text = "Calculate";
                text.setTextFormat(Calformat);
    
                //add text to calculation button
                total.addChild(text);
    
                stage.nativeWindow.visible = true;
            }
    
            private function calculate(event:MouseEvent, R1:int, R2:int, R3:int):int {
                return 0;
            }
    
            private function closeWindow(event:MouseEvent):void{
    
                stage.nativeWindow.close();
            }
    
            private function goToBackWindow(event:MouseEvent):void {
                stage.nativeWindow.orderToBack();
    
            }
        }
    }
    

    Needless to say, Adobe Flash builder don't like what I'm trying to do. Apparently EventListener does that take Boolean arguments. So how the values of R1 R2 and R3 to the function calculate?

    Thank you for your time

    Hello and welcome:

    In Flash/Flex/AIR event model is very simple and flexible.  In your example, it is better to create a LabelButton and add the event listener to that (fewer lines of code).  As:

    var button: LabelButton = new LabelButton();

    Button.label = "Push Me";

    button.addEventListener (MouseEvent.CLICK, DoCalculate);

    If necessary, adjust the location

    addChild (button);

    When the mouse is clicked, a "MouseEvent" event is sent to the DoCalculatefunction.  All event listeners must accept a parameter of an event. All events derive from the class of events 'event '.  Thus, the type of parameter can either be a MouseEvent from that which was given to generate, or the most high quality event.

    private function DoCalculate (event: Event): void

    {

    do something

    }

    Now what needs to be calculated would be information in the same point of view or accessible to the DoCalculate method.  So if you have 3 domains (e.g., TextInput), then those would be deprived of the main view and then attributes can be used to determine the result of the mouse click.  For example:

    SerializableAttribute public class MyApp extends Sprite

    {

    private var r1: TextInput = new TextInput();

    private var r2: TextInput = new TextInput();

    private var r3: TextInput = new TextInput();

    public void MyApp()

    {

    Add text entry to display a list

    make the application visible

    create a button

    Add button click listener

    }

    private function DoCalculate (event: Event): void

    {

    var sum: int = parseInt (this.r1.text) + parseInt (this.r2.text) + parseInt (this.r3.text);

    do something with sum

    }

    }

    Hope that helps.

  • Passing variables to functions

    Hello

    I'm relatively new to actionscript and were blowing away at him for the past two weeks. I am trying to call a function on a key. It's pretty easy, but when I then change this feature so that it accepts arguments all it goes a little wrong. Add this to the same screen just a string as argument and tracing problems...

    Basically I want the function that is called with an arg when a key is pressed, so something like:

    mybutton.onRelease = myfunction (1);

    MyFunction(i:Number) empty
    {
    trace (i)
    If (I == 1)
    {
    do something;
    }
    on the other
    {
    do something else;
    }
    }

    What ends up happening, is that when I test the movie function is called immediately, and then does not work when the button is pressed. If I get rid of the arguments then it works fine, only the number to print screen when the button is pressed. If I change the button support for what is called the function without sending the argument, then "undefined" gets registered on the screen (but at least it captures that the button was pressed differently than during the passage of an argument).

    All the tutorials I've looked at seem to have this as the standard arguments to a function, so I'm a little in the dark as to what is happening. Any help would be greatly apprieciated.

    See you soon,.

    Tom

    It's a little different for event handlers as the button's onRelease event.
    mybutton.onRelease = myfunction (1); -> the code will run away without waiting for the event to
    mybutton.onRelease = myfunction(); -> the code will run away without waiting for the event to
    mybutton.onRelease = myFunc; -> MyFunc is called after the onRelease event fires.

    See code attached.

  • Passing variables: functions

    Sorry if it's nooby questions:
    How can I pass variables between functions as I know how to return a value and you can pass parameters in a function, but say, I had an external function (say "a") with a local var (so-called "vara") with a function underpinned (so-called 'b') how can I make 'vara' in the function b and then come back out for the value of 'vara' has been updated. Sorry bad explanation. Is this possible with local vars? or would I need to use a regular var who can access these two functions?

    > This will essentially do what your asking. If I missed the mark let me know.

    I think you have

    > say I had an external function
    > (say "a") with a local var (so-called "vara") with a subtended (for example function
    (> 'b') how
    > can I spend 'vara' in the function b and then put it back so the value of
    > "vara".
    > has been updated.

    Short answer... No... you can pass things of value, and you can
    return values.

    You cannot pass a variable into a function and have the function change the
    variable.

    If you want to update a single variable with the result of a function, then
    You can do like TimSymons suggested: vara (vara) b =;

    But this doesn't seem to be what you're asking.

    You can however set your variables within an object, pass the object to a
    run and edit the variables within the object, then when the function
    back, the object has changed variables. for example

    function a() {}
    var myvars = {vara: 123, varb: 456};
    b (myvars);
    trace (myvars. Vara);
    trace (myvars.varB);
    }

    function b (myvars) {}
    myvars. Vara = myvars.vara * 2;
    myvars.varB = 789;
    }
    --
    Jeckyl

  • Passing variable of a function

    How to pass variable mulitple of a function using AS3? What this has to do with a class?

    It must be something simple that I'm missing. Please take a look and see what it could be.

    example:

    var endValue;  variable, I want to fill

    var loader: URLLoader = new URLLoader();

    loader.addEventListener (Event.COMPLETE, dataLoaded);

    var request: URLRequest = new URLRequest ("population.csv");
    Loader.Load (request);

    function dataLoaded(evt:Event):void {}
    var myData:Array = loader.data.split(",");
    endValue = myData [0];

    }
    trace (EndValue);  undefined

    Thank you

    Sky

    read my message above.

  • passing variables with "ProgressEvent.PROGRESS.

    Hi all, I have this code:

    imgContainer.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, function() {loadProgress (charger)});

    function loadProgress (aa): void {}

    var percentLoaded:Number = Math.round ((event.bytesLoaded/event.bytesTotal) * 100);

    trace ("loading:" + percentLoaded + "%");

    percentCar = percentLoaded * 3;

    AA. Width = percentCar;

    AA.x =-percentCar/2;

    }

    but does not work because of the way in loadProgress no event is to calculate bytesLoaded ecc...

    How can I pass variables in this formula?

    Thank you very much

    use:

    imgContainer.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, loadProgress);

    function loadProgress(event:ProgressEvent):void {}

    var percentLoaded:Number = Math.round ((event.bytesLoaded/event.bytesTotal) * 100);

    trace ("loading:" + percentLoaded + "%");

    percentCar = percentLoaded * 3;

    Loader.Width = percentCar;

    Loader.x =-percentCar/2;

    }

    or, if there is a really good reason to spend charger in your use of function loadProgress:

    imgContainer.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, {function (e:ProgressEvent)}

    loadProgress (e, loader)

    });

  • Passing variables ActionScript 2 using javascript

    Hello

    I tried to pass variables to a flashdrive with on the page refreshes. In doing my research I fell I cross things like externalinterface and others.

    I found a javascript + actionscript who spent ariables flashing without updating the code page:

    I have therefore 8 flash with actionscript 2.0.

    HTML:

    <SCRIPT LANGUAGE=JavaScript>

    <!--

    function callJavascript() {}

    Mathias var = inputValue.vars.value

    window.document.myMovie.SetVariable ("testValue", Mathias);

    }

    ->

    < /SCRIPT>

    <object classid=' clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 ' codebase="""http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8, 0,0,0" " " width="550" height="100" id="myMovie" align="middle"> "

    <param name="allowScriptAccess" value="sameDomain" />

    <param name="movie" value="setplay.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffcc00" /><embed src="setplay.swf" quality="high" bgcolor="#ffcc00" width="550" height="100" name="myMovie" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
    </body>
    <p>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value="Pass the variable to Flash" onClick="callJavascript()">
    <form name="inputValue">

    <a href="javascript:callJavascript()"> flash one</a><input type="hidden" name="vars" value="1.flv"/>
      </form>
    </html>

    I have a flash drive with a movie player instance name of myVid:

    ActionScript:

    var testValue:String = "";

    watchCallback = function (id, oldval, newval): String {}

    result_txt. Text = newval;

    myVid.play (newval);

    return newval;

    };

    _root. Watch ("testValue", watchCallback);

    The code gets the variable var in the html page. Pass vars to actionscript using javascript, displays text on result_txt and play flv video with similar name to a variable passed.

    The problem is:

    I have several a href links that I would like to have the different variables that they would pass to the flash drive.

    < a href = "javascript:callJavascript ()" > flash < /a > < input type = "hidden" name = "var1" value = "1.flv" / >

    < a href = "javascript:callJavascript ()" > flash two < /a > < input type = "hidden" name = "var2" value = "2.flv" / >

    < a href = "javascript:callJavascript ()" > flash three < /a > < input type = "hidden" name = "var3" value = "3.flv" / >

    < a href = "javascript:callJavascript ()" > flash four < /a > < input type = "hidden" name = "var4" value = "4.flv" / >

    How can I change the code so that if someone clicks on a flash of the value of var1 is passed to flash.

    and if two flash is clicked var2 are passed to Flash.

    Thank you.

    http://circlecube.com/2008/02/ActionScript-JavaScript-communication/

  • Passing variables by reference

    Hello

    Is it possible to pass variables by reference as the arguments of a function?

    Thank you.

    All scalar values are passed by value. Anything else is passed by reference. There is no language syntax to control this behavior in AS3.

  • passing variables between the pop-up windows

    I'm moving one popup to the other variables. It works fien if I spend bvariable of main application as soon as I'm moving from variable popup to popup window it does not work here is what I am trying ro:

    That works fine

    hand. MXML

    private function launchMoreInfo (): void {}
    var win: view = PopUpManager.createPopUp (this, opinion, true) as point of view;
    //

    victory. AccountNum = list1.selectedItem.accountNum;
    Win.User = user;

    }

    But if I try to pass variables to the pop-up window, created from popup component, is not ' work

    View.MXML

    private function dsclientevents (): void {}
    var win2:view = PopUpManager.createPopUp (Thi, dsclienteventlog, true) like point of view;
    //

    win2. AccountNum = 'test ';

    }

    AccountNum is declared in dsclienteventlog.mxml

    Is it possible to pass variables between the pop-up windows?

    I would much apreciate your help

    Thank you

    Hi friend!

    I have faced this kind of problem and solved using 'Public static var '.

    Just, you declare a public static variable in your class Popup. Then you can directly set the value to this variable as,

    ClassName.StaticVariableName = value;

    In your case,.

    say PopUp2.mxml or PopUp2.as

    =======

    In the PopUp1 script:

    OnItemSelectionChange (event): void

    {

    PopUp2.m_iSelectedID = DatagridID.selectedItem.AccountID; It will change the value of this variable, even if the popup2 is open.

    your stuff here...

    }

    Try this, I hope this will help you.

    Thank you

    Merlina.

  • SWF loaded, passing variables

    If I load a swf movieclip into a parent SWF is using:
    _root.loadMovie ("bar_chart.swf");
    How can I can pass variables in the parent swf using AS?

    Is it possible to use _global to declare a global variable in the parent, then access this in the swf file that is loaded:
    Parent:
    _Global.test = new Array();
    Load:
    [x] test = y;
    (well it does not work as I have tried, but something along those lines)

    Basically I'd like any info on how I could pass variables between a loaded swf and its parent, but try to keep it in terms laymans terms because I'm not so hot on the action script.
    Thanks for any help in advance!

    Place the code in the first frame of your movie. its working fine. I don't know why you want to call a function the external swf file perticular.

    _Global.bars = new Array();
    for (i = 0; i! = 5; i ++) {}
    bars.push (i);
    }
    var total = 0;
    var a = _global.bars.length;
    for (i = 0; I! = a; i ++) {}
    Total += _global.bars;
    }
    for (i = 0; I! = a; i ++) {}
    this.createEmptyMovieClip (("bar"+i), this.getNextHighestDepth ());
    var color = "0 x" + random (9) + random (9) + random (9) + random (9) + random (9) + random (9); "."
    This ["bar" + i] .beginFill (Colour);
    This ["bar" + i]. MoveTo (((i/a) * 100), (100-(_global.bars/total*100)));
    This ["bar" + i]. LineTo (((i+1) /a) * 100)-1), (100-(_global.bars/total*100)));
    This ["bar" + i]. LineTo (((i+1) /a) * 100)-1), 100);
    This ["bar" + i]. LineTo (((i/a) * 100), 100);
    This ["bar" + i]. LineTo (((i/a) * 100), (100-(_global.bars/total*100)));
    This ["bar" + i] .endFill ();
    }

  • Pass Variables from JavaScript CS3 ActionScript

    Hello

    I can't understand what I'm doing wrong and I need help . Who better to ask than legal experts?

    I have everything works fine so far except for this actionscript. I use CS3 Flash with ActionScript, CS3.

    I have 5 buttons in flash.
    I try to perform the following tasks
    1. ensure buttons with effects in flash - done
    2 put the button in the down position based on the Web page that the user is on.
    To perform this dynamic, I apparently have to use 3 different languages, PHP, JavaScript, ActionScript.

    I've been playing with this during a week and can not understand. I have the rest of the scripts tested and verified to work.

    Here is the link to my test page
    http://www.spectacularstuff.com/PHP-test/inProgress/php-URL-detection.php

    Here is my code for the test. (This does not include the buttons. It is simply to test to see if I'm passing variable.)

    PHP code to detect the file name.
    <? PHP
    function curPageName() {}
    Return substr ($_SERVER ["SCRIPT_NAME"], strrpos($_SERVER["SCRIPT_NAME"],"/") + 1);
    }
    ECHO "is the current name of the page detected by PHP". curPageName();
    ? >

    The JavaScript Code to pass variables to the Flash
    < script language = "javascript" src = "swfobject.js" >
    var so = new SWFObject ("php - url - detection.swf", "php-url-detection", "550", "400", "9", "#FFFFFF");
    so. AddVariable ("currentpage","<? php echo curPageName();? >" ")
    < /script >

    ActionScript Code to get the JavaScript Variables and display them in flash.
    Dynamically create text fields
    var tf:TextField = new TextField();
    tf.autoSize = TextFieldAutoSize.LEFT;
    TF. Border = false;
    addChild (tf);

    var tf2:TextField = new TextField();
    TF2. AutoSize = TextFieldAutoSize.LEFT;
    TF2. Border = false;
    addChild (tf2);

    Create the variable to write to the page
    var myStr2:String;

    first attempt to put the variable on the page.
    This LoaderInfo must be capitlized. An error occurs if not.
    var paramObj:Object is LoaderInfo (this.root.loaderInfo).parameters.currentpage;.

    second attempt to put the variable on the page
    var myStr:String = this.root.loaderInfo.parameters.currentpage;
    trace (paramObj);
    trace (myStr);

    If (myStr is nothing)
    {
    myStr = "Flash is not reading JavaScript variables.:(";).
    myStr2 = "";
    }
    on the other
    myStr2 = "" Flash read the JavaScript variables! :)) ' "

    TF. Text = myStr; Display the URL on the page
    TF2. Text = myStr2 //Display Flash is happy

    [- End of Code-]


    Help, please.

    Thank you in advance.

    Wayne

    I found an answer to this for someone looking for an answer. I wrote the answer in another forum:
    http://Board.flashkit.com/Board/ShowPost.php?p=3946455&postcount=31

  • 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

  • CVI 2013 ' FATAL RUN - TIME ERROR: pointer to free memory passed to the function of library "when you access a struct of struct

    #include 
    #include 
    #include 
    
    typedef struct StringsStruct
    {
      char A[10];
      char AA[10];
    
      char B[10];
      char BB[10];
    
      char C[10];
      char CC[10];
    } StringsStructType;
    
    StringsStructType Strings = {0};
    
    char *const SelectedStrings[3] =
    {
      Strings.A,
      Strings.B,
      Strings.C
    };
    
    int __stdcall WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                           LPSTR lpszCmdLine, int nCmdShow)
    {
      if (InitCVIRTE (hInstance, 0, 0) == 0)
        return -1;    /* out of memory */
    
      strcpy( SelectedStrings[1], "TEXT" );
      /*** FATAL RUN-TIME ERROR:   "main.c", line 32, col 11, thread id 0xXXXXXXXX:   Pointer to free memory passed to library function. ***/
    
      Breakpoint();
    
      return 0;
    }
    

    Any chance to get this working in 2013 CVI?

    "& Strings.A [0]" does not work either.

    Hello CVI - User!

    Thank you for reporting the issue. I filed the bug report # 423491.

    I did have a chance to get rid of the error by changing the definition of the structure, but I was able to get the program running by disabling execution checking when the fields in the structure are initialized:

    strcpy( (char*)(uintptr_t)SelectedStrings[1], "TEXT" );
    

    Or perhaps a more descriptive workaround solution:

    #define UNCHECKED(x) ((void*)(uintptr_t)(x))
    strcpy( UNCHECKED(SelectedStrings[1]), "TEXT" );
    

    Thank you

    Peter

  • Is it possible to pass variables in FledgeController?

    We have some environment variables that change instance of Simulator, and it would be better that we could transmit in the Simulator, rather than having to write them to a file in the application to read running. Is it possible to pass variables in the FledgeController so they can be used as the app system environment variables?

    I don't think it's possible to pass via a command line.  But you can store this value in a file on your hard disk, Simulator one card micro SD and read the file in your application (although you mentioned that you do not want to).

    If you install via a JAD file, you can add the parameter to your JAD file and access them from your application.  But it's probably more complicated than to write a file.

  • How to pass variables to the basket to your fund information?

    Here's what I have to do.

    I have a site that sells the same products to several groups of people.

    When a customer enters our site that they need to choose what 'group', they belong to.

    Based on this selection of some of the images, text and links on the pages are customizable (I can do this without problems using a combination of passing parameters through the URL, and writing based on cookies).

    My problem is when I get the extraction are the cookies that I wrote do not give because the url changes to the worldsecuresystems.com.

    I tried everything I can think of to try to get the information stored in the basket page to transfer to the payment page.

    I basically need to spend the 2 pieces of data based on {{globals.cookie.creditunion}} and {{globals.cookie.group}} in the cart at checkout it is added to the CMS or order somewhere.

    I hope that makes sense.

    James

    Hi James,

    Just like Mihai said, pass variables by using the url in the payment button.

    Use the liquid version to create a payment button, here is an example:

    Checkout

    Afterwards, you should be able to go to globals.get.creditunion or globals.get.group

    Good luck

    Stoiky

Maybe you are looking for