A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: mouse scrolling problem

  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    32

    mouse scrolling problem

    Hi a friend told me to have a look at his website.
    he has galleriess that move left or right depending on the place your mouse is.
    he asked me to add a picture in the gallery which i did.
    but then it jumps every time it loops.

    here is the bit of code that makes it move left i know how the-3192.15 was found but i dont know were they got 49 from

    function moveLeft(nPixels) {
    this._x -= nPixels;
    if (this._x < -3192.15) {
    this._x = 49;

    could anyone try help me understand thx

  2. #2
    Senior Member
    Join Date
    Aug 2009
    Location
    Scotland & England
    Posts
    117
    Well...

    if this is lower than -3192.15 on the stage then it will reset it back to the right via saying this._x = 49.

    Do you have a .swf or something you can show us so we can better work out the issue?

  3. #3
    Member
    Join Date
    Feb 2010
    Posts
    32
    Hi,

    here is the whole code from one of the pages with a gallery hope this helps...

    onClipEvent(load) {

    //this._alpha = 0;


    //nScreenWidth = 1000;
    nMaxRate = 5;
    // nPixels determines the speed of the slider movement
    function moveLeft(nPixels) {
    this._x -= nPixels;
    if (this._x < -3566) {
    this._x = 5027;
    }
    }
    function moveRight(nPixels) {
    this._x += nPixels;
    if (this._x > 5027) {
    this._x = -3566;
    }
    }
    }


    onClipEvent(enterFrame) {

    //if (this._alpha < 100) {
    //this._alpha += 3;
    //}

    // move slider with speed dependent on mouse position
    if (_root._xmouse < Stage.width/2 && _root._xmouse > 0) {
    moveRight(nMaxRate - _root._xmouse * nMaxRate/(Stage.width/2));
    } else {
    if (_root._xmouse > Stage.width/2 && _root._xmouse < Stage.width) {
    moveLeft(_root._xmouse * nMaxRate/(Stage.width/2) - nMaxRate);
    }
    }
    }





    the movie clip that holds all the photo's width and height is 17126 pixels by 200 pixels high

    the movie clips x position and y position is 3566x and 0y

    now this code works perfectly fine but as soon as i add a picture to the movie clip so it can scroll it it jumps every time it loops...

    i know that this value in the code ="-3566" is the x position of the movie clip
    but how did they get this value ="5027" in the code?

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Referencing the clip on which the code is placed...
    The clip is 17186 pixels wide and _x position is 3566. Guessing that this clip contains to identical instances of the content. Where each of the instances is 8593 pixels wide. Instance A has it's right side lined up with the center point of the clip and instance B has it's left side lined up with the center point of the clip. So, _x positions are -8593 and 0, respectively.

    17186 divide by 2 = 8593

    8593 minus 3566 = 5027


    HTH

  5. #5
    Member
    Join Date
    Feb 2010
    Posts
    32
    Thanks everyone. I understand the process to get the number. The programer that originally coded the pages did it approximately. So I was getting wrong numbers on every different page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center