A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Prevent movement off screen

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    3

    I Add some code with urs!

    onClipEvent (load) {
    speed = 15;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {

    preXcor=_x;

    _x -= speed;
    _xscale = -100;

    if (_x<0){
    _x=preXcor

    }
    }
    if (Key.isDown(Key.RIGHT)) {
    preXcor=_x;
    _x += speed;
    _xscale = 100;
    tot=_x+this._width
    if (tot>Stage.width){
    _x=preXcor;
    }


    }
    }

  2. #2
    Member
    Join Date
    Jun 2005
    Posts
    45
    That works great thanks!

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