Call a variable in one function of another

Okay so here is the situation:

I have a function that has a loop For inside.  Inside this loop for I am defining a button and calling another function, if you click on.  The question is (since I should not put functions within other functions) how can I get the variable being processed in the loop For to consider in the service that was already activated by pressing the button.

lol sorry.  Here's the code.

All variables are defined elsewhere in the code.

function populateBox(DataInput:XML)

{

linkAmount = DataInput.country [boxPartNum - 1].link.length (); sets the amount of deployed links

for (k = 0; k < linkAmount; k ++)

{

myLink = new LinkClass();

box.boxMC.linksMC.addChild (myLink);

define functions for links.

myLink.addEventListener (MouseEvent.CLICK, linkFunction);

}

}

now the function when the button is pressed.

function linkFunction(event:MouseEvent)

{

trace (k);

}

I need to find the 'K' used in the loop For.

What are my options?

IF they are the movieclips then you can assign the value of k as a property of them dynamically.  You can retrieve this value in your event handler through the event argument that is passed to the function.

function populateBox(DataInput:XML)

{

linkAmount = DataInput.country [boxPartNum - 1].link.length (); sets the amount of deployed links

for (k = 0; k

{

myLink = new LinkClass();

box.boxMC.linksMC.addChild (myLink);

define functions for links.

myLink.addEventListener (MouseEvent.CLICK, linkFunction);

myLink.kValue = k;

}

}

now the function when the button is pressed.

function linkFunction(event:MouseEvent)

{

trace (Event.currentTarget.kValue);

}

Note: I'm not surewhen, as it is needed, but it is possible that you will have to climb the event.currentTarget as a MovieClip, so the line service may need to be...

trace (MovieClip (Event.currentTarget) .kValue);

Tags: Adobe Animate

Similar Questions

  • copy some variables of one RPD to another


    Hi all

    How to copy a few variables of one RPD on the other, I'm spending DEV for the TEST and I can't move the RPD all as our architecture does not support. How can I copy only a few variables one SPR to another.

    Thanks for your time and your help.

    Compare to rpds and make a correction. then deploy the fix RPD in the RPD to test via the Merge option.

    The RPD to test will be original. dev RPD will be change.

  • Orchestrator web client: using variables in one presentation to another page

    A workflow that works linking orchestrator does not running the web client because (after a repair) I found that the values of a page of the submission form is not available on the other.  For example, the user selects the string: templateName on the first page and the following pages using #templateName to call a function.   However, this variable is empty so can not be used.  However, it can access General variables with values hard-coded.

    Is this a bug? limitation? Are there workarounds?

    (I use vsphere client 5.5 build 2026576)

    Default value is set once while data binding must be updated each time that the first field is changed.

    Sometimes what happens is that when the workflow starts, the default value cannot be calculated because the parameter is not yet set.

    You can avoid making mistakes with the launch of the first privilege of actions: if (parameterName == null) return null;

    But I'm surprised the example that you gave does not work.

    Check the server.log file to verify if the action runs with the empty parameter en or if there is another error.

  • How to call a method of one class from another class?

    I have two classes, Class1 and Class2 are saying. They are both public. They are located in the same package, and both are important to each other.

    I am trying to call a 2 function in Class1, but I do not know the syntax.

    I tried:

    Class2.godoThisThingNow ();

    But it gave me an error 1061, call to a method not defined.

    What is the correct syntax for this, and it is even possible in AS3?

    Thank you!

    You can call a public in Class1 2 method IF Class2 has access to an instance/member of Class1.

    for example, in Class2:

    var c1:Class1;

    .

    .

    C1 = new Class1();

    .

    .

    .

    C1.somepublicMethod ();

  • Simple task - syntax Question (how do you pass variables from one component to another component - databinding)?

    Hi all

    I'm moving some width/height/URL of a Video Player component to a Social Bookmarking component incorporate text entry field. (for people capture and share videos).

    I know that it's a simple task, but it's the end of the day and I seem to have a brain failure... What is the syntax to achieve this? Do I have to import the video player component? These widths/heights/URLs are all generated dynamically by a XML... should I be pulling the XML or reuse just variables already existing in the Video Player component?

    Here is my code...

    Video player:

    [Bindable]

    var public source: String = "";

    [Bindable]

    public var autoPlay:Boolean = false;

    [Bindable]

    public var fullScreenMode:Boolean = false;

    [Bindable]

    public var clipTag:String = '_movie;

    [Bindable]

    public var iag_code:String = "";

    [Bindable]

    public var officialURL:String = "http://www.movies.com/"; ""

    [Bindable]

    public var referer:String = 'unknown ';

    [Bindable]

    public var gID: String;

    [Bindable]

    public var starterImageURL:String = 'http://www.movies.com/jazzmaster/images/default_starter_image.

    [Bindable]

    public var oldWidth:Number;

    [Bindable]

    public var oldHeight:Number;

    Component sharing:

    < mx:HBox

    Height = "10%".

    horizontalCenter = "-25".

    Red = '0 '.

    paddingBottom = "5" >

    < mx:Text text = "" Embed Code: "paddingTop ="1"color ="#FFFFFF"fontSize ="12"/ >"

    < mx:TextInput text = "{oldWidth}" / >

    < / mx:HBox >

    The above code generates an error... "Any attempt of property inaccessible oldWidth via a reference with a static type com:SharingBookmarks."

    Thank you all!

    DK

    Try this...

    Create a flex project and add a folder called 'src '.

    create a new component MXML named "VideoComp.mxml" and copy/paste

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

    [Bindable]

    public var videoWidth:int = 300;

    [Bindable]

    public var videoHeight:int = 300;

    ]]>

    create a new component MXML named "SharingComp.mxml" add copy/paste this...

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

    [Bindable]

    public var videoWidth:int;

    [Bindable]

    public var videoHeight:int;

    ]]>

    and here's the main.mxml file

    http://www.Adobe.com/2006/mxml '.

    xmlns:src = "src.*" >

    private void doSomething (): void

    {

    sharingComp.videoHeight = videoComp.videoHeight;

    sharingComp.videoWidth = videoComp.videoWidth;

    }

    ]]>

    Hope this helps,

    BaBo,

  • to access the variables in a page in another page qml

    Hey gang,

    I've been watching some of the other problems autour to access the variables from one page on another page qml qml, and I can't get this to work.

    I have a page, main.qml with a NavigationPane.  The NavPane has a Page and some containers.

    I have a property defined in the NavigationPane like this:

    NavigationPane {
        id: mainNav
        backButtonsVisible: true
        property int customInt: 2
    
        onCustomInt: {
            console.log("  -------------> App: customInt");
        }
    

    I have a ComponentDefinition for next page, called SettingsPage.qml.  In the settings, I have two drop-down lists and a slider.

    Page {
        actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll
        id: pgSettings
    
        ScrollView {
            id: pageScroller
            scrollViewProperties.initialScalingMethod: ScalingMethod.AspectFit
            Container {
                topPadding: 25
                bottomPadding: 25
                rightPadding: 25
                leftPadding: 25
                Label {
                    text: "Settings"
                    textStyle.fontSize: FontSize.XLarge
                }
            Container {
                id: dropDown1
                topPadding: 25
                bottomPadding: 25
                rightPadding: 25
                leftPadding: 25
                DropDown {
                       id: ddOption1
                       title: "Option 1"
                       verticalAlignment: VerticalAlignment.Center
                       horizontalAlignment: HorizontalAlignment.Center
                      Option {id: o1o1; text: "One"; }
                      Option {id: o1o2; text: "Two"; }
                      Option {id: o1o3; text: "Three"; selected: true; }
                      Option {id: o1o4; text: "Four"; }
    
                    onSelectedIndexChanged: {
    
                        switch (selectedIndex){
                            case 0:
                                //
                                console.log(" -->App: Option 1 Selector, On");
                                customInt = 0;
                                break;
                            case 1:
                                //
                                console.log(" -->App: Option 1 Selector, Off");
                                customInt = 1;;
                                break;
                            case 2:
                                //
                                console.log(" -->App: Option 1 Selector, Top (default)");
                                customInt = 2;
                                break;
                            case 3:
                                //
                                console.log(" -->App: Option 1 Selector, Bottom");
                                customInt = 3;
                                break;
                        }
                    }
                }
            } }
    

    I look forward to the the statement will change the level property NavPane, called customInt, but it doesn't.

    the output of the console shows that the ' App: Option 1 selector "gets selected in the dropdown list selected index changes, but the onCustomInt() funtion slot never gets called.

    I tried "mainNav.customInt = X" too, but the parameters cannot solve the mainNav.  I get "unknown symbol 'mainNav'" error with alittle bulb.

    what I am doing wrong?

    When you call the second page, SettingsPage.qml, set it as an object.

    Don't do the following:

    attachedObjects: [
    
        ComponentDefinition {
            id: settingsPageDefinition
            source: "SettingsPage.qml"
        }
    ]
    

    Follow these steps:

    attachedObjects: [
        // Definition of the second Page, used to dynamically create the Page above.
        ComponentDefinition {
            id: settingsPageDefinition
            Settingspage{
    
            }
        }
    ]
    

    Then the second page main navigation page in the IDE.  I had the same problem with a multi-page application, I created.

  • 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 a variable from outside a function

    Hey everybody!

    I am so confused. I hope that someone can help me here! I try to call the variable named "time' go outside a function. '"

    Here is my code:

    var myXML:XML = new XML();

    var XML_URL:String = 'youtube - time.xml";

    var myXMLURL:URLRequest = new URLRequest (XML_URL);

    var myLoader:URLLoader = new URLLoader (myXMLURL);

    myLoader.addEventListener (Event.COMPLETE, xmlLoaded);

    var time;

    function xmlLoaded(event:Event):void

    {

    time = XML (myLoader.data);

    }

    trace (Time);

    Here's what my XML looks like:

    10 < time > < / time >

    Whenever I run the trace (time); outside the service - I get an "undefined" message in the output window.

    How can I access the variable " " time "outside my service so I can assign to another variable like this: "

    var VIDEOS_SECONDS = time;

    Thank you very much for any help!

    Timothy

    Functions are called, the variables are accessible.

    First thing you need to do is to check that xmlLoaded is actually called. Copy your trace statement to test. If you never actually call the .load method on your URLLoader object, as suggested by Colin, nothing will never load.

    Second, if your code snippet above is literally everything from an image and run correctly, then most likely your trace statement executes before the XML loading data are completed. URLLoader runs asynchronously, which means that your main code stream do NOT stop and wait until she finishes.

  • What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Hi all

    I am new to TestStand. Still in the learning process.

    What are the parameters? How are Variables differenet? Why we can not use variables to pass data to one sequnece to another? What is the advantage to use parameters instead of Variables?

    Thanks in advance,

    LaVIEWan

    I'm sorry... I discovered that... its not at all possible to pass data to another sequence using variables... it must be through settings... once again I apologize for the display of such a stupid question

  • Call a variable to another variable (alphanumeric)

    Hi all
    I have the scenario where I call a variable to another variable in ODI.

    For example.

    Lets say I have two variables V_SET1 & V_SET2

    V_SET1:
    Variable type: alphanumeric, Historize,.
    Refreshing: SELECT #V_SET1 FROM DUAL to historize value.

    Now I use V_SET1 in V_SET2
    V_SET2:
    Variable type: alphanumeric, Historize,.
    Refreshing:
    Select EXTRACT_PGSQL_DETAIL where OE_DETAILS = SOURCE_NAME # V_SET1

    The two variables are inside the script I'm passing V_SET1 value at runtime as a parameter 'TEST '.

    V_SET1 is running successfully & TEST is stored is historical


    BUT V_SET2 V_SET1 value happens in "quotes & I'm mistake geeting IDENTIFIERS INVALID"TEST"

    Select EXTRACT_PGSQL_DETAIL where OE_DETAILS = SOURCE_NAME # V_SET1 ('TEST') - identifier inavlid error.

    How can I convert the value of the TEST of 'TEST' to 'TEST' in the second Variable V_SET

    Published by: neeraj_singh on June 24, 2011 03:15

    Hello

    Try this if not,.

    Select SOURCE_NAME from EXTRACT_PGSQL_DETAIL where OE_DETAILS = '#V_SET1. '

    Thank you
    Guru

  • Call one report of another

    Hello

    Reports * 10 g * is it possible to call one report of another? So I have a button on a report, and how do I call another report? (with some parameter of the calling report). I know in Developer 2000 it is possible, but in 10g (which is based on the web I've heard is not possible).

    Please give me an answer if you know.

    Thank you

    Hello

    Several documents are available in "My Oracle Support":

    Tips for using hyperlinks in Drill Down reports (Doc ID 756110.1)
    How to design dynamic Drilldown Web Hyperlink reports (Doc ID 109507.1)
    How to create Drill Down Web of relationships using hyperlinks (Doc ID 160262.1)
    ...

    Concerning

  • Adaptation of one fla to another MovieClip doesn't work well

    I copied a movieclip of one fla to another. The copy itself seems to have worked but when I call mysprite.addChild (mymovieclip), I get the child parameter must be non-null.

    Is there more that needs to be done to get the created clip?

    In the code you gave mymovieclip is a variable name, not a type. If mymovieclip is the name of link try this instead:

    var mc:mymovieclip = new mymovieclip();

    You can also if you try to make a class for your symbol your class needs to extend MovieClip and then set you it as a base class in the Advanced Properties window.

  • Conversion of scripts from one domain to another

    Back to the pre OpenScript versions (v8), there used to be a utility (under the Tools menu) to convert the scripts. This would be useful for example when migrating a script from one environment to another (for a script can be used in a production environment?) However, this feature is not currently available in recent versions.

    I realize, you can try to do a global find/replace in the Java code, but it doesn't seem to be as simple as replacing the root of the URL like this leaves the issues with dynamic variables is most recognized (I get losts of messages "Could not be resolved" if I try this exercise).

    Is there a simple way to edit a script of 'https://URLA/application' to 'http://URLB/application '?

    NOTE: In the example above I also changed from HTTPS to HTTP simple.

    In 9.2 under Tools, there is an option called URL set... You select this option and it will display the URL of the application and a text field where you can enter a variable name. Then you can select all instances of this URL and OpenScript will be replaced by the variable. Once done you will have code such as

    Initialize the Section
    getVariables () .set ("bilbobaggins", "http://www.scl.com",
    Variables.Scope.GLOBAL);

    and in the running section you would have something like

    Web.Window (2, "/ web: window [@index = '0' or @title =' about: blank']")
    . Navigate (' {{bilbobaggins, http://www.scl.com}} / OA_HTML/RF.jsp "" ");
    Web.Window (4, "/ web:window[@index='0" or @title = 'Login'] "")
    .waitForPage (null);

    Notice it will return the variable and also have the saved value. So if you want to play against another environment just to change the value of the variable and replay.

    Hope this helps

    Concerning

    Wayne.

    Published by: byrne_wayne on January 11, 2011 15:16

  • Referencing variables in a function without causing 'access undefined... '. "

    I have a function called once creates new variables

    function createPane(event:Event):void
    {
         var manager:IPaneManager = map.getPaneManager();
         var markerPane:IPane = manager.getPaneById(1);
         var markerIndex:int = manager.getPaneIndex(markerPane);
         var pane:IPane = manager.createPane(markerIndex);
    }
    

    I have another function that refers to some of the variables created in the function above

    function paneClear(e:MouseEvent):void
    {
         manager.removePane(pane); 
    }
    

    If I have both in my code, FLASH will throw an error because the variable Manager and the pane are not created until the createPane function is called.  I understand that if I created these variables outside a function, this error does not happen, but this isn't an option that I have to wait to call createPane.

    I also found that if I embed the function of paneClear within the createPane function, I will not get an error (see below).  I thought that the nesting of functions is bad practice, so I'm Director of this approach.

    function createPane(event:Event):void
    {
         var manager:IPaneManager = map.getPaneManager();
         var markerPane:IPane = manager.getPaneById(1);
         var markerIndex:int = manager.getPaneIndex(markerPane);
         var pane:IPane = manager.createPane(markerIndex);
              function paneClear(e:MouseEvent):void{
              manager.removePane(pane); 
              }
    }
    

    I hope this explains my situation clearly.  I'm just trying to understand how you can reference a variable in a function, even if this variable has not yet been created.

    Thanks in advance,

    Josh

    What you would normally do, is to declare the variable outside the function and assign the value inside...

    var Manager: IPaneManager;
    var markerPane:IPane;
    var markerIndex:int;
    var component: IPane;

    function createPane(event:Event):void
    {
    Director = map.getPaneManager ();
    markerPane = manager.getPaneById (1);
    markerIndex:int = manager.getPaneIndex (markerPane);
    component = manager.createPane (markerIndex);
    }

  • How to pass the variable to a swf into another swf

    I declared a variable in the one.fla file

    I open another file swf on a button.

    the code is as follows

    name = 'personName ';

    myButton.onRelease = function () {}

    trace ("liberation" + name);     personName

    loadMovie ("mainPage.swf", _root);

    _root.loadMovie ("mainPage.swf");

    }

    I want the variable 'name' of access to another swf file. IE (mainPage.swf)

    How do I do that?

    You want to use the MoveClipLoader class (using loadClip() and addListener methods) rather than loadMovie so that you can wait for the file to load before you try to access anything in it.  You can create an empty movieclip to load the SWF in, and in this way the loaded file can be targeted using the empty movieclip instance name.

Maybe you are looking for