Several buttons and dynamic (?) EventListener

Hello world

I put 10 buttons on my stage, name it "b1", "b2", "b3", "b10".

All of these buttons should use the same function.

Is it possible to dynamically?

var r: Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

for (var i = 0; i <.) Length; i ++) {}

button = "b" + a [i];

This [button] .addEventListener (MouseEvent.CLICK, onClick_b);

function onClick_b(pEvt: Event): void {}

my_mc. Play();

}

}

The service plays only the 'b10' button.

Someone at - it an idea how all other buttons serve this function?

Thank you! C.

what you want is:

for (var i = 0; i)< a.length;="" i++)="">

getChildByName("b"_+_a[i]).addEventListener (MouseEvent.CLICK, onClick_b);

}

Tags: Adobe Animate

Similar Questions

  • Several buttons and an EventListener

    Hello world

    I put 10 buttons on my stage, name it "b1", "b2", "b3", "b10".

    All of these buttons should use the same function.

    Is it possible to dynamically?

    var r: Array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

    for (var i = 0; i <.) Length; i ++) {}

    button = "b" + a [i];

    This [button] .addEventListener (MouseEvent.CLICK, onClick_b);

    function onClick_b(pEvt: Event): void {}

    my_mc. Play();

    }

    }

    Only the button 'b10' play my function.

    Someone at - it an idea how all other buttons serve this function?

    Thank you! C.

    If you want to use the table 'a' then your for loop just needs to be:

    var a: Array = new Array (bone, btwo, bthree);

    for (var i in a) {}

    a [i] .addEventListener (MouseEvent.Click, onClick_b);

    }

    The line key = 'b' + a [i]; has several problems. You not report 'button' to be a variable, then you will probably get an error. Using the button is not necessary in all cases. The part, "b" + a [i]; feel bad a letter b for each of the elements of the array. The problem with that is that you end up with a string. When you try to add an event listener to this string, you will get another error.

    The names of instances of objects on the stage are not strings, they are values of property and so they are not presented with quotes around them. A button instance on the stage with an os name, or adeux, just shows that, OS, not "BONES", in the code.

  • CP4 - Pause a slide with several buttons and continue after clicking a specific button

    Hi all

    I know that a break has been discussed, with the idea that you can use a clickbox (tiny/transparent) to pause the slide in CP4.

    My problem is that I have a few buttons to show/hide a scenario/question in a slide that is suspended with a clickbox.  I would like a particular button to advance the slide (for example, the button 'Next').  Currently * any * button will UN-pause the slide even if all the buttons use advanced actions and are not defined for advnace slide to the click.

    Basically, I want to achieve this goal:

    http://kb2.Adobe.com/community/publishing/871/cpsid_87182.html

    Scroll down for the film and ignore everything apart as a result of clicking on the US/Europe/ISO buttons, you don't advance the slide. (I don't like on all counters/times etc.).

    BB

    (just in case it is useful to my slide includes):

    (1) invisible clickbox to pause at the top of the timeline (i.e. "put on the map"

    (2) an another clickbox with a legend of success/failure (that I want to advance the slide)

    (3) a "Hide" button that hides the name of a legend and shows another button (all with a tip action)

    (4) a "show" button that shows the 'hide' button and the legend (by peak action)

    (5) a couple of areas of turnover used to mimic navigation so that the user can click in the right place for (2).

    )

    Hello

    What's you point to one of my articles? Oh, I see now you are intrigued by the little film. It was created with Captivate 5 and CP4 is a little heavier.

    I just answered a question similar, but explained by adapting the user file. He wanted to have several areas to click that showed a text caption and offer the user the opportunity to click as many times as he wanted to in order any on those select boxes. Only when you click on the continue button (or click box), there should be a navigation to the next slide. If I understand you correctly, this is a similar case?

    My workflow: do NOT use multiple actions for areas of click to show/hide captions. He must not trust at all, and in addition you must go back the playback head to avoid it continues after clicking on a CB. Create a tip action for every click like this screenshot:

    Here, a single text of the legend was hidden, but can be extended to many of course. The last instruction (assignment) is important: it puts the read head back a frame, so that it remains before the point of interruption.

    I blogged about this type of micro-navigation once, but the examples are for CP5 and later versions:

    Micro-navigation in Captivate

    Lilybiri

  • Button and dynamic Actions

    Hi all
    I need to hide/show buttons with dynamic action, in the Actions of true/false, I tried with the object DOM and selector withjQuery, but it does not work.

    Can someone help me, please?
    Sergio

    Sergio,

    As you guessed, buttons are currently not well supported with dynamic actions, something we hope to treat in the future. However, it is possible to work around this problem. First of all, I assume that you use the "Template" based keys: and not "HTML". The "HTML" buttons automatically generate an ID set to the value of the button name, so if you tried to use "DOM object" with the value of button name, then this should have worked. The "HTML Code" buttons are certainly easier to control with dynamic actions, however if you're set on using the buttons "Template" based, it is a bit more complicated, but still possible.

    The fundamental problem is that "Template" based button generate an ID has the default value, and the simplest for dynamic steps control the individual buttons (and any element) is by referencing by ID. In addition, there is no substitution string available in the template of the button to the name of the button (only LINK, LABEL, BUTTON_ATTRIBUTES, and BUTTON_ID), so you can't do this on the side of the model. (I know there is a BUTTON_ID, but it is the internal ID, and it is a different set of challenges, I don't think it's better to continue to do this). If we want to give the button ID, the name of the button. To do this:

    • Make sure that the substitution string #BUTTON_ATTRIBUTES # is included in your button template, something like:

      
      


    • In your button, verify that the template is selected, and then you have to specify the ID attribute, whose value can be given in the field "attributes button" the same as the name of the button:

      id="my_button"
      

      You encounter so, essentially, to reproduce the name of the button, as well in the name of the button and the added value of ID ideally, you'd be able to do this in the model, as explained, but this is not possible.


    • Now, you can reference this button against the 'affected elements' dynamic actions, using a selection of type "Object DOM" and the value of the button name / ID specified.

    Sorry it's a bit lengthy. As explained, based HTML buttons are certainly easier currently, you don't have to worry about all that extra work to get the generated ID, it's right there already. And in a later version of the SUMMIT, we want to allow just completely declarative selection of dynamic action buttons that work, without having to make these types of additional solutions.

    Hope that helps.

    Anthony.

  • Several buttons and rdcmndGotoFrame with rdinfoCurrentFrame

    I'm working on a project using the buttons and multiple advanced actions to allow users to make a self-assessment with a rating scale. The buttons are how they enter their rating.  I had the problem of when I clicked on one of the buttons it would advance the slide instead of wait for the user to click on the next button. I searched the forums and found the solution to use rdcmndGotoFrame with rdinfoCurrentFrame, that fixed my issue of the advance slide and let my rankings correspond correctly to the top.  But now I have the problem that the slides with side buttons do not play, even when none of the buttons were clicked to trigger rdcmndGotoFrame with rdinfoCurrentFrame.

    I would be very happy to help.  Thank you!

    Hi Laurie,

    Does not look further for the reason of corruption in this action InitSlide, but with a fresh mind have now some questions and answers:

    • the InitSlide action makes no sense at all; You must have misunderstood this other thread, because the variables that you are reset to 0 for each slide will be re-populated by actions on the various buttons. change the action on enter to the 3 critical thinking slides to continue (BTW, don't use not identical ID even for slides, when you use the button to its use in the interface the user advanced, Actions the same slide jumped 3 times, ID was quite confused until I realized that you used the same label on slide three times)
    • the variables that might perhaps need to reset to 0 are those which are incremented after each slide as v_Critical... (another tip: check the shorter labels...) ; but this can be necessary if you allow the user to resume all the slides; is this the case? Reset would be enough once, entering the first criticism... drag

    You do not have to stagger the buttons as you did on the first slide of critical thinking, with the statement that Rewinds the playhead in the tip action, they have the same point of suspension. Another tip (I was born as a sensei): label the buttons, if you graduate them before you create / label advanced actions, you can even use the same label for actions, makes it much easier to attach to buttons (what about Bt_CT1_1 for the first button on the first slide, Bt_CT2_7 for the seventh button on the second slide etc...)

    Does make sense?

    Lilybiri

  • Several buttons and a listener?

    Hello everyone, I basically have 3 buttons I need to have different actions. I tried to use separate listeners for each, but failed due to the error Illegalstateexception. Now, I tried to use if statements, but nothing happens when I click on them! Here is my code:

    import com.samples.toolkit.ui.container.VerticalButtonFieldSet;

    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.FieldChangeListener;
    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.component.ButtonField;
    Import net.rim.device.api.ui.container.MainScreen;

    /**
    * A class that extends the class screen, which offers default standard
    * BlackBerry GUI applications behavior.
    */
    / public final class screen extends StartScreen
    {
    /**
    * Creates a new object StartScreen
    */
    public StartScreen()
    {
    Set the displayed title of the screen
    setTitle ("start screen");
    VerticalButtonFieldSet buttonSetOne = new VerticalButtonFieldSet (USE_ALL_WIDTH);
    buttonSetOne.setMargin (15,15,15,15);
            
    final ButtonField newButton = new ButtonField ("New revision Guide", ButtonField.CONSUME_CLICK);
    final openButton ButtonField = new ButtonField ("existing Open Guide", ButtonField.CONSUME_CLICK ");
    final exitButton ButtonField is new ButtonField ("Quit the Application", ButtonField.CONSUME_CLICK);.
            
    newButton.setMargin (5,5,5,5);
    openButton.setMargin (5,5,5,5);
    exitButton.setMargin (5,5,5,5);
            
    buttonSetOne.add (newButton);
    buttonSetOne.add (openButton);
    buttonSetOne.add (exitButton);
            
    Add (buttonSetOne);
            
    buttonSetOne.setChangeListener (new FieldChangeListener() {}
    ' Public Sub fieldChanged (field field, int context) {}
    If (field is (newButton))
    {
    UiApplication.getUiApplication () .pushScreen (new ChooseLayout());
    }
    ElseIf (field == (openButton))
    {
    UiApplication.getUiApplication () .pushScreen (new GuideList());
    }
    If (field is (exitButton))
    {
    Close();
    }
    }
    } );
    }
    }

    When I tried to search for this problem, I saw that others had to make paintings for the buttons? Sorry, I'm just a beginner, and I have no idea what to change.

    Oh wow I didn't expect to be that simple! Right, so the three keys need to be addressed then, not the game real button... Thank you very much, Mr President!

  • Buttons and videos does not

    I have several buttons and videos related to each other.  When I click on a button, it will run only a video and not the video I want for this button.  Any help?

    Thank you

    Try if it works:

    SYM. $("Subdivision_-_20_sec_1") .css ({height: "200px", width: "300px"});

    SYM.$("Subdivision_-_20_sec_1") [0]. Play();

    HTH,

    Vivekuma

  • Redirect button AND perform the dynamic action

    Hello

    I use Oracle 11 g and Apex 4.2.2

    It could be a matter of beginners (but that's what I'm ;-)) but I'll ask anyway.

    I created a button and can "redirect to the Page in this application" in the section "Action when the button clicked" or select "defined by the dynamic Action."

    Is there a way to select "Redirect."... "AND run the SQL Code?

    This is exactly the situation that I was considering. You start at the apex (which means don't not offensively or anything like that) and so the concept of session state can still be fresh for you. Telling me where you're just complicates things for yourself.

    Why do you, or makes you think, that you need to run plsql in dynamic action first and then redirect the page?

    Running code plsql already involves tracking session state and would require the value of the required items on the server. Running WHAT PLSQL is on the side server, if a call should be made. Given that you want to redirect afterwards, the call should happen synchronously, IE make the browser wait the result in order to continue to the next step. A redirect will just tell the server to send the new page to you.

    So why would not just use a send page? A page sent will submit all values of item on the server and thus session state. You can use the values of calculation and validation processes and never worry about having properly put it. You can filter out inappropriate process etc. According to the values of query (for example submit) so no problem there. Finally, a branch should redirect you to the target page. Remember, a branch is a part too and is essentially a redirect server-side. Find yourself on your new page without problem really and just send 1 page (send page, get another back essentially).

    That said, I simply don't consider a dynamic action. It is useless to laregely here and creates more problems than is useful to review more.

    What you have now is to redirect the client to another page, but in the process, you have lost everything from the original page. No values are stored in the session to all State: no save manual to submit State or session page. Add the element to the redirect link doesn't work either, as the link is built during rendering and is not dynamic (so no ' regenerated' link when you click it).

    Again, I advise you to:

    -put the button to send the page

    -create a process after you submit and run your plsql code

    -create a branch to a point after the process and set it to redirect to the target page

    or

    -put the button to send the page

    -create a branch set up to redirect to the target page

    -create a process on the target page and run your plsql code (but be aware that it may have to be executed conditionally)

    There are several traps on session state, so when you feel better grasp it. Page submits are not all that bad.

  • Dynamic creation of buttons and events. Event was not working.

    Hi guys,.

    I am trying to create an application that will dynamically create buttons and events... Creating a button isn't a problem, but the event did not work. The code below is simple... 1. click on the button and it will create another button (dynamic)... If you click on the newly created button it should alert a test2...

    Anyone know how to implement this (which works )

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"> "
    < mx:Script >
    <! [CDATA]

    Mx.controls import. *;

    private void onLoad (): void
    {
    var btn:Button = null;
    //
    Test2();
    BTN = new Button();
    BTN.label = "test";
    btn.addEventListener ("click", test2);
    this.addChild (btn);
    }

    private void test2 (): void
    {
    Alert.Show ('test', 'test');
    }

    []] >
    < / mx:Script >
    < mx:HBox id = "testbox.foobar.com" x = "0" y = "154" width = "100%" >
    < mx:Button label = "click" = "onLoad()"; / >
    < / mx:HBox >

    < / mx:Application >

    Hi gretags,

    You forgot to specify the argument in the eventListener... that's why you are getting the runtime script error...

    Check the code below... Now the alert will appear...


    http://www.Adobe.com/2006/mxml"layout ="absolute">
       
                   
    Mx.controls import. *;
           
           
    private void onLoad (): void
    {
    var btn:Button = null;
    //
    Test2();
    BTN = new Button();
    BTN.label = "test";
    btn.addEventListener ("click", test2);
    this.addChild (btn);
    }
           
    private void test2(event:MouseEvent):void
    {
    Alert.Show ('test', 'test');
    }
           
           
    ]]>
        

       
           
       

       

    If this post answers your question or assistance, please mark it as such.

    Thank you

    Jean Claude Chari

  • Disappear several buttons to create the message window after installing Enigmail and GNUpg

    Hello.

    I decided to install the Thunderbird PGP module (Enigmail). During the installation, it was necessary to install additional software GnuPG. After restart Thunderbird in create message windows several buttons disappear as: fonts, links, etc. (see photo).

    I uninstalled Enigmail and GnuPG, but the situation with row of missing button has not changed.

    I installed the new Thunderbird software at the top of the old installation and don't change the situation with row of button disappeared.

    I repeat the installation on a new computer to get started with Thunderbird and after that with Enigmail and GNUPG and I got the same result with line disappears in create message window.

    Thank you in advance.
    Cryospin

    Enigmail works very well with HTML email. That's why default Enigmail to plain text message composition. The installation wizard did ask you if it
    should these settings and let you inspect these changes.
    You must undo the changes in the settings of your account under Composition & addressing. Just check "compose messages in HTML format.

  • How to use commons composition on-board charger to charge several compositions with a next button and back?

    I work on an interactive book and have set up each page as a separate publication on the edge.

    I use the common edge JS library to load several compositions in a main composition.

    You can see how it works here: edge Commons - Extension Library to animate Edge and Edge reflow. EdgeDocks.com

    The way in which the municipalities of edge tutorial is set up requires a button for each publication that I want to load. I'm interested in loading multiple compositions with a 'next' and 'back' button and a 'shot left, the "forehand" on the content symbol gesture loaded in each composition. I also have the characteristics of drag on the icon content do not interfere with the interactive elements on the charged composition.

    Please suggest a solution that works without adding additional scripts beyond the Commons of edges and jquery.

    Sort of. I use this code inside an action for a button symbol. But it does not work perfectly. Trying to debug.

    I would like to know if you have a bit of luck.

    Check if there is already a pageCounter

    If (typeof EC.pageCounter = "undefined") {}

    It does not exist, so initialize it to the first page

    EC.pageCounter = 2;

    }

    check if the page is only 1 digit - patch for single digit

    If (EC.pageCounter< 9)="">

    It is, so we need complete a 0 on the front.

    EC.pageCounterString = '0' + EC.pageCounter;

    for example, 01... 09,11,12, 13... 115, 222352...

    }

    else {}

    EC.pageCounterString = EC.pageCounter;

    }

    EC.loadComposition (EC.pageCounterString + "/ publish/web /" + EC.pageCounterString + ".html", sym.$("container"));

    EC.pageCounter = EC.pageCounter + 1;

    TODO for back - 1

  • Slide several boxes and align itself with several locations and reveal the button

    Hi I am developing a game where the user chooses from a range of boxes to the left of the screen and can drag the 3 of them separately from 3 boxes to right ther. each box can be moved anywhere, and the order is not important. Once the 3 boxes are all full, I want a new button to appear. I finished a tutorial and I have a box works perfectly, but no matter what I try, I can't work with several boxes and locations. Here is a list of the instance names of film clips more my actionscript. I have attached a link to the flash file. Any help would be really appreciated. See you soon

    LINK

    http://www.sainters.NET/flash_preview/flash_test/Flash test_v6.fla.zip

    INSTANCE NAMES

    1 box = 'circle_mc.

    Box 2 = "circle_mc2."

    the two grey boxes are called = "targetCircle."

    ACTIONSCRIPT

    function dragSetup (clip, targ) {}
    clip.onPress = function() {}
    startDrag (this);
    this.beingDragged = true;
    };

    clip.onRelease = clip.onReleaseOutside = function () {}
    stopDrag();
    this.beingDragged = false;
    If (eval (this._droptarget) == targ) {}
    this.onTarget = true;
    _root. Targ.gotoAndStop (2);
    } else {}
    this.onTarget = false;
    _root. Targ.gotoAndStop (1);
    }
    };
    the following variables can store the start position of clips
    clip.myHomeX = clip._x;
    clip.myHomeY = clip._y;
    the variables below are going to store the position of end of clips
    clip.myFinalX = targ._x;
    clip.myFinalY = targ._y;
    clip.onEnterFrame = function() {}
    all these actions basically just to say "If the mouse is in place (in other words - the clip is not moved).
    then replace the MC to its original start (with a smooth movement) point ".
    If (! this.beingDragged & &! this.onTarget) {}
    This ._x-= (this._x-this.myHomeX)/5;
    This ._y-= (this._y-this.myHomeY)/5;
    If the circle is moved on any part of the target, it slides toward the center of the target
    } else if (! this.beingDragged & & this.onTarget) {}
    This ._x-= (this._x-this.myFinalX)/5;
    This ._y-= (this._y-this.myFinalY)/5;
    }
    };
    }

    dragSetup (circle_mc, targetCircle);

    You can probably do all the things you want to do.  I will make them for you well.  Trying to figure out how what I've provided works and then try to reason things for the changes you want to perform.

  • Safari, showing buttons and titles of different language

    I have a problem that Safari shows some titles and buttons in a weird language. When I copy the title it sticks as an Englishman. I set the language as British English in language preferences. Also, I deleted the extensions, and he has not made a difference. I changed same encoding of text in several languages and it is yet to make a difference. Here are some pictures to illustrate.

    OOpen the application book fonts in Applications, file > restore the standard fonts and restart.

  • I missed the SHIFT key and press several keys in the lower corner of my keyboard LH. Firefox split up into several iterations, and I had to reboot.

    I missed the SHIFT key and press several buttons in the lower left corner of my keyboard. Firefox has lost the tab that I was using and divided into a separate iteration for each other (plus two I had closed). I could not recover and had to close all but one of them and restore all my tabs.

    What I had done and how I should have recovered?

    First, you need to update to Firefox 18.0.1 Firefox updated to the latest version. The version you are on is bug and little course.

    Second, it looks like you may have entered groups of tabs. Use tab groups to organize a large number of tabs is that look familiar?

  • Why push button and stop button does not work in the structure of the casing and buckle my VI? (code attached)

    I am a beginner. I'm trying to create a simple VI only switches beetween two types of signals like sine and triangle when someone press on the push button and at the same time, save the data in the file to my desktop. I also have a stop button which no longer record data.  Here are my questions and dproblems:

    1. when I press the button, it does not the true and false in the structure of the case so that I can see the triangle wave stops and begins the sine waveform table.

    2 when I press the stop button, I want the program still running, but the process of writing data in time the loop stops. I don't mind if the graph of the wave stops too but it would be better for the user to see the wave form is running, but the data will stop recording.

    3. Although the condition of the loop did not accept the local variable for the stop button inside the loop or within the structure of the case, so I put the button outside all the loops and the structure.  (I know that this is a problem, I do not know how to use a single button several times in a single code. The local variable did not work the world premiere? I have to?)

    4. the data file it creates hase a lot of lines and columns. I expect a time column and a column of mixed signals based on the push button amplititude this user press every time.  I did that with the acquisition of data and a sensor, it automatically gives me the voltage and time in a column. I tried 2D and 1 d and it has not changed anything.

    Thank you for your help

    Like you said, you read only your entries at the beginning, then whatever value they had before you hit run is worth to be seen by the rest of the code. Programming LabVIEW is based entirely on the data flow and parallelism. It is incredibly powerful and has led to its success over the years (coupled with graphical programming), but is usually one of the first things the new developers stumble on. This is a simple resource to familiarize themselves with its functioning. The function to highlight execution is a great way to watch how your application uses data streams.

    Simple code goes like this:

    • Containing the main code of while loop

      • Inside of the whole loop is all user interaction code or modify the code entry
      • Stop the terminal loop is attached to stop certain criteria or user selection of a stop button
    • Loop initialization above all if necessary
    • Closing referrals and communications, etc after all loop

    It's very simple code. If you want to watch in more advanced architectures that are scalable, Google "LabVIEW State Machine" or "LabVIEW producer consumer."

    If you are just starting, you should do a free training have the capabilities of LabVIEW.

    "Give me six hours to chop down a tree and I will spend the first four sharpening the axe.  -Abraham Lincoln

    Here are some free training focused mainly on LabVIEW and hardware tools to help get started.

    Training center of NOR

    NEITHER start-up

    -Hardware Basics

    -Guide of MyRIO project Essentials (a lot of good simple circuits with links to youtube events)

    -LabVEW databases

    -DAQ Application tutorials

    -CRIO Developer's guide

    Learning OR training videos resources

    Introduction to LabVIEW for 3 hours

    Introduction to LabVIEW for 6 hours
    Paced self-study for students
    Self Paced Training beginner to advanced, required SSP
    LabVIEW training Wiki

