A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Goes right off the Blumin' screen

  1. #1
    Member
    Join Date
    Apr 2001
    Posts
    39

    Wink

    I've just started in with a bit more advanced Flash Programming and i've hit what seems to be an Impass.
    Reading the book "Flash 5 Magic" and in one of the chapters on modular programming, it gives the code for screen wraping, but i can't seem to get it to work. not to mention i'm trying to get it to stop when the boundries touch, not even jump to the other side of the screen...Is there any help??? if it's something inside the .FLA file, i can send it to ya.

  2. #2
    I think the trick is to have an mc the same size as your movie (or the area you want to keep the object in).

    If you call this instance for example background and put this code on the movieclip you wish to move

    onClipEvent (enterFrame) {
    }
    // screenmapping
    object=this.getBounds( _root );
    screen=_root.background.getBounds( _root);
    if (object.yMax<screen.yMin) {
    this._y = screen.yMax;
    }
    if (object.yMin>screen.yMax) {
    this._y = screen.yMin;
    }
    if (object.xMax<screen.xMin) {
    this._x = screen.xMax;
    }
    if (object.xMin>screen.xMax) {
    this._x = screen.xMin;
    }
    }

    I hope that helps

  3. #3
    Member
    Join Date
    Apr 2001
    Posts
    39

    Angry here, maby the code it's self will help

    onClipEvent(enterFrame){

    CarBounds = Car.getBounds(_root);
    screen = _root.screen.getBounds (_root);

    if(CarBounds.yMax < screen.yMin){
    this._y = screen.yMax;}
    if(CarBounds.yMin > screen.yMax){
    this._y = screen.yMin;}
    if(CarBounds.xMax < screen.xMin){
    this._x = screen.xMax;}
    if(CarBounds.xMin > screen.xMax){
    this._x = screen.xMin;}
    }

  4. #4
    Member
    Join Date
    Apr 2001
    Posts
    39

    Thanks

    Ty Devil art, i'm beginning to wonder if my flash program is just goofed up and i have to re install it. the other day with that same code, it worked occasionally, but then it would stop..i don't understand why lol, but ty, i'll try that

  5. #5
    Its exactly the same as I wrote.

    Mine works though.

    Could you just check to see if you have named all of your mcs on the screen

  6. #6
    Member
    Join Date
    Apr 2001
    Posts
    39

    ok, another question lol

    Now, how can i use this same code to make the object stop at the bounds of the screen, kinda like a car running into a brick wall lol

  7. #7
    Just change a few of the fields round


    onClipEvent (enterFrame) {
    // screenmapping
    object=this.getBounds( _root );
    screen=_root.background.getBounds( _root);
    if (object.yMax<screen.yMin) {
    this._y = screen.yMin;
    }
    if (object.yMin>screen.yMax) {
    this._y = screen.yMax;
    }
    if (object.xMax<screen.xMin) {
    this._x = screen.xMin;
    }
    if (object.xMin>screen.xMax) {
    this._x = screen.xMax;
    }
    }

    This doesn't take into account the width of the object.

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