By passing a string as the name of a function of mouse event listener?

Hello

I am trying to essentially pass a string as a function name in an event listener, but I do not know how to approach the issue.  Is there a way to convert a string to a function?  I don't know how to Word my question, so I apologize.

Here's some code I have for me to show you what I'm doing.

package {}

some import declarations

public class changes extends MovieClip {}

var functionName:String
var aBox: Sprite;

public void changes() {}

nomfonction = "hemagg";

createButtonBox (16, 16, 32, 32, functionName);

}

public void createButtonBox (anX:Number, aY: number, aWidth:Number, aHeight:Number, aFunction:String) {}


aBox = new Sprite();
Some code for box drawing

aBox.addEventListener (MouseEvent.CLICK, [aFunction] ())?

addChild (aBox)

}

public void aFunction(event:MouseEvent) {}

trace ("test");

}

}

}

I'm on the right track, or is not possible?

Anyway, thanks in advance.

If you pass a string representing a function name, then you must use the notation of support to have this interpreted as an object/function string.  Try to use...

aButton.addEventListener (MouseEvent.CLICK, this [functionToCallTo]);

Tags: Adobe Animate

Similar Questions

  • How to pass a string as the name of MovieClip?

    Hello world! I'm back with more doubts

    I created 4 buttons with 4 animations each, one for each State (using interpolations), so I have this list of 16 "addEventListeners" enourmous (do not know if there is another way to do it). But everything works as I want.

    The problem is that I am creating only 4 functions for dealing with all 4 keys and these 16 eventListeners.

    This is part of my file AS3 (always with the ' traces', 5 seconds of the animation to see animations and all).

    empresa_btn.addEventListener(MouseEvent.MOUSE_OVER, isOver);
    empresa_btn.addEventListener(MouseEvent.MOUSE_OUT, isOut);
    empresa_btn.addEventListener(MouseEvent.MOUSE_DOWN, isDown);
    empresa_btn.addEventListener(MouseEvent.MOUSE_UP, isUp);

    parceiros_btn.addEventListener(MouseEvent.MOUSE_OVER, isOver);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_OUT, isOut);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_DOWN, isDown);
    parceiros_btn.addEventListener(MouseEvent.MOUSE_UP, isUp);

    var mouseState:String;
    var mouseActive:String;
    var txt:String;

    empresa_btn.over.alpha = 0; empresa_btn.down.alpha = 0;
    parceiros_btn.over.alpha = 0; parceiros_btn.down.alpha = 0;

    function isOver (e:MouseEvent):void {
         mouseActive = e.currentTarget.name;
         mouseState = "isOver";
         trace (mouseActive + " " + mouseState);
         var isOver:Tween = new Tween(empresa_btn.over, "alpha", Strong.easeOut, empresa_btn.over.alpha, 1, 5, true);
    }

    function isOut (e:MouseEvent):void {
         mouseActive = e.currentTarget.name;
         mouseState = "isOut";
         trace (mouseActive + " " + mouseState);
         var isOut:Tween = new Tween(empresa_btn.over, "alpha", Strong.easeOut, empresa_btn.over.alpha, 0, 5, true);
    }

    Now, what I'm trying to do, is use the var 'mouseActive' which returns the names of right button inside the interpolation as the clips.

    The problem is that the 'e.currentTarget.name' is not the 'movieClip' itself... it is just a string with the name of the movieClip.

    Example: whenever I try to do something like this:

    var isOut:Tween = new Tween(mouseActive.over, "alpha", Strong.easeOut, mouseActive.over.alpha, 0, 5, true);

    It will return an error to the cause, as I said, mouseActive is not a clip, it's just a string (at least I think).


    Thank you already support (new)

    And mind to please my nickname

    Here's what I offer before raised the potential issue of button...

    Try:

    var mouseActive:MovieClip;

    function isOver (e:MouseEvent): void {}
    mouseActive = MovieClip (e.currentTarget) .more;
    mouseState = "isOver".
    trace (mouseActive + "" + mouseState); comment this out at the moment
    var isOver:Tween = new Tween (mouseActive, "alpha", Strong.easeOut, mouseActive.alpha, 1, 5, true);
    }

  • random string after the name of the application installing app webworks

    Hello

    I have my webworks named "com.dev.improve" app, but when I run webworks run to run the project and deploy it on my phone, the terminal theres a list of info logs, which says:

    [INFO] Installing com.dev.improve.testDev_dev_improve2ba0b1c0...

    Why am I this weird string after my app name? What can I remove prossibly?

    Thank you

    This is the Package Id for your application.  You can see by opening the BAR file in a program such as WinZip and open the META-INF/TRANSLATED. MF file in a text editor.

    For unsigned files BAR, it's a dummy value to always start with test.

    Signed BAR files from the Package Id is generated based on the name of the Package you specify (com.dev.improve in your case) and your signature account.  This creates a value unique for each application and use the device to determine whether a BAR file being installed is a new application or an upgrade of an existing application.

  • Area hideShowHeader: how to get the name of region on Hide/Show Event

    Hello

    I would like to retrieve the name of the region (hideShowHeader) when I click on the hide/show icon. I know how to catch the event but some OAWebBeanConstants I always check null... any idea?

    Thank you very much, Pier Paolo.

    Hello

    Try to print below in LIC...

    System.out.println ("name of the event:" + pageContext.getParameter (OAWebBeanConstants.EVENT_PARAM));
    System.out.println ("the Source of the event:" + pageContext.getParameter (OAWebBeanConstants.SOURCE_PARAM));
    System.out.println ("value:" + pageContext.getParameter (OAWebBeanConstants.VALUE_PARAM));

    Thank you
    Mukesh Uchaniya

  • the transparent parts of component prevents mouse events

    Hello

    I work with a bunch of components that are superimposed on top of eachother.

    Some of the components are odd-shaped and with a transparent background.

    When I try to click on items that are causing others the mouse event is not fireing.

    is there a way I can fix this?

    Drew

    There is a difference between transparent and no background background.  If I take a Sprite and draw a triangle filled like this:

    moveTo (0,0)

    lineTo (100, 100)

    lineTo (100, 0)

    lineTo (0,0)

    Then any component under half, I don't draw is 'visible' mouse and my Sprite get not mouse events.

    If I fill this area with a background with alpha = 0, so I actually placed a piece of glass in my component and it will get the mouse events, even if you can see through things behind him.

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • Hello. How can I pass a variable as the name of file in writeStringToFile.

    When I try to pass a variable as writeStringToFile it is ignored.

    For example:

    getVariables () .set ("ts", "{{@today (YYYYMMddHHmmss)}}", Variables.Scope.GLOBAL);

    Path String = "C:\\OracleATS\\OFT\\Databank\\";

    String file = "test .csv {{ts}}";

    String completedOrders = path + file;

    Info (completedOrders);

    utilities.getFileService (.writeStringToFile) (file, "CreatedDate, customer, iteration, OrderNumber" + "\n");

    In the previous case.

    a. the console returns the correct file name: C:\OracleATS\OFT\Databank\test20151005133343.csv

    b. the file system will not be: test .csv {{ts}}

    Thank you for taking the time to consider the issue. I found another way to achieve this. It must be as follows:

    Import:

    import java.util.Date;

    import impossible;

    Format of date as follows:

    Path String = "C:\\OracleATS\\OFT\\Databank\\";

    String file = new SimpleDateFormat("'scriptOut_'YYYYMMddHHmmss'.csv'").format (new Date());

    String completedOrders = path + file;

    Info (completedOrders);

    utilities.getFileService () .writeStringToFile (completedOrders, 'CreatedDate, customer, iteration, OrderNumber "+" \n");

  • class string for the name operation

    Hi, suppose I have three classes with names like

    enemy1

    enemy2

    enemy3

    and a table enemyIndices = [1,1,2,2,3,1,2] or something like that.  Is it possible to compose on the fly class names so that I can write something like

    for (i = 1; i < = enemyIndices.length; i ++)

    {

    var className:String = enemy + i;

    var obj:Object = new className(); / / to create enemy1 etc.

    } ?

    Of course, I can use if... else statement to achieve this

    if(i==1)

    new enemy1();

    another if (i == 2)

    new enemy2();

    another if (i is 3)

    new enemy3();

    You can use (I assume you mean to use the numbers in the table, not only its length)...

    for (var i: uint = 1; i<= enemyindices.length;="">

    {

    var ClassRef: Class = Class (getDefinitionByName ("enemy" + String (enemyIndices [i])));
    var obj: * = new ClassRef();
    addChild (obj);

    }

  • Read a string as the name of a table

    Well... lets say ive got a code like this...
    (it is the AS2)

    How could I get the track to the output data in the table instead of just "map1"?

    You can do it like that. If you want something different than the join of standard comma to the top level of the table, you can use the join method to create other separators (including carriage return, etc.)

  • Select and delete the elements of an array using mouse events

    Hello

    I am trying to write a code that allows the user to select or remove items from a table to a table in another table. IE, choose what files will be used in later analysis. Selection work ok (using the mouse to select from the table 'files available'), but my deletion section requires an extra mouse click before you update the "trial to use the chart", which causes a lag.

    I really don't see why two events are handled differently in what concerns updating the 'trial to use the table.

    Help, please!

    Thank you

    Graham

    Graham,

    Add an event to the event of value case changed the Stop button. Use it to stop the loop. The way in which your VI is set up two events are necessary after you press Stop until the loop stops. Turn on execution highlighting, and watch what happens to see why.

    In addition, the mechanical Action typical for the stop buttons is latch when released.

    Why not use a ListBox to tests available with SelectionMode is set to 0 or more items? Its output is an array of indexes of names of point.

    Lynn

  • Pass the name of the table to report dynamically?

    I'm looking for any method any table name for a sql statement through an independent written report.

    a short example:
    I'm trying to create a report that lets me select a column in a table - time (column and table) should be provided in time, the report is run.
    Of course, something like
    select :column
    from :table
    does not work; the error is ORA-01745.

    Is someone know a method to pass a string to the variable in the SQL before the cursor created?

    You cannot use LIE in FROM apparently, although I am struggling to find that explicitly in the DOCs, then you need to use & or & in your query of dynamic report OF clauses.

  • "1 MHz" for the name of the source on the time loop does not work on LabVIEW Real-time 9.0

    A Loopis Timed running as expected if a time source is manually chosen in the dialog box of configuration for "1 kHz" (first digit) and "1 MHz" (second digit). If the time Source name is set through the input of the channel "1 kHz", the loop is executed, too third figure). But if the input string is "1 MHz", the loop is not executed (last figure). The channel two are created by "create constant" on the entry of the loop to exclude typos. Is it possible to set the Source of a loop time timed through the input string to the real-time clock hard Mhz?

    OK, I was a bit confused by the difference between the behavior of error...

    Now, the question is quite clear. Aid for the timed loop provides the following regarding the Source of the calendar entry:

    Specifies the name of the synchronization source to use to control the structure. The source of synchronization must be created using the create synchronization Source VI on the block diagram or selected in the dialog box Configure the timed loop .

    So, I think that you have somewhere in your code a time Source.VI create if you pass "1 kHz" as the name. But you did not do this for your clock "MHz 1"...

    hope this helps,

    Norbert

  • Retrieves the name of the variable

    Hello

    I'm trying to change the OpenG changed? Subvi (see below) so that he will write the new value of the variable sent to 'Variant' if changed on the disk (using the following config VI). To do this, I need to somehow extract the variable name of the variable (any type) which was connected to the entrance of variant of the changed? Sub - VI by VI calling so that I can use it as a key name. Is this possible? This information is still transmitted to the Subvi?

    If you use openg, there is a "Get the name of data" function that retrieves the name of the data passed in the Variant.

  • Can after get values a RGB pixel, hoe I write the name of the color?

    Team,

    I'm quite new to LabVIEW and I'm working on an application using USB webcam to capture the color of the object.

    So far, it's finished, but now I need to write the name of the color on the screen.

    Please, could someone help identify if IMAQ or Labview have this feature?

    For help in understanding:

    Below you can see the example.

    R = 236

    G = 0

    B = 116

    And the name of the color is pink.

    But the problem is how to get the name by using certain features available.

    Thank you.

    Kind regards

    JCG

    There is not such a function, but you can create a pretty easily.

    I would divide each color component by 64 and to get a value of 2 bits for each color.  Combining these (multiply/shift and add) would give you a 6-bit integer, which gives you 64 color combinations.  Create an array of 64 strings with the names of the colors and the correct name indexes.  You need to browse manually the first time and assign a name to each color, but that wouldn't be too bad.

    Bruce

  • Getting the name of the tab

    Version: 4.1.1.00.23

    Hey,.

    I need to enter the name of the tab when it is selected. Is it possible to do this?

    I created the dynamic breadcrumbs and when the user clicks on the tab to access a page elements application used to hold the values for the path of the site map don't are not cleared. When the user clicks a tab to go to the page directly the path of the site plan is the last entry created in the trail, but it should be the only entry in the navigation path.

    for example: user is working on 1 Page and clicks a button put on page 2 and the breadcrumb will be Page 1 > Page 2.

    However, if the user clicks a tab to go directly to page 2, the navigation bar should be just the Page 2 and it is showing Page 1 > Page 2 and this is because the application parts contain the values are not cleared.

    Does anyone have a solution to this?

    Thank you.

    Parth.

    psampat wrote:

    Version: 4.1.1.00.23

    Hey,.

    I need to enter the name of the tab when it is selected. Is it possible to do this?

    If there is a standard tab then the value of the built-in substitution REQUEST string is the name of the tab when selected.

    Otherwise, query view APEX_APPLICATION_TABS using page ID in a process of calculation/forward header in the destination page, something like:

    select
              aat.*
    from
              apex_application_tabs aat
    where
              aat.application_id = :app_id
    and       (   aat.tab_page = :app_page_id
               or instr(
                      ',' || aat.tab_also_current_for_pages || ','
                    , ',' || :app_page_id || ',') > 0)
    
  • Getting the name of the variable?

    Hi, is it possible to get the name of the defined variable?

    for example

    var description:String = "Some description";
    var variableName = getVariableName(description);
    trace(variableName); // output = "description"
    
    

    Thank you

    You can retrieve the xmllist of the variables (string or otherwise), of any object (for example, the current timeline) using the following function.  each item in the list has a property of type with the name property:

    function variableF(o:Object):XMLList {}

    .variable describeType (o) return;

    }

Maybe you are looking for

  • Is Satellite P100 does support Windows 7?

    Satellite P300-373 does support Windows 7?

  • Satellite L100 113 - HARD drive upgrade

    I want to convert the disc on the laptop 60 GB to 250 GB.If it is possible?, flat main (motherboard) some limitations to disk?Plan to buy Samsung 250 GB 2.5 '7200 obr, SATA, 16 MB. Thank for the answer.

  • [K3 note] Game performance

    It is very annoying that despite the K3 NOTE have 2gigs of ram and gpu Mali his lag so...High-end as asphalt 8, Nova 3, BIA 3 gal and don't all games are not playable, my other phone has Mali 400 mp, which performs better than this,Software updates (

  • Moto g4 play glass protection

    Hey Any of you know if the g4 bike game will be scratch-resistant glass? Other models have protection Corning Gorilla, but I'm guessing that this model does not have it. Thank you all for the help.

  • The Photosmart 7525 Airprint is compatible?

    I've implemented several HP airprint compatible printers before, and none of them had problems printing from Apple devices.  This, however, does not appear on any device.  2 iPhone and an iPad.  ePrint works, even if it's not super well and obviously