Moving Background Based Mouse Movement (Parallax) AS3

I found this AS2 tutorial online but I'd like to achieve this in AS3. I tried transcribing but the  setProperty is throwing me off. Thanks
//AS 2 parallax code
stageWidth = Stage.width;
speed1 = 20;
speed2 = 19;
mc1Width = front_mc._width;
mc2Width = back_mc._width;
mc1X = front_mc._x;
mc2X = back_mc._x;
lock_scroll = false;
_root.onEnterFrame = function () {
    if (!lock_scroll)
        scroll_mc();
function scroll_mc() {
    var xdist = _xmouse-(stageWidth/2);
    mc1X += -xdist/speed1;
    mc2X += -xdist/speed2;
    if (mc1X>=0) {
        mc1X = 0;
    if (mc1X<=stageWidth-mc1Width) {
        mc1X = stageWidth-mc1Width;
    if (mc2X>=0) {
        mc2X = 0;
    if (mc2X<=stageWidth-mc2Width) {
        mc2X = stageWidth-mc2Width;
    setProperty("front_mc", _x, mc1X);
    setProperty("back_mc", _x, mc2X);
//create an empty mc container for content to display
createEmptyMovieClip("content_box", 200);
content_box._x = 195;
content_box._y = 92;

Ok I added that line of code. But my background isn't moving...
var stageWidth:Number = stage.width;
var speed1:Number = 20;
var speed2:Number = 19;
var mc1Width = front_mc.width;
var mc2Width = back_mc.width;
var mc1X:Number = front_mc.x;
var mc2X:Number = back_mc.x;
var lock_scroll:Boolean = false;
stage.addEventListener(Event.ENTER_FRAME, scroll_mc);
function scroll_mc(event:Event):void
        //if (!lock_scroll)
                var xdistance = mouseX-(stageWidth/2);
                mc1X += -xdistance/speed1;
                mc2X += -xdistance/speed2;
                if (mc1X>=0)
                    mc1X = 0;
                if (mc1X<=stageWidth-mc1Width)
                    mc1X = stageWidth-mc1Width;
                if (mc2X>=0)
                    mc2X = 0;
                if (mc2X<=stageWidth-mc2Width)
                    mc2X = stageWidth-mc2Width;
                back_mc.x=mc1X;
                front_mc.x=mc2X;

Similar Messages

  • Screen not displaying correctly. It keeps moving as the mouse moves

    Screen not displaying correctly. It keeps moving as the mouse moves

    Your problem is not the same as that of the original poster of this thread, and it can be very confusing for everybody if we try to answer more than one question in each thread.
    In order for us to give your problem our undivided attention to try to solve it, would you kindly start your own thread, describing the trouble you are having in the fullest detail, including completing your details to show what Mac or iDevice you are using, what operating system, and what version of the application in question. Please remember to post in the forum relevant to your hardware or version of OS X.

  • Desktop Moving With My Mouse Movements!

    This is a weird one for me, as I've never seen it before.
    I booted up my Mac Mini this afternoon, and when I moved my mouse, my desktop moved with it! Kind of hard to describe, but whichever way I move the mouse then the whole desktop image moves with it, regardless of what I am doing.
    I have tried the Command Option P & R startup and looked in the system preferences, but I'm so far admitting defeat on this one!
    Any ideas?

    Hi Samsong-
    You have zoom enabled on the mouse.
    If you hold the control key while scrolling up or down is one way zoom becomes enabled and the mouse will do that. Try holding the control key down and scroll all the way out.
    Zoom can be configured in the mouse preferences.
    Luck-
    -DaddyPaycheck

  • Rotate object based on the mouse movement

    Hi, how can I do to make the object rotate based on the direction and movement of the mouse?
    Similar to this: http://activeden.net/item/billboard-style-xml-photo-viewer/22111
    Thanks in advanced.

    Hi ,
    I created a simple sample for you. Hope that helps!
    Basically on the image elements' ($("image")) mouse move you could add this snippet -
    // insert code to be run when the mouse is moved over the object
    var img = sym.$('image');
    var offset = img.offset();
    var center_x = (offset.left) + (img.width()/2);
    var center_y = (offset.top) + (img.height()/2);
    var mouse_x = e.pageX;
    var mouse_y = e.pageY;
    var radians = Math.atan2(mouse_x - center_x, mouse_y - center_y);
    var degree = (radians * (180 / Math.PI) * -1) + 90;
    img.css('-moz-transform', 'rotate('+degree+'deg)');
    img.css('-webkit-transform', 'rotate('+degree+'deg)');
    img.css('-o-transform', 'rotate('+degree+'deg)');
    img.css('-ms-transform', 'rotate('+degree+'deg)');
    Thanks and Regards,
    Sudeshna Sarkar

  • Use mouse movement to create parallax

    How would I create a little parallax between layers using the mouse movement rather than the scroll bar? Just trying to create the sense that there is some depth on the page,not massive movement. Sorry don't have an example to show what I mean.

    Yes, you can do that.
    After you have selected your rectangle tool, look in the options bar at the top of the window and click on the down pointing triangle next to the custom shape icon. In the  resulting dialog box click on fixed size and put in your values. Then click on your image and place your shape.
    Paulo

  • Moving mouse moves the entire screen

    When I move the mouse the entire screen moves in the direction the mouse moves. Tried different mouse, keyboard, restarting. Nothing works. The computer still works fine, it's just the moving screen won't stop

    Open the Universal Access pane of System Preferences, click on the Seeing tab, and turn off Zoom.
    (31635)

  • Flash video performance poor in Firefox 3 and other newer Gecko-based browsers; fails to detect mouse movement in full-s

    Regardless of configuration, I have found Flash video
    performance on Firefox 3 to be severely sub-par. Numerous visual
    lags occur throughout a typical Youtube video as it cannot seem to
    manage to maintain a steady frame rate. When in full-screen, mouse
    movement is not detected, forcing me to click in a full-screen
    Vimeo video in order to display its controls when I should have
    only needed to move the mouse. I was informed that the technical
    explanation for this is that Flash isn't triggering MouseEvents
    other than MouseEVENT.CLICK.
    In my tests, this behavior also occurred in Flashplayers 9
    and 10 as well as with recent versions of other browsers that also
    use the Gecko rendering engine, namely Camino, Flock and Songbird,
    but not in Firefox 2. I was told by a Mozilla employee that this
    issue can only be solved by Adobe.
    This has forced me to use the Safari browser as my only
    available work-around. I implore that these issues get resolved as
    quickly as possible.

    guys, im exactly experience the same issue here.. any
    solution guys? tks in advantage..

  • After web page finish, mouse movement and scroll up down very slow.

    After web page finish loading,both mouse movement and scrolling that page is very slow.
    I compare the same page on MS internet explorer and have no problem.
    p.s. I'm using intel core 2 dual on 4gb ddr3 windows vista 32bit.
    == URL of affected sites ==
    http://www.sanook.com

    Thanks for both of these answers. I am finding that I do not
    like the totally manual method all that much (but it does work).
    Using the PrintScreen-before-and-after-each-action method seems a
    little better for me. Either method requires way too much editing
    for a simple "let me show you" movie. I have moved on to version 3
    since it seems to behave a little better.
    I think it is odd how sometimes Captivate puts an action
    (like a mouse click) on a background from *two* slides previous.
    Why would it ever go backward - especially skipping over the
    previous slide to get an even older screen. If I have forced a
    screen capture, you would think it would stay with that.
    I realize that I am not using Captivate where its strengths
    seem to be (eLearning) but there must be a lot of people capturing
    demos of web-based material. Does everyone have this
    problem?

  • Move container sprite according to mouse movement

    Hi All,
    Currently I'm developing a game where there is a object which follows mouse. Also there are other objects and a map on the screen.I want all of background content(whole map and other objects) to move when user moves mouse left or right. That is, if user moves mouse on right side then all content(except object which moves as per mouse) should move left side so that user can see remaining part of map on the right side.
    As of now I have created new Container sprite in which I have added all of my objects and map. So when user moves the mouse right, I move the container sprite to left so it looks all stuff moves to left. Code looks like as below
    var pt:Point = new Point(character.x, character.y);
    pt = dori.localToGlobal(pt);
    if (pt.x > (stage.width * 0.5))
                        container.x -= 5;
    Structure of project is such that, I add Container directly to stage. and this container contains everything like map, character and other objects.
    Now issue is that as soon as mouse goes beyond middle of stage...it creates distance between mouse location and character..!! I mean it does move according to mouse but some distance get created between mouse and character. and this distance keeps increasing as I continue to move mouse away from center of stage!!
    I'm really stuck with this issue. Please someone help with this. I hope I have explained this well. Let me know if you need more info but please help.

    No see......I dont want ease in n all....and character following the mouse logic is working fine if I dont use above linear interpolation to move the container mc.....
    but I do want to move container mc as well so I will have to use what you gave to move the all background objects when user moves mouse....
    so Again to clarify, in the game when user moves mouse the character should follow and at the same time bakckground objects which are in container mc should move opposite to mouse movement so that remainng mape gets visible to the user....
    just now when I was debuggin the linear interpolation logic...I got to know that there something I need to change in it...because accroding to that logic...let say for example
    stageWidth is 480
    maze.width is 551
    then x1 will be  480
    y1 will be -71
    x2 will be 0 and
    y2 will be 0
    so m = (y1 - y2) / (x1 - x2) = -71 - 0 / 480 - 0
    m = -0.147
    b = y1 - m * x1 = -71 - (-0.147 * 480) = 0
    so on each enter frame when mouseX wil be multiplied with m....it will create lag in moving container(character is in container as well!
    bcoz
    container.x = m * stageRef.mouseX + b;
    so I'm confused!!
    where do u think shall correction be made??

  • After sleep, retina MacBook Pro (Mid 2014) does not recognize usb connected mouse movement

    After sleep, retina MacBook Pro (Mid 2014, on 10.9.4) does not recognize usb connected mouse movement. I have tried a generic usb mouse and my Razer Deathadder usb mouse. Both mice work before sleep; but after sleep, the computer no longer recognizes mouse movement while still recognizing the mouse buttons when pressed. Any idea why this is occurring?

    Hello, chocotac0.  
    Thank you for visiting Apple Support Communities.
    Here are some troubleshooting steps that I would recommend when experiencing this issue.
    OS X Mavericks: Reset your computer’s PRAM
    http://support.apple.com/kb/ph14222
    Intel-based Macs: Resetting the System Management Controller (SMC)
    http://support.apple.com/kb/ht3964
    OS X Mavericks: If a USB device isn’t working
    http://support.apple.com/kb/PH13876
    Cheers,
    Jason H.

  • Premiere Elements 13 issue with the mouse on When I select a clip of video and move to a different place in my time line, Premiere Elements 13, will not release the clip rom the mouse.    The clip follows my mouse movements and goes to other places in my

    Premiere Elements 13 issue with the mouse on MAC OSX Yosemite 10.10.1
    When I select a clip of video and move to a different place in my time line, Premiere Elements 13, will not release the clip from the mouse.
    The clip follows my mouse movements and goes to other places in my time line.
    I try to delete these extra insertions, but the mouse will not release the clip.
    Action I’ve taken: I’ve re-installed Premiere Elements 13. Problem remains.
    This issue has consumed too much of my time and does not go away.  It ruins my video.
    Help please.
    Thanks

    I tried using the Guest Account on my Mac. In the Guest Account, Illustrator works perfect!
    Then I started wondering what processes (tools/tweaks) I run by default on my account. Turned out the problem was called by a little background tool called RightZoom. RightZoom let's the green 'zoom' button always maximize your current window.
    So thanks! Problem solved!

  • How can I stop coalescing of mouse move/drag events in jdk1.6 ?

    Hello all,
    My application uses a [pen-based tablet|http://en.wikipedia.org/wiki/Graphics_tablet] to draw lines/curves. But the problem is: when I run my application, due to java’s default behavior of discarding the mouse events which occurs during the repaint call, the curves results in the set of joined straight lines.
    To overcome this problem, when searched over net, came across below link:
    [http://forums.sun.com/thread.jspa?messageID=10811388]
    I tried the option provided at the above URL i.e. overriding the below method of Component.java file:
    protected AWTEvent coalesceEvents(AWTEvent existingEvent,AWTEvent newEvent);
    But later found that, overriding this method worked fine for me for jdk1.5 but this solution did not work in case of jdk1.6. When reviewed the source of Component.java and EventQueue.java files in jdk1.6, found that this method is not having any implementation and simply returns “null” and the complete handling of coalescing of events occurs within EventQueue.java file’s local method which is mentioned below:
    private boolean coalesceEvent(AWTEvent e, int priority);
    As this method is part of EventQueue.java and also it is a private method, I am not finding any way to stop the coalescing of mouse move/drag events in jdk1.6.
    The main problem is that my application is purely based on jdk1.6 only.
    Can anybody help me out to solve this problem by providing any option of preventing the coalescing of mouse move/drag events in case of jdk1.6.
    Thank you.

    Look at the link I posted, you aren't double buffering correctly.
    I saw the other post you mistakenly made before you edited it. Not really a big deal, I was just wondering why you did that.

  • XY graph "mouse move" event stops generating when click on cursor

    Hello All
    When the mouse is moving freelly inside the XY graph control, the "mouse movement" event is fired.
    The same happens when muse clicks anywhere in the graph with the exception of cursors.
    hen mouse clicks on cursors the "mouse move" event is NOT generated even though the mouse is phisically moved.
    Is there any explanation to this.
    I enclose the example.
    regards
    Pawel

    Just today I had the same problem -> my solution:
    set event timeOut to some value(I have it at 1ms) then
    add to globalVariables some BOOL variable that will signal if mouse is down or up (set the flag in appropriate event),
    then add a case in the timeOut event which will read this
    global variable(flag) -> if it's TRUE then change the needed parameter.
    So even if the mouse move event isn't fired the main timeout event is.
    Not a perfect solution, but better than nothing.
    Peace
    Waldemar

  • CS3 Ext. Vista 64 jerky mouse movement

    Hi there,
    I have a huge problem with my 32 Bit Photoshop CS3 Extended under the operating system Windows Vista Business 64 Bit and don't know if this is a known problem or has to do with the 64 Bit or something. I don't know what to do more so I ask here in hope of some help.
    The problem: When I use the f-key to switch to a mode where the image uses the whole space behind the tool paletts and use the space-key to switch temporarily to the move tool to move the image around, my next mouse movements with click actions will be really jerky.
    To explain this further more imagine you are on a deep zoom level inside an image, using the polygon lasso to mark an object exactely, there's often the situation where you come to the border of what you can still see and what you can't see anymore. Here you'd use space and move the window a bit in the direction you want to continue marking the object. When I do that (in fact after the first time i do that) I see that the whole processing of generating those marking points with the lasso gets really jerky as if the pc is studdering. It is not possible to work fluently and/or fast this way. As you can see from my speccs (see further down for details) pc speed is no real issue here. Other things like GPU-heavy games (e.g. Crysis) don't show any studdering.
    Things I already tried to no success:
    1) deactivated version cue
    2) bumped the memory that Photoshop may use from 2.5 GB to the maximum of about 3.5 GB. Windows still has plenty of memory left for itself as Photoshop seems to have a border here that windows itself hasn't.
    3) deactivated GPU-Support temporarily
    Some more information:
    1) Windows and Photoshop are on their newest versions/patches.
    2) There is no emulation software and no Nero installed.
    3) The file I'm testing this with is newly made (ctrl-n) in a resolution of 1280x1024 @ 300 dpi plain white. This shouldn't be extremely large.
    4) Computer speccs: Intel Core i7 920 @ 4000 MHz, 6GB DDR3-1600, Geforce GTX 285 Black Edition, Watercooling for processor and north-/south-bridge and condensators. The whole system resides on 2 500GB Samsung Spinpoint F1's that run in raid 0 mode for speed purposes. Partitioning is done so that the operating system, programs, data, temp-files, photoshop swap file, windows swap file (and some more partitions) are each on separate partitions.
    5) CPU/GPU temperatures are on nice levels (about 50°C each) and at least what I see from the CPU usage all 4 CPU-cores are getting bored during all this (less than 10% usage each).
    6) This is nothing that is limited to the polygon lasso tool: If i use the clone stamp tool or a brush I get the same problem after moving the image around with the move tool on a higher zoom level.
    7) I didn't have this problem on my old pc with Athlon 64 4000+ single core with 2 MB RAM and Windows XP Prof. 32 Bit. Furthermore I haven't seen my new pc without that problem so far. So the problem exists from the beginning.
    Any help is much appreciated! I hope I made myself as clear as possible. If there are questions on your side please ask.
    Kind Regards
    Steve

    Yes, of course the guarantee is solely on the vendor's part. They give 5 years of guarantee on the hardware as they build them together.
    That is an interesting information with CS3 and multi-core-systems. I shall google that and see what information I find about it. Thanks for the remark.
    I'd be more than happy if some folks here could bring some more light in the 64Bit-RAM-size-scratch-disk-issue and how it affects CS3-behavior. Would be really helpful.
    Right now it should be (almost) like this: Vista gets about 2.5GB of RAM, Photoshop gets about 3.5GB of RAM, that is if Photoshop would take it (I'm not sure if it does although I configured it to do so). Being able to use the whole 6GB of RAM was the reason to use a 64Bit OS.
    EDIT: I found a test with dual-core and quad-core systems with Photoshop CS3. The operating system seems to be 32 Bit though. It seems that CS3 doesn't scale very well with 4 cores. It uses 2 apparently but cannot make use of more. But anyway as I said: My old PC with a speed of 2.4GHz (single core Athlon 64 4000+) whose clock-speed is not directely comparable to my i7's 4GHz because of efficiency did the job without studdering. It had only one core that was much (!) slower than any single core on my i7. Even if the multi-core cannot be used from CS3 one would think that it had to run faster with the i7. In my opinion it must have something to do with either the 64 Bit OS or the raid0. The partions were no issue on the old machine (although I used multiple HDDs in the past so Windows and Photoshop were on the same HDD on different partitions but the scratch disks were on another).

  • How to create an Interactive Moving Background or Object that Reacts to Viewer's Cursor?

    Hi,
    i started creating a website in muse and i try to create an object who react to viewer's cursor.
    I have an image in center fix, and around and other which had to move with cursor movement like in this tutorial : Create an Interactive Moving Background/Object that Reacts to Viewer's Cursor
    i'd like to do it in muse and don't know how to proceed,
    thanks

    Hi,
    There is no native feature in Muse to achieve it. If you can get the code for this, you can add it to your site using Insert HTML feature.
    Regards,
    Aish

Maybe you are looking for

  • How to remove the pop-up window ''Wireless Radio Status" for t430s

    Hi, I have owned my t430s for now about 2 years without any major complaints recently I've had to use the fn + f5 function quite frequently, because of my poor internet connection. so that way i can reset which signal I want to choose because the def

  • Excise duty actuals

    Hi experts Excise duty actual While creating PO tax code selected as exise duty actuals Ex: Quantity 15000 Price Rs.25 per unit  (this price including excise duty) VAT 4% While booking MIGO the following entries are updating manually (Excise duty) Ba

  • Greyed out songs on iPhone and not visible at all in iTunes

    I have recently had to replace my iphone due to the microphone breaking, when restoring my new iphone and attempting to transfer all my music onto it, I noticed it asking me to sign in to the apple store with an email address I have never used or rec

  • External USB drive won't mount after 10.9.5 upgrade

    Is anyone else reporting the following issue?  Immediately after installing OS X update 10.9.5 (13F34) on 09/18, my external USB drive (IOMega 1GB OS X Extended FS) used for Time Machine would no longer mount and isn't recognized.  When I look at the

  • Apex install on 10.2 - Needed Apache having problems starting

    Hi, I am trying to get Apex running on a 10.2 database (Linux 64). To do so I need a webserver so I downloaded the companion and installed. During the install I was asked to place into a new Oracle home so I did so. After the install I have been unab