How to assign addEventListener to 52 Buttons?!

Hi there! I am not an expert in Flash and my problem might looks silly.
But anyway, my problem is that, I have 52 Button instances on Scene 1 as bellow: 
B1 , B2 , B3 , ... , B52 and I want to assign seperated actions for each of them. The way I currently CAN do that is this: 
B1.addEventListener(MouseEvent.MOUSE_DOWN, B1F);
B2.addEventListener(MouseEvent.MOUSE_DOWN, B2F);
B3.addEventListener(MouseEvent.MOUSE_DOWN, B3F);
B52.addEventListener(MouseEvent.MOUSE_DOWN, B4F); But the way I CANT do this, is that I use a formula like WHILE for example, to do this for all of them together... for example: 
var i:int = 1;
var test:string;
while (i<53) {
test = "B" + i
test.addEventListener(MouseEvent.MOUSE_DOWN, test + "F");
i++;
} But "test.addEventListener(..." does not work, and Flash searches for a function named "test" instead of working with the VALUE of "test". hope it is not confusing? What is the right way to do this in your opinion??? Any sort of help is really appreciated - Ali

You said: What functionality differentiates the event handler functions (B1F,B2F,etc)?  You may be able to have one function for all of them.
I was thinking I can do that myself But I couldnt as well...
Ok.....what I have now (with your kind help) is the code below to assign Listeners to 52 Buttons at once:
var i:int = 1;
while (i<53){
   this["B" + i + "_mc"].addEventListener(MouseEvent.MOUSE_DOWN, this["B" + i + "F"]);
   i++;
But now I have 52 Functions! that do the same job as you said!
fnctions B1F(event:MouseEvent):void {
       var i:int = 1;
       Bpressed = i;  
       gotoAndStop(2);
       BtnNo1_mc.gotoAndStop(i);
       BtnNo2_mc.gotoAndStop(i);
       BtnNo11_mc.gotoAndStop(i);
       BtnNo22_mc.gotoAndStop(i);
       Btns_Detail.gotoAndStop(i);
function B2F(event:MouseEvent):void {
       var i:int = 1;
       Bpressed = i;
       trace(this[name]);  
       gotoAndStop(2);
       BtnNo1_mc.gotoAndStop(i);
       BtnNo2_mc.gotoAndStop(i);
       BtnNo11_mc.gotoAndStop(i);
       BtnNo22_mc.gotoAndStop(i);
       Btns_Detail.gotoAndStop(i);
function B52F(event:MouseEvent):void {
       var i:int = 1;
       Bpressed = i;
       trace(this[name]);  
       gotoAndStop(2);
       BtnNo1_mc.gotoAndStop(i);
       BtnNo2_mc.gotoAndStop(i);
       BtnNo11_mc.gotoAndStop(i);
       BtnNo22_mc.gotoAndStop(i);
       Btns_Detail.gotoAndStop(i);
the reason I have all those functions is that I don't know the code to get the "InstanceName" of Button that is pressed?....For example if I know the Button pressed is "B13_mc" and I could store it in a variable, then I can have a chance to make a single Function instead of 52 Functions!
that's my opinion, but What is your valuable suggestion please???
Best wishes - Ali

Similar Messages

  • How to assign a dynamic value to the value property of a button ?

    Hi Folks,
    I have a need, can i know how to assign a dynamic value to the value property of a button. Scenario is like follows...
    This is a struts based web application
    1. I have a file which consists of login user details (user name and his previlages) for a web application.
    2. I got those user details, into a List.
    3. When a user logged into the web app, in the home page there are few buttons. The type and number of buttons shown depends on the type of user/ user. (Buttons have different combination and the number of buttons available are not constant, they will vary from user to user).
    4. for each button, there will be a different action. I can pass the value of a button to an action class, but here button must have a dynamic value.
    Here is my test code:
    <%
    if (List != null)
    for (int i = 0; i <List.length; i++)
    %>
    <html:submit property="rduname" value= "<%=List%>" onclick="return submitRdu('<%=List[i] %>');"/>
    <%
    %>
    But my problem is how to assign a dynamic value to the value property of the button ( i know 'value= "<%=List[i]%>" ' will not work, just wanted show you guys).
    Thanks in advance,
    UV
    Edited by: UV_Dev on Oct 9, 2008 2:15 PM

    Let me try i know am not good at JSP but do we need double quotes here
    value= <%=List%>i think JSTL should help you about the dynamic thing                                                                                                                                                                                                                                                                                                                       

  • How to Assign an event to a button in PCUI

    Hi everybody,
    How to Assign an event to a button in PCUI ?
    Thanks & Regards
    Hassan

    Hello Hassan,
    The button for which you are tying to assign is a part of Toolbar group, then in CRMC_BLUEPRINT_C there under Application element expand the node TOOLBAR GROUP, there select you toolbar group & on the left panel  you have ASSIGN EVENTS
    there you can assign the event.  Provided event should be defined before.
    Hope this helps.
    Thanks & Regards,
    Bhavya

  • How to assign a button for attachment and send the data through browser ?

    Hi friends,
    How to convert to browser ?
    how to assign a button for attachment and send the data through browser ?
    Thanking you.
    Regards
    Subash.

    Refer to
    How to create a text box in ascreen painter?
    where another user (venkateshwar reddy) has asked a very similar question...
    Jonathan

  • How do I use directional PDA buttons in LabVIEW programs?

    Hi all,
    I've been assigned to get a LabVIEW program to work on a Palm PDA with LabVIEW 7.0 and palm PDA module 7.0.  I am basically totally new to LabVIEW, and my possibly very simple problem is, the PC program requires input from a serially connected number pad for the 8, 4, 5, 6, and 2 keys which are used as four directions (8, 4, 6, and 2) and an enter (5). 
    I am trying to rewrite the input vi to use the directional buttons and middle enter button on the PDA itself but am having trouble figuring out what to use.  I am using a PDA simulator because of the PALM OS5 we own.  The input demo vi example provided will not build for PDA because of size so I am unsure of how to approach this.  Another thing is, we have LabVIEW and PDA module for pocket PC 8.0, and a Dell Axim PDA on order.  From what I understand off of this website, the latest PDA module has example button vi's.  I would still like to figure out the way to do this on 7.0 so I can have a better understanding of LabVIEW.  Eventually the program's endgoal is to be used on a PDA and inputting with a bluetooth keyboard, but we are going step by step right now.
    I guess my biggest questions are, how do I assign the directional buttons on the PDA in my program, and will this differ greatly when we switch to 8.0 and pocketPC.
    Oh and I did try to look at the example asteroid.vi but from looking at the input subvi, still couldn't figure out how they assigned the buttons.
    Thanks,
    Stephen

    I can't help with any specifics (no access to the PDA module at the moment and I didn't use the buttons anyway), but I would like to say that it probably would make a big difference if you used LV 8. 7.0 was the first version of the PDA module and was extemely limited and problematic (it didn't even have a tab control). 7.1 was somewhat better and I understand that 8 is even better (although still very limited and buggy).
    I also remember reading about several differences between Palm and PocketPC and I think you will generally be better off with the PocketPC as it's related to windows and will probably support more stuff.
    Try to take over the world!

  • How to use Checkbox  and radio buttons in BI Reporting

    Hi BW Experts,
       My Client has given a report in ABAP format and the report has to be develop in BI.It contains Check boxes and the radio buttons. I don’t know how to use Checkboxes and radio buttons in Bex.For using this option, do we need to write a code in ABAP.Please help on this issue.
    Thanks,
    Ram

    Hi..
    Catalog item characteristic
    - Data element
    - Characteristic type
    Entry type
    List of catalog characteristics
    Designer
    Format (character)
    Standard characteristic
    Alternative: Master characteristic
    (used for automatic product
    assignment)
    Simple entry field
    Alternatives:
    Dropdown listbox or radio button
    list

  • How to Add shortCut  key to  button or form In SAP BusinessOne

    Hi
    How to assign short Cut  key to  button or form ,in SAP BusinessOne using  VB.net.
    Thanks,
    Y.
    Edited by: Yughandar on Mar 10, 2011 9:32 PM

    Hi
    To set shortcut key for button , try this
    in your srf change the button caption like this
    caption="&amp;Del line"
    this will set shortcut key (Alt+d) for the button
    Regards
    Arun

  • I am trying to find out how to assign files with particular extensions to the appropriate software. At the moment when I create a file using Word it is apparently given the extension .docx but Word doesn't recognise its own files. How do I alocate th

    I am trying to find out how to assign files with particular extensions to the appropriate software. At the moment when I create a file using Word it is apparently given the extension .docx but Word doesn't recognise its own files. How do I allocate the extension .docx to Word? There used to be a way of doing it, I think under "Preferences" but I can't seem to find it.

    Still in the same location:
    File > Get Info > Open with (select) > Change All (button)

  • How to assign output type and trigger printing in ABAP

    hi all,
    i have create invoice by using BAPI_BILLINGDOC_CREATEMULTIPLE and create header/item text with CREATE_TEXT.
    please advise how to assign the output type and trigger immediate printing after this.
    thanks.

    Hi Reetha ,
    This is a functional setting  , and should be done by some functional guy. The setting can be done by NACE.
    Just follow the path : NACE - > Select V3 for Billing - > Press Output type Button Just above - > Assign Output Type and
    then Assign Output program and form in PROCESSING ROUTINE comes into left. Set this output type for immediate print.
    Whenever You create a billing document by BAPI with this document type , the print out will be fired immediately.
    Hope it will solve your problem.
    Thanks.

  • HT3576 how to assigne a unique sound to a single incoming e mail address and have it aleart when in lock screen 4s Iphone 6.13

    how to assign a unique sound to a single incoming e mail address and have it alert when in lock screen on 4s Iphone 6.1.3
    I receive emergency requests for service thru e mails. my old BB let you assign separate sounds for incoming e mail addresses. can I duplicate that with Iphone or MUST I be woken with each and every incoming e mail?

    I have email messages alert sounds turned off except for VIP addresses (of which I have only one). That means I only get alerted for that one address.
    To add a Contacts entry to VIP senders in iPhone Mail:
    Open your list of mailboxes in iPhone Mail.
    Tap the > button next to VIP.
    Select Add VIP… at the list's end.
    Tap the desired entry from your contacts.
    Then, in Notifications>Mail, turn off the souds for your email account but enable them for VIP.
    Note that all VIP emails will have the same tone. It's more like the Priority feature on a BB than custom text tones.
    Best of luck.

  • How to assign sessionscope variable to the bind variable in Query of VO

    Hi all,
    I want to know how to assign a sessionscope variable in the binvariable of Query in VO
    My sessionscope variable holds the value of currently selected column in the table. eg:empname of the currently selected column which is in empdetails table...
    I want display the schemes available for the selected employee in the next table..The schemes are in another table named empschemes which has the empname and empschemes as column
    I have created a vo for empschemes table with bind variable 'scheme_bind'..I need to set the sessionscope variable '#{sessionScope.empname}" to the bind variable.
    Its urgent,..Pls do reply asap
    Thanks in advance
    Nasrin

    HI,
    You can use
    adf.context.sessionScope.get("YourSessionVariable")this code for assigning VO's bind variable value.write this code where you create bind variable and do not forget click on expression radio button.
    Rafat

  • How to assign approver to missing approver of workflow

    We have defined approval group on specific employee so when every user create their leave then it go to specific user for approval. Now the issue is, approver has been terminated and the dynamic query is getting no record. Due to this neither approver information is appearing nor it’s not going to notification user.
    Now we have updated approver name with the new, but how to assign approver to those leave request which have no approver defined.
    Pls advice

    I am bit confused, when i assigned from one user to another user by selecting notification and press reassign button on the main page instead of inside the request where is the same re-assinge button beside approval.
    Now problem is that system has assigned all notification to new user instead of two particular record which i selected.
    pls advice.

  • How to assign possible agents at security role / CAG level?

    Hi Experts, How to assign possible agents at security role / CAG level?

    Yes, that's exactly what I'm talking about. In your task maintenance, goto additional data -> agent assignment -> Maintain
    Click on th task, click on the assign button. Choose object type 'Role', enter role.
    Cheers,
    Mike

  • How to assign the trip type to a particular employee. - Urgent

    Hi,
    In HR - Module - Travel Management.
    I am trying to create a travel request for an employee.
    i am getting the error message :
    Statutory trip type  does not exist in the system (T702G)
    how to assign the trip type to a particular employee.
    regards
    Giri
    *Points will be assigned for all the valid answers.

    Hi Fred,
    If you open any activities or opportunities, you can see the description if you select new button and click on the process type. It will be display Activities and below that New: Activity. Instead of always displaying the same description I want to override the description according to the process type. For me the application is not activity but Incident. Hope I am clear with the question.
    Thanks,
    Anu

  • How can assign the value returned from javascript to Hidden item

    Hi All,
    I have created a report with button in one column adding following code to SQL select statement like
    SELECT USER_RQST_ID, USER_RQST_DESC, RQST_DATE, STATUS, USER_ID, CNTRY_ID, KPI_LIST, YEAR_LIST, QTR_LIST, MONTH_LIST,
    PROD_LIST, FULL_PERIOD_FLG, GEN_DATE, '<input type=button value="view_list" onclick="javascript:doSubmit('||USER_RQST_ID||');">' button FROM KPI_USER_RQST;
    Then i have implemet doSubmit() function in Javascript like
    function doSubmit(req_id)
    html_GetElement('HIDDEN_ITEM')= req_id.value;
    Here HIDDEN_ITEM is the name of the item, I want to use that HIDDEN_ITEM value in PL/SQL block like...
    BEGIN
    INSERT INTO SAMPLE(KEY) VALUES(:HIDDEN_ITEM);
    END;
    But it is not working, Please help me anybody know the solution How to assign an item in javascript block function.
    Thanks,
    Neel

    Hello,
    doSubmit() is one of the built in javascript functions in apex and it's a bad idea to override it unless you know exactly what you are doing, and even then is a generally bad idea.
    change your function to this
    function mySubmit(pValue){
    $x('HIDDEN_ITEM').value = pValue;
    doSubmit();
    then your onclick will look like this notice the lack of the javascript: and the three ''' quotes to get the proper quotations for your value.
    onclick="mySubmit('''||USER_RQST_ID||''')"
    And there you go
    Carl

Maybe you are looking for

  • Itunes has stopped working on our PC? Itunes attempted to load the C Runtime library incorrectly.  Reinstall. Error 7 Windows error 1114.

    When I try to play an audio cd or open itunes from programs, I get the following dialog box. "Itunes attempted to load C Runtime library incorrectly"  Reinstall itunes.  Error 7  Windows error 1114.  Do I uninstall from the control panel and then dow

  • A problem with bind variables in a shuttle

    Hi After days of research I cannot come up with a solution to this problem which I hope will be easy to describe. I'm working on an apex.oracle.com workspace (4.02). I have a page with a) a region with tree which works well populated by a list of rol

  • Interactive Reporting and Custom SQL

    I have SQL that works in TOAD and I'd like to copy it directly into IR; however, it appears that the custom SQL feature only allows you to "customize" the FROM, WHERE, etc parts of the SELECT statement and not the database fields that are directly af

  • Re-installed router software - can't change password!

    I had to format my HD so I re-installed my linksys WRT54g wireless router and used the installation disk. at the end it says to put in my password. I put in every combination of password I could think of, but it keep going back and asking me again. s

  • SCCM 2012 R2 Report using WMI Query

    I am trying to find out if I can generate a report to show which users installed what software using a report in SCCM 2012 R2 and a WMI Query. If not using the reporting within SCCM, then: 1)  is it possible to pull such data via a wmi query 2)  any