Maybe you are looking for

  • iPhoto to the Migration of the Photo

    I recently spent hours doing several photo books in iPhoto 6.0.6 v. (322).  When I tried to buy the books and received their approval, I received the following message: "the possibility of ordering books, cards, calendars and prints is no longer supp

  • Tecra M2 interupted noise problem

    I have problem with Tecra M2: -during playback of music (mp3) with the player (winamp, mediaplayer) watch when turns off and I want that it is aggain-moving mouse ON, or hit some interrupts sound - key for a second.Any idea?It's really annoying. Than

  • Pavilion dv7-6050ec 2nd HARD drive

    Can I add a second HARD drive to my new dv7-6050ec? It has all (free space, HARD drive caddy), except the cable in the case.  If the upgrade is possible, should which cable I use? George THX

  • Remove a Gateway desktop logo

    I have Win7 Premium 64-bit. All of a sudden, a big Gateway logo popped up on the desktop when I boot. How can I get rid of him? If the suggestion is to "look in the BIOS" (leave a preliminary google search), please tell me what/how to do it, and do w

  • Smartphones blackBerry reconnecting to jvm always fails

    My curve 8520 has been perfectly well for almost 2 years now 3 days ago. He couldn't turn it on. It stuck on loading usually considered white bar when restart the device. I waited almost 5 hours hoping this loading ends and my bb started working, but