A Flash Developer Resource Site

Results 1 to 4 of 4

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

Threaded View

  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.

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