One RollOver function for all buttons?

Is there a way to streamline AS3 code so that all buttons are controlled by one rollover function? The code below isn't working for me.
function rollOverbtn(e:MouseEvent):void{
e.target.gotoAndStop(2);
trace("button HIT");
function rollOffbtn(e:MouseEvent):void{
e.target.gotoAndStop(1);
btn1.addEventListener(MouseEvent.MOUSE_OVER, rollOverbtn);
btn1.addEventListener(MouseEvent.MOUSE_OVER, rollOffbtn);
The trace works which shows me that the function IS properly firing, but the rollOver effect is not hitting. I'm sure I'm doing this wrong as I am brand spaking new to AS3.

You're welcome.  When you use MOUSE_etc events, and "target", the target can end up being a child within the object that has the event listener assigned.  currentTarget always points to the object with the listener assigned to it.

Similar Messages

  • Event and obj type in one eventlistener function for all buttons

    Hi i have something like this
    button1.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
    button1.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
    function manageMouseOver(event:MouseEvent):void{
      TweenLite.to(button1, 1, {x:100, rotationX:360, ease:Back.easeOut});
    function manageMouseOut(event:MouseEvent):void{
      TweenLite.to(button1, 1, {x:14, rotationX:-360, ease:Back.easeOut});
    and i would like to get one sentence for all button. I would like to create reference obj to use that function for all of my 7 buttons.
    button1.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver(button1), false, 0, true);
    button1.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut(button1), false, 0, true);
    function manageMouseOver(event:MouseEvent, obj:Object):void{
      TweenLite.to(obj, 1, {x:100, rotationX:360, ease:Back.easeOut});
    function manageMouseOut(event:MouseEvent, obj:Object):void{
      TweenLite.to(obj, 1, {x:14, rotationX:-360, ease:Back.easeOut});
    but this is not working. I know that is wrong but what i should do to do this right?

    in the listener function, use the event's currentTarget property to determine which object dispatched the event.

  • One function for multiple buttons?

    I have a county map on my timeline with a list of each county as buttons ( there is 88 counties). I want to highlight the county on the map when I click the county's name from a list.
    when I test this out, only the last one gets highlighted. I know I am missing something really simple. it does work if I write code for each button but I can't to seem to get it to work with only writing the function once for all buttons
    var countyHigh:MovieClip = adamsHighlight;
    var countyCheck:MovieClip = kickout.adamsCM;
    kickout.adamsCheck_btn.addEventListener(MouseEvent.CLICK, highlightCounty);
    kickout.allenCheck_btn.addEventListener(MouseEvent.CLICK, highlightCounty);
      countyHigh = allenHighlight;
      countyCheck = kickout.allenCM;
    kickout.ashlandCheck_btn.addEventListener(MouseEvent.CLICK, highlightCounty);
      countyHigh = ashlandHighlight;
      countyCheck = kickout.ashlandCM;
    function highlightCounty(event:Event):void{
      if   (countyHigh.alpha == 0)
           countyHigh.alpha = .5;
      else  countyHigh.alpha = 0;
       if(countyCheck.alpha == 0)
       countyCheck.alpha = .5;
      else
      countyCheck.alpha = 0;
    when I click all there buttons, the all highlight ashland county instead of their own county. I am using Flash Professional CS5 and only been playing with Flash for about a year.

    var previouslyHighlightedCounty:Movieclip;
    function highlightCounty(e:MouseEvent):void{
    if(previouslyHighlightedCounty){
    //reset previouslyHighlightedCounty. ie, un-highlight
    // highlight e.currentTarget
    e.currentTarget=previouslyHighlightedCounty

  • Same function for all mc buttons?

    I am putting together a simple flash anim – and pretty much have about 25 buttons that I need to fade in and out on rollover. I seem to remember there is a way to apply the same function to all buttons – as long as the over and out state labels within the mc are the same. Could someone let me know what i should look into in order to accomplish this? Thank you.

    dhem – i am getting a
    TypeError: Error #1010: A term is undefined and has no properties.
        at tw_flash_jh_fla::MainTimeline/frame1()
    when trying to implement that loop code – am i missing something?
    That is with the attached code – assumably the error is mine:
    stop();
    for (var i:int = 1; i < 66; i++){
        this["mc" + i].addEventListener(MouseEvent.MOUSE_OVER, showHighlight, false, 0, true);
        this["mc" + i].addEventListener(MouseEvent.MOUSE_OUT, removeHighlight, false, 0, true);
    function showHighlight(e:MouseEvent){
        e.currentTarget.gotoAndPlay("over");
    function removeHighlight(e:MouseEvent){
        e.currentTarget.gotoAndPlay("out");

  • HT204053 Our family uses one Apple ID for all of our iPhones.  We installed the update and now we are all getting each others photos and texts.  How do we stop this?

    Our family uses one Apple ID for all of our iPhone 5's.  We installed the update and now we are all receiving each other's pictures and texts.  How do we stop this? 

    Have a look here...
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l

  • HT4436 My family has multiple iPhones.  Can we use one Apple ID for all of our phones?

    My family has multiple iPhones.  Can we use one Apple ID for all of our phones?

    If you use the same AppleID for iMessage and iCloud though, you will all be sharing the same message account and iCloud email account.  You can use a common AppleID for purchased content, but each create your own unique AppleID for iMessage and iCloud so you each have your own private accounts for those services.

  • HT1660 how can I use one single library for all users on the same laptop?

    how can I use one single library for all users on the same laptop?

    You are most of the way there. Each user having access to hard drive is the key. If users are limited in file privileges this is harder.
    Any files you add to your library and any files she adds to her library are available to the other. Just not automatically. Each user must add the files to their own library using the add file or add folder option from menu bar.
    What I have done is set library location to a location outside of My Documents\My Music. On my network storage I have a folder names s:\itunes. Both accounts iTunes are set to use this location for the library.

  • How to get One Selection Screen for all queries?

    Hi Experts,
    I have three queries having selection screens. All the selection screen have the same variables, but the reports are different.
    I have created a workbook having these three queries. Each time when the workbook opens, the three selection screen pops up one after the another. Same values are entered in all the selection screens.
    Now the user wants only one selection screen for all the three reports. Is it possible? I tried but I do not see any way.
    I think there should be some way of getting it done.
    Waiting for your inputs,
    With kind regards,
    Shreeem

    Hi
    If a workbook contains multiple queries that use the same variable, you are prompted to enter the variable values again for each query. To avoid this, set the Display Duplicate Variables Only Once flag.
    Goto Workbook Settings>Under Variables Tab>select Display Duplicate Variables only Once
    http://help.sap.com/saphelp_nw70ehp1/helpdata/EN/54/a493f7256b43698191a2623e5a0532/frameset.htm
    Hope this helps,
    Aparna Duvvuri

  • HT201251 I want to use 30  ipads to run kiosk software in my restaurant. Can I use one Apple ID (and one credit card) for all devices

    I want to use 30  ipads to run kiosk software in my restaurant. Can I use one Apple ID (and one credit card) for all devices?

    Alternatively you can always manage your iPads (does not matter how many) with a single apple id and all reporting to your account under "find my device" service. Keeping an eye on all your units. Additionally as you mentioned these are for your Restaurant you may find the solutions offered by this company who creates apps and hardware for this purpose: http://www.spartakioskpro.com
    Additionally if you expand beyond those 30 iPads to say 300 you will want to enable or plan on MDM as your best option to automate every ipad to use the same profile and app and ios configuration while also keeping a close eye on all of them via online MDM services like: https://meraki.cisco.com/products/systems-manager
    Here is a pic

  • How to force RH9 to use only one master stylesheet for all Word imports?

    I have set a stylesheet (css) as the default for my RH9 WebHelp project in project settings. When I import Word documents into the project, the edit import setting dialog does not show this stylesheet in the list of available stylesheets for the import.
    What is happening instead is a proliferation of unwanted stylesheets derived from all the imported documents. I then have to manually re-set all the new topics to the master stylesheet.
    How can I stop this, and force RH9 to use only the one master stylesheet for all imports?

    cid:[email protected]
    Hi Peter,
    That’s what I thought I was doing in the Project Settings>Import tab>CSS for Style Mapping selection. Maybe that isn’t what it’s meant to do. It’s just getting annoying having all these unneeded files popping up in the project manager so that I have trouble distinguishing the “real” topics from the extra stuff.
    Michael West | Business Improvement | Aurecon
    Ph: +61 3 8683 1996 | Fax: +61 3 8683 1444 | Mob: 0407 485 228
    Email: [email protected]
    PO Box 321, South Melbourne | VIC 3205 | Australia
    http://www.aurecongroup.com
    http://www.aurecongroup.com/apac/groupentity/

  • HT1879 how to buy multiple songs for one person & pay for all at once

    i want to purchase a bunch of singles for one person, & pay for all at once. is that possible?

    Basis can do a export and import transport, still if don't have connection between boxes.
    or
    check this
    http://www.sap-basis-abap.com/abap/copy-program-variants-from-one-to-another.htm

  • Publication using "one database fetch for all recepients" is a failure

    Hi,
    I have created a Publication in *CMC* with Crystal Reports as Source Document. When I schedule it with option " One database fetch per recipient" it is a Success. But while using the option "One database fetch for all recipients" it is a Failure.
    I tried this with Personalization value Parameter as well as Filter. But both combinations throw an error message when used with Reporting Bursting Method "One database fetch for all recipients".
    Anybody who has worked with Publication please let me know in which scenario one can use the Advanced setting:
    Report Bursting Method
    "one database fetch for all recepients"
    Regards,
    Amogh.

    Howard,
    The method I use is to put the connection script in a file outside the web root. Although the file has the same name on both the local and remote servers, the details are specific to that particular connection. Then each page in the website has the following PHP script.
    require_once '../outside_folder/.db.php';
    This method is also more secure than including the connection details inside the web root. Also note that the file name begins with a period and ends with the php extension, both for added security.

  • Publication using 'One database fetch for all recipients' is a Failure

    Hi,
    I have created a Publication in CMC with Crystal Reports as Source Document. When I schedule it with option " One database fetch per recipient" it is a Success. But while using the option "One database fetch for all recipients" it is a Failure.
    I tried this with Personalization value Parameter as well as Filter. But both combinations throw an error message when used with Reporting Bursting Method ""One database fetch for all recipients"".
    Anybody who has worked with Publication please let me know in which scenario one can use the Advanced setting:
    Report Bursting Method
    "one database fetch for all recepients"
    Regards,
    Amogh

    Howard,
    The method I use is to put the connection script in a file outside the web root. Although the file has the same name on both the local and remote servers, the details are specific to that particular connection. Then each page in the website has the following PHP script.
    require_once '../outside_folder/.db.php';
    This method is also more secure than including the connection details inside the web root. Also note that the file name begins with a period and ends with the php extension, both for added security.

  • I downloaded mountain lion on my laptop.  Do I need to do the same on my Desktop and iPad or is the one download good for all 3, and how do I do that if it is?

    I downloaded mountain lion on my laptop.  Do I need to do the same on my Desktop and iPad or is the one download good for all 3, and how do I do that if it is?

    If your desktop computer is one that supports Mountain Lion, you can either download it there or make a bootable jump drive with the installer on it -- assuming you haven't yet used the installer you downloaded to your laptop.
    As for the iPad, it doesn't use the same OS as the Macs do; it uses iOS versions, so Mountain Lion won't work there.

  • SAP Business one Manual / Documentation for all Modules

    Hi,
    SAP Business one Manual / Documentation for all modules is required by our client.
    The details should include screen wise explanation of each and every form in the SAP Business one package for all modules.
    Please provide me with link so I can download such information which would be useful for the User post implementation.
    Regards,
    Siddhesh

    hi siddesh,
    Best user manual is context help available in B1(Press F1/ ? mark),It is also available
    in this link for 2005 & 2007 Versions.
    http://help.sap.com/saphelp_sbo2005b/helpdata/en/1d/48a291fc4a0448bbc8dacd344e956c/frameset.htm
    Crispy overview of all topics can be available in wiki page
    https://www.sdn.sap.com/irj/scn/wiki
    More documents is available in service market place which requires s-userid & password.
    http://service.sap.com/smb/sbo/documentation.
    Edited by: Jeyakanthan A on May 15, 2009 4:33 PM

Maybe you are looking for

  • Weird Blurry Sections on the Sides of the Screen

    This is only a minor problem, but it sure is annoying. Parts of my screen are blurred. If you divide the screen in thirds, the middle of the screen is crisp and clear as usual, but the left and right sides are blurry. What's going on?

  • No communication between FIOS Westell routers at different locations

    I have CrashPlan running at home. It uses port 4242. I had 10 computers at multiple locations that were backing up to me when I was using cable. Some of the locations also had cable and some had FIOS. Ever since I changed from cable to FIOS at home,

  • Custom Bookmark Format for Law Firm

    I have a client who is a transactional attorney and she needs to deliver a "closing cd" to all partied involved, which is basically a copy of all the documents for the current RE deal.  She showed me an examlpe of another law firms closing CD and ask

  • Dynamic Time Series - Consolidation

    <p>Hello</p><p> </p><p>I verified that time balance attribute allow control the memberconsolidation for differents time periods.</p><p>I have a time and accountsdimension on outline. My Time dimension is dividedin Year and quarter without months.</p>

  • Hashing is considered Encryption?

    Hi, I've almost finished an app that uses SHA-2 before sending the score to a webserver to avoid cheating, so it doesn't actually use encryption. Do I have to mess up with the export compliance or hashing is not considered a kind of encryption? I've