1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| package com.shooter2012.explosions {
import flash.display.Sprite;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.display.Stage;
/**
* @author Benjamin
*/
public class MiniExplosion extends Sprite {
[Embed(source="../gfx/swf/StingerDetruit.swf")]
private var Ressource : Class;
private var stageRef : Stage;
public function MiniExplosion(s : Stage, x : Number, y : Number) {
stageRef = s;
this.x = x;
this.y = y;
var image : MovieClip = new Ressource();
addChild(image);
// Evénement
addEventListener(Event.COMPLETE,chargementTermine);
//image.contentLoaderInfo.addEventListener(Event.COMPLETE, chargementTermine);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}
// Boucle de l'explosion
private function loop(pEvt : Event) : void {
// removeEventListener(Event.ENTER_FRAME, loop);
// if (stageRef.contains(this)) stageRef.removeChild(this);
// Supprime l'explosion
}
function chargementTermine (evt:Event) {
if (stageRef.contains(this)) stageRef.removeChild(this);
}
}
} |
Partager