How can you execute a function while the mouse is over a button.

I've got a movieclip I want to move across the screen on the x axis to the left or right depending on which button the user hovers their mouse over.
I thought I could do this with the following:
right_btn.addEventListener(MouseEvent.MOUSE_OVER, moveRight);
left_btn.addEventListener(MouseEvent.MOUSE_OVER, moveLeft);
function moveRight(e.MouseEvent):void
     sampleMovieclip_mc.x += 1;
function moveLeft(e.MouseEvent):void
     sampleMovieclip_mc.x -= 1;
But I find that it only moves it 1 pixel when the mouse first goes over the button and not continiously as it stays over it.  I tried using Event.ENTER_FRAME to call the moveRight and moveLeft functions, but it just keeps going and I'm not sure how to kill the function once they move the mouse off of the button.
Any help would be greatly appreciated.
Thanks.

use removeEventListener() method. Here is one of the ways to deal with it:
// move direction
var xd:int = 1;
// speed along x
var xs:Number = 1;
right_btn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
right_btn.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
left_btn.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
left_btn.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
function onMouseOver(e:MouseEvent):void {
     xd = e.curretnTarget == right_btn ? 1 : -1;
     addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onMouseOut(e:MouseEvent):void {
     removeEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
     sampleMovieclip_mc.x += xd * xs;

Similar Messages

  • How can i reload font information while the jvm is running.

    l.s.
    how can i reload font information while the jvm is running.
    I'm having the following problem...
    A program is running.
    A user installs a new font on the system (Xwindows in this case)
    Java doesn't display the font when i ask :
    java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();Thus i think that java buffers its font information somewhere. Anyone knows how to refresh te buffer?
    many thanks

    ungalcrys, welcome to the forum. Please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    I'm locking this thread now.
    db

  • We are evaluating the use of iPod touch devices to record best practice videos on our manufacturing floor and to post to an internal Moodle web site. How can you upload a video from the iPod touch to a site other than YouTube?

    We are evaluating the use of iPod touch devices to record best practice videos on our manufacturing floor and to post to an internal Moodle web site. How can you upload a video from the iPod touch to a site other than YouTube? The Moodle upload interface is expecting a file selection dialog box like windows or OSX. I do not want to have to go through an intermediary step of messing with a pc.
    Thanks!

    It should be around 7 and a half gigs. In iTunes, across the bottom there should be a bar that show how much storage is being used and by what. (music, movies, apps, etc.) To make music take up less room, you can check the box to make it convert the music to 128kbps AAC. This lowers the quality, but with most earbuds and speakers, you can't even tell the difference.
    The iPod touch has parental controls built in. You'll find them in Settings. I think they only work for enabling/disabling Safari, Mail, YouTube, and App Store. Here's an app that does more: http://www.mobicip.com/online_safety/ipod_touch

  • In print preview - how can you have multipage previews of the document - 1 - 2 - 3- 6 - 12 page preview and so on so that you can see if the document is ok to print?

    WINXP - In Explorer you can have multi-page print previews from 1, 2, 3, 6 upwards to check and confirm that the document will print correctly to your needs - and does this across the screen format as opposed to down the page, so that you can see all 12 pages on your screen to quickly see that the print percentage is correct and all pages fall into the print area and so on - how can you set this up with Firefox, because printing with Firefox is so unstable, you don't know what to expect when printing a document or web page?

    No what I mean is how can you see many pages across the screen without having to scroll like in explorer where you can see 12 or more small pages on your screen without scrolling down, like tiled across your screen as opposed to vertical down the page. Thanks

  • How can you download premier pro when the icon doesn't exist in cloud?[was:pr]

    how can you download premier pro when the iucon doesent exist in cloud???

    In order to download the software, your computer must meet the system requirements to run the software.
    http://helpx.adobe.com/x-productkb/policy-pricing/system-requirements-premiere-pro.htmlhttp://www.adobe.com/products/premiere/tech-specs.html
    The usual reason for not being able to download is that Premiere Pro (and other video apps such as After Effects) are 64 bit only so they require a 64 bit computer and a 64 bit operating system.
    If you're running a 32 bit computer and operating system then you will not see the Premiere Pro icon since the software will not run on your computer.

  • How can you minimize or (turn) off the "side panel" in Web Intelligence in the view mode.

    How can you minimize or (turn) off the "side panel" in Web Intelligence in the view mode.
    It is possible to turn on/off options within the Side Panel by Customization of Groups.
    But it seems You cannot influence the way Web Intelligence present (minimized or Off) the Side Panel in the IE??
    Is there a solution for this??
    If not, it would be a nice property of a Web Intelligence document in a future release.

    Hi Nico,
    we patched up to BI 4.1 SP 3 Patch 2
    and look look
    click side panel to minimize
    so .. patch patch ...

  • How can you cancel sounds registered during the lessons?

    How can you cancel sounds registered during the lessons?

    In applications, drag the install OSX 10.10.1 to trash. The download will not install unless you tell it to. You can download it without it installing, so trash it if you have decided you don't want it or simply don't tell it to install.
    Cheers
    Pete

  • How do you highlight several cells with the mouse in numbers

    how do you highlight several cells with the mouse in numbers

    Hi David,
    Using only the mouse, you can select a contiguous range of cells using the method described by dwb.
    For larger (but still contiguous) ranges you might prefer this method:
    Click the first (top left) cell of the desired selection.
    Scroll to the last (botom right) cell of the desired selection.
    Shift-click the bottom right cell to select it, and all of the cells in the rectangular array defined by this and the top left cell selected in step 1.
    To select two or more non-contiguous cells:
    Click on the first to select it.
    Command-click on another to add it to the selection.
    Repeat as necessary.
    Regards,
    Barry

  • How can I update my Iphone when the update is over 20mb, can this be done in Itune ?

    How can I update an app if the update is over 20 mb. Can this update be done in Itune ?
    An update on Iphone is not possible when it is over 20 mb. and I can't find an update tool in Itune.
    Thanks

    Yes for itunes, or you can update when you on wifi.
    On the left side bar where you see apps click on it then on the bottom you will see check for updates.

  • How can you soft reset an iphone 4s when power on/off button not working

    How can you soft reset an iphone 4s when your on/ off button is not working?
    My voicemail messages are unobtainable and i'm trying to work out how to fix this.

    Sorry you don't.

  • The text on web pages fades as you scroll the page, it reapears if you click refresh or move the mouse arrow over it. I reset FF still doing it.

    The text on web pages fades as you scroll the page, it reappears if you click refresh or move the mouse arrow over it.
    I went to many different web pages and it does it on all of them including this one.
    I went to the same web pages using IE 10 and the text does not fade away.
    I reset FF still doing it. I uninstalled and reinstalled FF still doing it.
    What could be wrong?

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • How can you get your photos in the order they are in your computer

    How can you get your photos synced to your phone in the same order as the file on your computer?

    The iPhone Photos app orders photos by date.

  • How can you reset an ipod if the lock button is broken?

    how can i reset my ipod if the lock button is broken?

    To reset the iPod without the hardware buttons,
    - Reset network settings: Settings>General>Reset>Reset Network Settings. All your wifi and bluetooth preferences and settings are reset. Information (such as contacts and calendars) and media (such as songs and videos) aren’t affected. You will have to rejoin wifi networks and repair BT devices
    If you mean place in recovery mode then use on of these
    For PC
    RecBoot: Easy Way to Put iPhone into Recovery Mode
    If necessary:
    Download QTMLClient.dll & iTunesMobileDevice.dll for RecBoot
    and                                           
    RecBoot tip
    RecBoot may have problems on 64X windows, then try:
    Tenorshare ReiBoot – Enter & Exit iPhone, iPad, iPod Recovery Mode with a Single ClickFor MAC or PC           
    The Firmware Umbrella - TinyUmbrella
    Installs blootware on PC too

  • HT1430 How can you reboot your Touch if the screen is frozen and will not allow you to use the "slide to power off"

    How can I reboot my Touch when the screen is frozen and I cannot use the "slide to power off" feature?

    Next try:
    - Reset the iOS device. Nothing will be lost
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup. See:                                 
    iOS: How to back up           
    - Restore to factory settings/new iOS device.
    If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
    Apple Retail Store - Genius Bar          

  • If we have the original ipad, how can you open a pdf in the ibooks? the menu tap bar does not appear at the top of the screen like the new ipad2. Any suggestions?

    If we have the original ipad, how can you open a pdf in ibooks? The menu bar does not pop up like it does on the ipad2. Any suggestions?

    Are you in Safari and you want to copy them to iBooks, or you in a different app ? Assuming that you are using Safari, then if I open a PDF on my first gen iPad in Safari and tap on it, I then get a pop-up bar at the top of it with the 'Open In' options.

Maybe you are looking for

  • How to generate the sequential number in Javascript

    Hi , I am facing one issue. I am adding the record to the underneath record and it works fine. But I have one problem there. I am having 10 records and adding one record between any of those records. I can able to reinitialize the index using xfa.for

  • Photos showing up in Wallpaper Photo Album, but not Main Photo Album

    I just switched to iPhone - love it. Just transferred all of my photos from my old device into my iPhone via iTunes. They show they are in the iPhone when I check the iTunes capacity at the bottom, and they all show up as options for my wallpaper in

  • Subscript & SuperScript in Crystal Report

    hi , I m developing application which contain information about chemical compound. all formula of chemical compound contains superscript & subscript. I store value in database using sub & sup Tag .but crystal report does not support these tag how can

  • What situation would make the dbms_scheduler to delay the execution of jobs

    Hello all, Env: 10.2.0.3 I have a couple of jobs scheduled in DBMS_SCHEDULER to run at 6:00 AM everyday and it used to run at 6:00. But today instead of 6:00 they ran at 13:00. Next_run_time for jobs are at 6:00AM tomorrow. I checked the log files an

  • Some software not working anymore,,,,

    Hi I dont knwo if I am in the right topic... I have a mac 10.6 and these software dont seem to work anymore... anfter i double lcick they seem to open for 1sec and then just close without any message or so... --------------roxio toast lite ----------