A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to add limiting "walls" to movement of MC controlled by buttons

  1. #1
    exclusive member ( V I P ) tiGRAN=-2001's Avatar
    Join Date
    Aug 2001
    Posts
    434

    How to add limiting "walls" to movement of MC controlled by buttons

    Hello wizards,

    I am trying to make a simple scrolling thumbnail menu for some photos.

    I used the following script (tutorial) to add the movement functions to the up and down buttons, which have instance names "moveUp" and '"moveDown".

    The thumbnails are in a vertical looking MC named "rocket".

    I have no problem scrolling up and down, but I want to limit the functionality of the buttons when the rocket is between coordinates Y=0 and Y=-1200

    How can I add that to this script?

    Code:
    moveUp.onPress = function() {
    rocket.onEnterFrame = function() {
    this._y -= 18;
    }
    }
    moveUp.onRelease = function() {
    delete rocket.onEnterFrame;
    }
    //
    moveDown.onPress = function() {
    rocket.onEnterFrame = function() {
    this._y -= -18;
    }
    moveDown.onRelease = function() {
    delete rocket.onEnterFrame;
    }
    //
    moveUp.onReleaseOutside = function() {
    delete rocket.onEnterFrame;
    }
    moveDown.onReleaseOutside = function() {
    delete rocket.onEnterFrame;
    }
    I actually tried to use the following code to stop the movement but it doesn't work because you can pass the limit assigned and it only gets back after another click.

    Code:
    //
    if (rocket._y > 0) {
    rocket._y = 0;
    }
    }
    if (rocket._y < -1200) {
    rocket._y = -1200;
    }
    Please help me find a solution,

    Thanks!!
    Tigran
    Last edited by tiGRAN=-2001; 09-18-2009 at 08:05 PM.

  2. #2

  3. #3
    exclusive member ( V I P ) tiGRAN=-2001's Avatar
    Join Date
    Aug 2001
    Posts
    434
    Thanks for the link, but I don't know how to change the the up and down functions to address my buttons.

    It would be great if I can use that code with scrolling wheel on the mouse!! But mainly the buttons, any idea of how to refer to the buttons within that function?

  4. #4
    exclusive member ( V I P ) tiGRAN=-2001's Avatar
    Join Date
    Aug 2001
    Posts
    434
    anyone else wanna look at the code that's posted? I just can't speak actionscript otherwise I know what needs to be done..

Tags for this Thread

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