Controlling movie with mouse location

I am a designer trying to be a flash programmer and I have a
navigation idea that I've been struggling with. I am simply trying
to do this: put a movie on the stage and as the mouse moves closer
or farther from the movie, it plays forwards and backwards. The
movie I made is a circular logo with navigation buttons curling out
from it like a jack knife. My idea is to have the buttons curl out
as the user moves the mouse closer to the logo and curl back in as
the mouse moves away.
I understand the coding concept - calculate where the cursor
is on the stage, figure out the distance of the cursor to the logo
movie, and just go to certain frames in the logo movie based on
that distance.
I have the stage, the logo movie, and even the code to figure
out the the mouse location. But beyond that, I need help. I just
don't know enough about actionscript syntax and although
conceptually this seems like a basic exercise, I really don't know
where to start. If anyone is willing to help, the .fla file can be
downloaded here:
http://0099d33.netsolhost.com/westside-home2.fla
Thanks so much for any help you can offer.
null

You would replace the one mDistance line in your original
with the three I've given you. But if you weren't able to figure
that bit out, you might not be able to figure out how to modify the
whichFrame line either? Do you have a conceptual understanding of
what your code is doing? Being able to read the code and understand
what it is doing is really central to Actionscript. So here goes:
mcLogo.onEnterframe: this is attaching some code that will
repeat at the frame rate of the movie to the mcLogo instance. Even
if there is a stop() on the timeline, this code will continue to
repeat at the framerate set by your movie. By attaching it to
mcLogo your scope will be mcLogo.
In both version the next line (or three in my case) say find
the distance between the current mouse position and this._x (for
example). Since we are inside an onEnterFrame which is attache to
mcLogo, so "this" refers to that time line. So this._x is saying
the _x location of the mcLogo clip.
If you remember basic geometry a right hand triangle's long
side (the hypotenuse) is given by h^2 = a^2 + b^2. (The square of
the hypotenuse is equal to the sum of the squares of the other two
sides.) So we are figuring out how far between mcLogo and the mouse
in the x and the y directions. This gives us the other two sides.
So the distance between the mouse and the clip is the square root
of the sum of the squares of those two sides.
Finally since you need to adjust the distance to some scale
of the number of frames you have added to your clip. So your have
some code that makes the distance proportional to the number for
frames in your clip.
As for the second part of your question, "Don't use scenes!"
So that makes that easy. Scenes are great tools for organizing your
timelines when you are just doing some timeline-based animations.
But when using Actionscript there are some bugs and limitation in
scenes and you are only asking for trouble.
So if you have this code say on frame ten with a stop().
There is no looping that needs to happen. The onEnterFrame will
continue doing the animation until someone clicks.
Add maybe ten blank frames after 10 and then on frame 20 put
your new thing you want – perhaps even give it a frame label
called, "home" or "about" or whatever section it is about. Then you
can use:
this.gotoAndPlay("about");
Also don't forget that you will want to remove the
onEnterFrame event because otherwise it will keep running. So you
should probably also include:
delete mcLogo.onEnterframe;

Similar Messages

  • How to control the speed of nested movie with mouse

    I have a movie nested inside another movie with pictures that
    scroll horizontally across the screen. I would like the user to be
    able to control the speed and direction of the pictures by moving
    their mouse. Can anyone give me some insight on where to look to
    find out how to do this?
    If this can't be done then perhaps add controls on the screen
    to stop / play / speed up / slow down the horizontal scrolling
    pictures

    it can be done. search for a scrolling movieclip tutorial
    using google or at flashkit.com

  • How to control timleline with mouse x coordinates

    Hi,
    Does anyone know a good tutorial on how to create a movie with a sequence of pictures and controlling the timeline frames with mouse x-coordinates?
    Regards,
    MH

    basiclly,these swfs didn't work in mailtimeline movies.some of them were created by  flash3D .
    the point is some functions what created mouseX & DisplayMovies mapping like this
    function mouseMoveH(e){
              displayrender()
    function mapping(){
         return  fun(mouseX)
    function displayrender(){
        showFrame(mapping)

  • Desktop moves with mouse!

    A friend reported to me from work that when she mouses, the whole desktop on her computer (10.4.11, but not sure what model, maybe a G4 tower) moves with the mouse movement! Is this a known issue? Any solution?

    Hi there,
    It sounds as if she might have accidently enabled the zoom feature. This can be toggled on and off using the cmdoption8 combination or in the 'Universal Access' pane of System Preferences. The zoom level can be controlled with the cmdoption'=' or cmdoption'-' keyboard combinations.
    Yang

  • Character movement with mouse click

    This will be for an MMO online game/ world. So it needs to be good.
    Hi guys. I'm really happy I got this to work as I'm a neebie to AS3 but getting to love its simplicity. My problem is not my AS3 but my maths.
    I click the mouse and the movieclip runs to the mouse's x position. However, it only goes in one direction ie: downwards and to the right.
    I need to it go in all directions depending on where I click. I suppose it has to do with comparing x and y positions of both mouse and mc - ie: if one is bigger than the other then you can tell where both are positioned and then put the code in. Am I right and does anybody hace a little code like this flying around for me?
    import flash.display.Stage;
    import flash.events.Event;
    stage.addEventListener(MouseEvent.CLICK, myClickReaction);
    function myClickReaction (e:MouseEvent):void{
        sunny.gotoAndPlay("runback")
        //sunny.x = root.stage.mouseX
        //sunny.y = root.stage.mouseY
        addEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onEnterFrame(event:Event):void {
                 var xDistance:Number
                 var yDistance:Number
                //mc increments by 5 until it reaches mouse - mc (ie the distance)
                sunny.x += 5;
                sunny.y += 5;
                xDistance = root.stage.mouseX - sunny.x
                trace (xDistance)
                if (xDistance <= 0 ) {
                trace("works")
                sunny.gotoAndPlay("static")
                removeEventListener(Event.ENTER_FRAME, onEnterFrame);

    Thanks for contacting but the code more or less works already apart from the comments below.
    The position I get comparing mousex position and movieclip position. BUT it goes loopy when I move the mouse around. ie: I need the coordinates when I click and not a variable that changes while I move mouse around.
    I will check it out now.
    import flash.display.Stage;
    import flash.events.Event;
    stage.addEventListener(MouseEvent.CLICK, myClickReaction);
    function myClickReaction (e:MouseEvent):void{
    //sunny.x = root.stage.mouseX
    //sunny.y = root.stage.mouseY
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onEnterFrame(event:Event):void {
                 var xDistance:Number
        var yDistance:Number
       //mc increments by 5 until it reaches mouse - mc (ie the distance)
                // if you click to the right of sunny then mouse is > than sunny.x so x = 5
       if (root.stage.mouseX > sunny.x) {
        sunny.gotoAndPlay("walk right")
        sunny.x += 5;
        sunny.y += 0;
        xDistance = root.stage.mouseX - sunny.x
        //if (xDistance <= 0 ) {
        //sunny.gotoAndPlay("static")
        //removeEventListener(Event.ENTER_FRAME, onEnterFrame);

  • Unwanted Mission control openings with mouse movement

    Many times Mission Control will open when I make a fast movement up or down with Magic Mouse. It's happening more and more, and very annoying.
    ais there any way to turn it off? I can't figure out what iscausing it.  Thanks - Rick

    It's caused by a double-tap with two fingers on top of the Mouse.
    You can turn it off in System Preferences > Mouse > More Gestures tab > uncheck Mission Control.
    Regards,
    Captfred

  • Control frames with mouse x coordinates

    Hi,
    I will try to rewrite an earlier question to be more precise:
    I want to take a folder with 20 pictures, in some way convert them into a movie. And then apply so that I can navigate the frames one by one in the movieclip by moving the mouse right and left  (move mouse left - navigate backwards frame by frame, move mouse right - navigate forward frame by frame).
    Anyone knows a good tutorial for this? Or maybe some tips to get started?  I'm pretty new to Flash CS3.
    Thanks,
    MH

    I don't know that there will be a good tutorial for this, if any, mainly because as described, it may not be a desirable means of controlling a movieclip's timeline.  While the "in some way convert them into a movie" is your call, assuming that movie will occupy a timeline, the controlling of frames by moving the mouse may need a little more thought/criteria resolution.
    If the desired control is to merely make it such that moving the mouse left or right changes it one frame for each movement, then you can use a variable that keeps track of the mouseX value (where the mouse was) and a MOUSE_MOVE listener to trigger a function that tests where it is.  If the new mouseX value is greater than the stored value, the mouse moved right, so you advance one frame in the movie's timeline.
    The thing with this approach is that you really want to wait for the mouse to stop moving before you process a command to move, or somehow otherwise build in some stalling, otherwise one movement could end up moving several frames of the movie.  Also, one movement could limit how much space you have left to continue moving--running out of room to move....  You would need to sneak around to the opposite end of the stage at some point in order to keep moving in one direction.
    It may be better to create another area/movieclip that you use as a stepper control... if you pass the cursor over it from left to right, it advances the movie one frame and vice versa.  You use rollover and rollout detection to capture the position of the mouse for each event and that can tell you which way the mouse was moving.

  • Camera moves with mouse

    Hi guys,
    Just a quick post with HOPEFULLY a quick and helpful answer.
    See
    the background effect on this game which moves the background
    when the mouse is moved, I would love to know how to make something
    similar to that. Can you either, Direct me to a tutorial that will
    teach me how to do this OR do you know the script to do this?
    All help is appriciated!
    Thankyou!

    well, if you really want to duplicate the effect of your
    link, just use a scrolling movieclip whose scrolling is a function
    of the mouse position.
    the class below sets up the scrolling for a member of the
    class. usually a mask is used to display the scrolling movieclip
    and this class requires one. just use a mask movieclip the same
    dimensions as your stage:

  • Frozen icons - files will not move with mouse.

    Hello, all.
    All of a sudden I noticed that the icons on notebook's desktop have stopped responding to my mouse commands. I've tried with the built-in trackpad as well as with an external mouse. I've also tried to create a test user but the same happens.
    I have also booted the system with Leopard's installation DVD and verified/repaired permissions to ensure that it wasn't the problem but the same continues to happen. I also verified read and write rights to these folders but nothing seems to be out of order (at least nothing that I can see).
    This started happening after the internal drive became full and my wife deleted several photos stored in iPhoto.
    Any ideas of what might be the cause and how to fix it ?
    Thank you in advance for your help.
    Joseph

    Just upgraded to 10.5.8 today and suddenly this problem appeared.
    The thread starter tried his best to explain the problem but everyone seemed to be suggesting things that were not responsive to this problem (yet plausible overlooks for a n00b on OS X)
    Let me first say that I have been using a Mac since 1988, and OS X since the day the Public Beta released. So, I know all the little tricks to try like zapping the PRAM, checking the align to grid settings and other stuff we used to try, just before disabling extensions and rebuilding the desktop :P
    Here's what I am seeing: Any icon displayed in icon view is selectable, but immovable. You can double click on the icon to launch it, right click on it...do everything except move it. Even tried some of the old favorites like holding down a modifier key and dragging. Nope, still locked down.
    I looked deep to find if there wasn't some kind of "Lock icons in place" setting in the 10.5.8 update that accidentally got enabled by default.
    Also tried starting up with no battery or other accessories plugged in (after zapping the PRAM a few times).
    Tried logging in to another account on the machine to see if it was my user account that was corrupted - same results in my son's account.
    I am running a MacBook Pro 2.33 with 10.5.8 and 2GB of RAM.
    This seems suspiciously tied to the update, but it may be a nasty coincidence. I have been holding off on installing my Snow Leopard upgrade because of the CS3 issues I have heard about. I hope this is not the "force point" on that. And rebuilding my drive from scratch? Ugh! I think I would just move to an "off the grid" commune instead of facing that one.
    Any help would be greatly appreciated.
    Thanks!
    Mike
    UPDATE: this problem is affecting all dragging, not just icons. I just tried to drag the URL for this thread from the address bar to the desktop for later reference. Nope. Allows me to double click to select it, but not drag it.
    Message was edited by: Fiodan
    Message was edited by: Fiodan

  • Action Script to restart movie with mouse

    I added code using Script Assist in Flash CS4 to pause the
    movie at the end frame until the user clicks on the mouse to
    restart it. Seemed so easy but I have tried everything I can think
    of and nothing works. I actually did this in an earlier version of
    Action Script and now I am lost. The code I used is attached. Any
    help is greatly appreciated!
    Richard

    Installed and working. Thanks for the code!

  • Screen Image moves with pointer

    Entire Screen moves with mouse pointer. The dock and menu bar do not fit on the screen at the same time. MacBookPro 10.4.11 Problem started suddenly today. Thanks for helping me.

    Yeah, sounds like you may have zoomed in. Control+the two finger scrolling swipe should zoom you in and out (and back to normal), or you can also use command/option/+ or -. I think this is a super handy feature and rather than turning it off you may wish to adjust how it works in system preferences/universal access (you can control the zoom speed and whether the screen moves with the cursor, or when the cursor gets to the edge, etc).

  • Move a mouse with Apple script

    Hello,
    I need some apple script code to move a mouse to a certain location and then click. If possible could it record the location of the mouse, move it to the pre-assigned coordinates, click, and them move it back to where it was.
    I am doing this so I can use multivid and Qlab to play different videos on different iOS devices. Multivid doesn't seem to let me have a cue list with different videos playing simultaneously.
    I will have my iMac set up with 2 displays, one with Qlab and the other with multivid in full screen.
    Thanks for the help

    Here's another code using rubycocoa you might try.
    _rb_click({|:position|:{30, 10}, |:click|:1, |:restore|:true, |:prep|:false})
    on _rb_click(desc)
            record desc : event descriptor record;
                full spec = {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p}
                defaults   = {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
                list pos : {x, y} or {}
                    number x, y = x, y global coordinate of position
                    {} denotes current location
                integer k : click count (0, 1, 2 or 3}; 0 denotes only to move mouse and exit
                integer b : button index (1 = left button, 2 = right button)
                string m : modifier flags; e.g. 'ck' = control + command
                    a = capslock
                    s = shift
                    c = control
                    o = option
                    k = command
                boolean r : true to restore original mouse location, false otherwise
                boolean p : true to post preparatory left 1-click event to change UI context, false otherwise
            return list : {x, y} = mouse location at exit
        considering numeric strings
            if (system info)'s system version < "10.9" then
                set ruby to "/usr/bin/ruby"
            else
                set ruby to "/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby"
            end if
        end considering
        set defaults to {|:position|:{}, |:click|:0, |:button|:1, |:flags|:"", |:restore|:false, |:prep|:true}
        set {|:position|:pos, |:click|:k, |:button|:b, |:flags|:m, |:restore|:r, |:prep|:p} to desc & defaults
        if pos = {} then
            set {x, y} to {"%", "%"}
        else
            set {x, y} to pos
        end if
        if k is not in {0, 1, 2, 3} then error "invalid click count: " & k number 8000
        if b is not in {1, 2} then error "invalid button index: " & b number 8000
        if m = "" then set m to "%"
        do shell script ruby & " <<'EOF' - " & x & " " & y & " " & k & " " & b & " " & m & " " & r & " " & p & "
    require 'osx/cocoa'
    include OSX
    if ARGV[0..1] == ['%', '%']
        pt = CGEventGetLocation(CGEventCreate(nil))        # current mouse location
    else
        pt = CGPoint.new
        pt.x, pt.y = ARGV[0..1].map {|a| a.to_f}
    end
    clk, btn = ARGV[2..3].map {|a| a.to_i}
    flg = ARGV[4]
    res, prep = ARGV[5..6].map {|a| a == 'true'}
    etype, mbtn = case btn
        when 1 then [KCGEventLeftMouseDown, KCGMouseButtonLeft]        # [1, 0]
        when 2 then [KCGEventRightMouseDown, KCGMouseButtonRight]    # [3, 1]
        when 3 then [KCGEventOtherMouseDown, KCGMouseButtonCenter]    # [25, 2]
        else raise ArgumentError, %[invalid mouse button: #{btn}]
    end
    mtable = {
        'a'    => KCGEventFlagMaskAlphaShift,
        's'    => KCGEventFlagMaskShift,
        'c'    => KCGEventFlagMaskControl,
        'o'    => KCGEventFlagMaskAlternate,
        'k'    => KCGEventFlagMaskCommand,
    mf = flg.split(//).inject(0) { |mf, x| (m = mtable[x]) ? mf | m : mf }
    src = CGEventSourceCreate(KCGEventSourceStateHIDSystemState)
    tap = KCGHIDEventTap
    pt0 = CGEventGetLocation(CGEventCreate(src))                    # current mouse location
    # move mouse to target location
    ev0 = CGEventCreateMouseEvent(src, KCGEventMouseMoved, pt, 0)    # move mouse
    CGEventPost(tap, ev0)
    if clk == 0
        puts pt.x, pt.y
        exit
    end
    # post preparatory left mouse click to change UI context (optional)
    if prep
        ev1 = CGEventCreateMouseEvent(src, KCGEventLeftMouseDown, pt, KCGMouseButtonLeft)    # mouse left button down
        CGEventPost(tap, ev1)
        CGEventSetType(ev1, KCGEventLeftMouseUp)                    # mouse left button up
        CGEventPost(tap, ev1)
    end
    # post target mouse click(s) with given flags
    ev = CGEventCreateMouseEvent(src, etype, pt, mbtn)                # mouse button down
    CGEventSetFlags(ev, mf)                                            # set flags
    CGEventSetIntegerValueField(ev, KCGMouseEventClickState, clk)    # set click count
    CGEventPost(tap, ev)
    CGEventSetType(ev, etype + 1)                                    # mouse button up
    CGEventPost(tap, ev)
    # restore mouse location (optional)
    if res
        CGEventSetLocation(ev0, pt0)                                # restore mouse location
        CGEventPost(tap, ev0)
        puts pt0.x, pt0.y
        exit
    end
    puts pt.x, pt.y
    EOF"
        set rr to paragraphs of result
        repeat with r in rr
            set r's contents to r as number
        end repeat
        return rr
    end _rb_click

  • Clips moving visually when zoomed in with mouse movement

    Hello,
    I am experiencing a glitch with the visual placement of the clips in Final Cut Pro X.
    When I zoom in to the maximum level, the audio and video clips move visually. I can therefore not determine their exact alignment. When I move the mouse over the clips (a physical mouse by Logitech) without touching any other controls, the clips stutter around, and shift their apparent location.
    I am using a brand new, maxed-out iMac and have restarted the program, and computer several times. This happens in all of my projects and not just the project in which I first noticed the problem.
    Has anyone else encountered this problem?

    BillMilgram wrote:
    With the OS Update to OSX 10.8.4, this problem went away.
    Luis, it is a 2013 27" iMac with a 3.4 GHz i7, 32 GB of 1600 MHz DDR3 ram, an NVIDIA Geforce GTX 680MX 2048 MB, and has the 768 GB SSD drive.
    Thanks for your replies guys!
    I am glad the problem was solved. My guess is that the update included a new driver for the graphics card that may have solved some bugs.

  • On my Cinema Display the screen is blurry and shifts with mouse movement.

    I have had this screen for a year and a half and only use it once a week in my remote office. This morning I noticed blurring on the screen and the whole screen shifts up/down, left/right with mouse movement. Please help. I am getting a headache.
    Thanks In Advance,
    Rob

    Press Command-Option-8 once or twice.
    You have Zoom on. It is controlled in "Seeing" in "Universal Access" system preference, and by Control-Scrollwheel.

  • User Control screwed up but unable to click on icons with Mouse on OSX 10.8

    I dont know what has happened, but today user control with mouse and trackpad on my macbookpro is screwed up.
    I rebooted twice, it made no difference.
    The trackpad moves the cursor okay, but I cannot get tapping or clicking the trackpad have any effect.
    With my mouse I can access menubars, but the left and right buttons are swapped round, or it might be that the right button is acting as both left and right button.
    I then went to the System Preferences screen to try and fix the mouse preferences, but clicking on any icon with left or right button has no effect.
    I then found no icons of that type seem to work, I thought Id try and just update OSX with any updates available hoping that would fix anything that has got corrupted. But although I can get to the Appstore Update screen and there are two updates available I cannot get the updates installed. Clicking with the left button does nothing, clicking with right button changes the colour of the button slightly so the bottom half is in gray but nothing else happens.
    As there is no menu option to install the updates I thought I tried and install the updates using the keyboard but I cannot work out how to do this.
    Does this sound like a hardware or software problem
    Help Please !

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

Maybe you are looking for