SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    destroying movieclip after movie's boundaries

    onClipEvent (enterFrame) {

    _x+=8.5;
    while (_x>=750){
    if (_x>=750) {
    removeMovieClip(this);
    }
    }
    }

    ----------
    700 x 500 is the dimensions of my movie. I added 50 to account for the size of my movieclip. I'm not sure if doing this is correct, or using bounds._x + bounds._width or whatever.
    Thanks in advance.

  2. #2
    SHIZA
    Join Date
    Apr 2003
    Location
    Great White North
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't really understand what your trying to do. remove the clip? or once the while statment is complete if your just trying to get rid of it just use the removeMovieClip function. p.s iam a bit rusty at flash.
    Pixel Engineer

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by korruptking
    i don't really understand what your trying to do. remove the clip? or once the while statment is complete if your just trying to get rid of it just use the removeMovieClip function. p.s iam a bit rusty at flash.
    1. move the movie clip at constant speed.
    2. once it goes past boundary (movie is 700x500), remove it

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2002
    Location
    New York, NY
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    firstly, you can only use the function removeMovieClip() if the movieclip is a duplicate of another movieclip (a result of duplicateMovieClip())

    secondly, the while() clause you have in the actionscript is unneccassary, i.e. all you need is:

    Code:
    onClipEvent (enterFrame) {
       _x += 8.5;
       if (_x > 750) {
    	  removeMovieClip(this);
       }
    }
    zing
    Better-Barter.com
    Logo store full of unique, professional identities
    perfect for you or your client!

  5. #5
    SitePoint Zealot webQS's Avatar
    Join Date
    Oct 2002
    Location
    Sydney : Australia
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use the stage object to make this extensible...


    Code:
    onClipEvent (enterFrame) {
       //storing the required increment vars in a clip in the root timeline
       //need to explicitly declare what is being moved here.
       this._x +=  _root.vars.xmove;
       this._y +=  _root.vars.ymove;
       //check if the clip has moved outside the stage boundaries
       if (this._x > stage.width || this._x < -this._width || this._y > stage.height || this._y < -this._height) {
    	  removeMovieClip(this);
       }
    }
    So if the clip moves outside the stage it gets removed. Note that the clip has to move completely outside the stage for it to be removed - why the -this._width and _height is being used

    HTH
    James

    ...I should qualify that the stage object is available in Flash Player 6 minimum.

  6. #6
    SitePoint Member
    Join Date
    May 2003
    Location
    Singapore
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, sorry, being a newbie at all this, I'm not too sure how to access the duplicated movie clip(didn't use the stage object method because I'm only using this once).

    I tried:
    Code:
    onClipEvent(load) {
    	duplicateMovieClip(mcPlatform1, mcPlatform2, 1010);
    }
    onClipEvent (enterFrame) {
       _parent.mcPlatform2._x += 8.5;
       if (_parent.mcPlatform2._x > 750) {
    	  removeMovieClip(_parent.mcPlatform2);
       }
    }
    where mcPlatform1 is the original movieclip, mcPlatform2 is the duplicated instance that should travel across the stage.
    I assumed that you couldn't just do _x+=whatever straight away from the code on the movie clip instance, but I had problems trying to accessing the duplicated movie clip.
    Last edited by qwing; Jun 5, 2003 at 03:00.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •