dcsimg
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: Stay scrolling when down

  1. #1
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148

    Stay scrolling when down

    I have been trying to get my head round scrolling and am not quite there (a bit of an understatement). I have managed to get a button to move and object left and another to move it right. However it only moves the object every time I click, I want to be able to keep the object moving if I keep the mouse down, also is there a code that makes the object look more like it's moving instead of jumping?????

    on (press) {
    mouse_x = _xmouse;
    setProperty (_root.follow, _x, mouse_x+((getProperty(_root.follow,_x)-mouse_x)+10));
    }

    on (press) {
    mouse_x = _xmouse;
    setProperty (_root.follow, _x, mouse_x+((getProperty(_root.follow,_x)-mouse_x)-10));
    }

  2. #2
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Hi.....
    If you post the fla. in MX format....i might be able to help.

  3. #3

  4. #4
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714

    scroll prob

    Hi littlematt....

    Here is one way..... two variables...
    moveleft... and.... moveright.... which are initialized on the keyframe to control the movement of the 'followMC' .....if their values are switched from false to true then movement occurs...
    then a statement that says 'if they go beyond this point, change the variable back to false.....'
    So this goes on the keyframe....
    code:
    moveright = false;//variable
    moveleft = false;//variable
    follow.onEnterFrame = function() {
    if (_root.moveright == true) {
    this._x += 5;//speed of movement right
    if (this._x>550) {//this stops movie going further 550 right
    _root.moveright = false;
    }

    }
    if (_root.moveleft == true) {
    this._x -= 5;//speed of movement left
    if (this._x<100) {//this stops movie going further than 100 left
    _root.moveleft = false;
    }
    };
    }


    Then to control the variables value ....place this on the left button
    code:
    on (press) {
    _root.moveleft = true;
    }
    on (release) {
    _root.moveleft = false;
    }


    then this on the right one...
    code:
    on (press) {
    _root.moveright = true;
    }
    on (release) {
    _root.moveright = false;
    }


    and that should do the trick!...here is an update of your fla. to demonstrate.....edit the parameters to suit your project.....
    hope this helps
    hum

  5. #5

  6. #6
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    Is there a way of stopping the buttons (when clicked again) from moving the mc when it reaches the end of the image?

  7. #7
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    how do you mean ....when it reaches the end of the image......
    do you mean when it reaches the edge of stage?

  8. #8

  9. #9
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    sorry....not sure what you mean....you have 2 buttons and a small MC with the words 'text'in the fla.....i don't see an image......
    Can you explain in more detail.....

  10. #10
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    Sorry, that is the old test file, I have taken that file and placed a long image in the follow mc. The image is 3096px long. I have set the amount so that it can move 4000 pixels each way

    if (this._x>4000) {
    if (this._y>4000) {

    Even when I set it to 3096 each way it keeps scrolling past the end of the image.

    I would upload the fla but IE wont let me and my Safari no longer likes flashkit...

  11. #11
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Hi littleMatt....
    ok....the length of your image is not 3096 it is 309.6
    so you need to put 400 instead of 4000.
    code:
    moveright = false;//variable
    moveleft = false;//variable
    follow.onEnterFrame = function() {
    if (_root.moveright == true) {
    this._x += 5;//speed of movement right
    if (this._x>400) {//this stops movie going further 550 right
    _root.moveright = false;
    }

    }
    if (_root.moveleft == true) {
    this._x -= 5;//speed of movement left
    if (this._x<400) {//this stops movie going further than 100 left
    _root.moveleft = false;
    }
    };
    }


    Try that......

  12. #12
    Senior Member littleMatt's Avatar
    Join Date
    Apr 2004
    Posts
    1,148
    It doesn't want to move to the right with the < in:

    if (this._x<400)

    If I change it to > it scrolls but still past the end of the image.

  13. #13

  14. #14
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    hi little matt...
    can you save it in MX format .....not MX2004......then post the fla.
    i have MX......

  15. #15

  16. #16
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    Try again......that is still mx2004 format.....
    There is an option that enables you to save as MX

  17. #17

  18. #18
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    ooops....still not working....
    a few people have this prob.......check the save as ...then format tab

  19. #19

  20. #20
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714
    tell you what.....iv'e just got to finish helping someone else then i'll make an image 309.6 on the original fla. you sent... and fix the code so it doesn't scroll off stage.....i don't understand why the fla. you are trying to post doesn't work.....aah well.....i'll post a little later...hang in there!

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