# Unload movie

**URL:** <https://forum.kirupa.com/t/unload-movie/328275>\
**Category:** Uncategorized\
**Created:** [May 3, 2012, 6:23am UTC](https://forum.kirupa.com/t/unload-movie/328275 "2012-05-03T06:23:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohya](https://avatars.discourse-cdn.com/v4/letter/o/fbc32d/32.png) [@ohya](https://forum.kirupa.com/u/ohya)\
**Post date:** [May 3, 2012, 6:23am UTC](https://forum.kirupa.com/t/unload-movie/328275/1 "2012-05-03T06:23:44Z")

</div>

I learn a dragon shooting game from Kirupa. I want to unload the dragons but the dragons run to the corner, need help from the expert.

This is the script:

var dragons:Number = 2;  
var i:Number = 0;  
var score:Number = 0;

function initDragons() {

for (i; i\<dragons; i++) {

attachMovie(“dragon”, “dragon”+i, i);  
dragon = \_root[“dragon”+i];  
updateDragons(dragon);  
dragon.onEnterFrame = function() {

if (this.\_x\>0) {

this.\_x -= this.velo;

} else {

updateDragons(this);

}

};

}

}  
initDragons();  
function updateDragons(which) {

which.\_x = random(100)+530;  
which.\_y = random(80)+80;  
which.velo = random(10)+2;

}

on (press) {unloadMovie(“dragon”);updateDragons(this);  
}
