A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [Question]: MC delete after play

  1. #1
    Member
    Join Date
    May 2007
    Posts
    48

    [Question]: MC delete after play

    hey guys,

    is there a quick and easy way to delete a MC immediately after it plays once?
    like a function that plays the clip once and then deletes it?

    without knowing of any special functions to do that, i thought about:
    -play the movie clip
    -wait x seconds for movie clip to run 1 time through
    -delete movie clip

    EDIT:
    or maybe count x number of frames and delete?

    thanks,

  2. #2
    Member
    Join Date
    May 2007
    Posts
    48
    i just dynamically created the object and made an onenter event for it.
    in the event, i counted down the number of frames. when it hits zero, i delete the object.

    seems to work

  3. #3
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Code:
    movieClip.aliveTime = 0;
    
    movieClip.onEnterFrame=function() {
    if (this._aliveTime < this._totalframes) {
    this.aliveTime++;
    } else {
    this.removeMovieClip();
    }
    }
    I am away from my computer this weekend so you may need to check the syntax on _totalframes, but I believe that is correct. Easy and painless.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  4. #4
    Member
    Join Date
    May 2007
    Posts
    48
    cool....

    i came up with something similar:

    code:

    mc.onEnterFrame = function(){
    this.frames--;
    if (this.frames == 0){
    this.removeMovieClip();
    }



    it just requires to initiallize mc.frames first.

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Either way works fine, but this way you can change number of frames without having to reset your variable.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  6. #6
    Member
    Join Date
    May 2007
    Posts
    48
    Quote Originally Posted by ImprisonedPride
    Either way works fine, but this way you can change number of frames without having to reset your variable.
    true

  7. #7
    Member
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    66
    Code:
    mc.onEnterFrame = function() {
       if (this._currentframe == this._totalframes) {
          this.removeMovieClip();
       } else {
       }
    }
    No variables needed.

  8. #8
    Member
    Join Date
    May 2007
    Posts
    48
    Quote Originally Posted by StephenN
    Code:
    mc.onEnterFrame = function() {
       if (this._currentframe == this._totalframes) {
          this.removeMovieClip();
       } else {
       }
    }
    No variables needed.

    sweet.... that works perfectly.

    thanks for the help, guys.

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