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:

Similar Messages

  • 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);

  • 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

  • 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;

  • 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

  • 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).

  • I used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this?

    i used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • FireFox with adobe flash using a retina macbook pro under win 8.1 64 bit is lagging . when you move the mouse above any flash game / video

    Hi
    I asked this question again and i reported this bug , i am a computer engineer and i tested it with few macbook pro retina laptops , when u use win 8.1 64 bit or 32 bit and install adobe flash under firefox try to play any game in facebook , view video on youtube or use any FLASH video and move the mouse above the screen of the flash game / video / etc , the screen will lag alot .
    under chrome this problem doesnt exist but the screen is blurry in chrome when using retina screen thats why firefox is better , but the problem is annoying .
    i tried to disable hardware acceleration as you suggested still the same problem

    Hi thesoulkeeper,
    Do you have the bug number? We can try needsinfo to ask for some help.

  • 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.

  • Creating a QuickTime movie with the new Canon T5i  camera in iMovie 9.0.9.

    Help needed creating a QuickTime movie with the new Canon T5i  camera in iMovie 9.0.9.  The project is done and looks good...I need help understanding what settings need to be set so I can make a QuickTime movie in the highest quality that would fit the ratio of 16.9 to be sent out to my YouTube page.  I played around with some of the settings and have not come with the right setting for the video.  I want the highest quality with the lowest amount of megabytes…thanks

    I would suggest using SHARE/EXPORT MOVIE and choose 1920x1080 (if your source material supports this).
    That should work well in YouTube.
    If you want to go further with custom QuickTime settings,  here are some that should work, but in my experience, it will be no better than using SHARE/EXPORT MOVIE.
    follow the instructions below to create a .mov video that will work on YouTube:
    In iMovie, select Share > Export Using QuickTime
    Next, you may want to check your Options to verify that the following settings are correct:Video settings
    Compression Type: H.264
    Frame Rate: 30 is preferred. 23.98, 24, 25, 29.97 are also acceptable.
    Data Rate: Automatic
    Key Frames: Automatic
    Frame Reordering: Unchecked
    Audio/Sound settings
    Format: AAC
    Click Show advanced settings and choose Constant Bit Rate as encoding strategy
    Other settings
    Size: Choose the original size of the video
    “Prepare for Internet Streaming”: Fast Start

  • Using Lion, recent Movies with .mov extension will not play in Quicktime, but earlier ones taken with same camera (Kodak M530) will play fine.

    Using Lion, recent Movies with .mov extension will not play in Quicktime, but earlier ones taken with same camera (Kodak M530) will play fine. I have got VLC which runs them fine but cannot get movies saved in iPhoto to play in VLC...and of course its a real bugger to copy moves from iPhoto to another folder; in fact if anyone can tell me how to do that I will accept defeat!

    Hello Shad:
    Have you downloaded and installed Flip4Mac?
    http://www.microsoft.com/mac/otherproducts/otherproducts.aspx?pid=windowsmedia
    Barry

  • Can't make movies with iphone camera?

    OK, I might be dumb, but I just got an iphone yesterday and seems pretty cool, but doesn't seem to have the ability to make movies with the built in camera. Am I just stupid or what? Every other crap phone I have had for the last 5 years could make movies so I just assumed an iphone would make them too and even better ones with the 2 megapixel camera. Am I missing something or is this some kind of astonishing lack of feature? I don't seem to see anyone else complaining. Maybe I am just out in my own left field or something. Wouldn't one just assume an iphone could make a movie like all the other cell phones? Maybe I am just dumb and missing something? I hope so. It has got to just be a software thing. If Apple can't manage it for some reason, maybe a 3 party developer will figure it out for them. Any help?

    Well, your comments sort of prove your point as well as one of mine. I guess I am one of few people who would really like to have the video feature even if it is compromised in quality. But, honestly so is the rest what the iphone does. It is by far not the best computer or internet connection (a desk top or laptop is), nor the best phone (a land line is), nor the best music player nor the best camera either. It is not the best at any of that, just obviously a really good almost-all-in-one product compared to other relatively similar camera phones products. So, yes, I guess I am dumb as I suspected and should have known better and not assumed anything - my fault entirely. But, since I hadn't heard any serious negative feedback about the lack of a video function or any other real negative feedback actually, I just assumed it had it. But, the reality is I guess most other people just don't care too much about it. Lesson learned. I don't care about the money and I am not interested in trying to get my money back or resell it. It is still a good product for what it is. I am just disappointed in the lack of what I would think was a pretty basic and common feature on other camera phones. How much extra could it have cost and what could it have hurt to have it? I am not sure what a good reason for not having it is, but maybe there is one, who knows. Anyway, I did fill in a feedback on the apple site, but I guess that is about all I can do for now.
    Thanks for the help. At least I now know that it doesn't have the video taking feature and it's not that I am just not understanding how to use it, which was the basis of my post. Thanks for the help.

  • 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

Maybe you are looking for