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
|
function traceFleche(evt:Event){
terrain.addEventListener( MouseEvent.MOUSE_DOWN, clicSouris);
function clicSouris( event:MouseEvent ):void {
var monDessin:Shape = new Shape();
idF+=1;
monDessin.name="fleche_"+(idF);
trace(monDessin.name);
addChild( monDessin );
terrain.addEventListener( MouseEvent.MOUSE_DOWN, clicSouris );
var positionX:Number=event.stageX;
if(positionX>450) positionX=450;
var positionY:Number=event.stageY;
terrain.addEventListener(MouseEvent.MOUSE_MOVE, bougesouris);
function bougesouris(event:MouseEvent):void {
monDessin.graphics.clear();
monDessin.graphics.lineStyle( 8, 0x0000CC, 1 );
monDessin.graphics.moveTo( positionX, positionY );
var positionX2:Number=monDessin.mouseX;
if(positionX2>450) positionX2=450;
var positionY2:Number=monDessin.mouseY;
monDessin.graphics.lineTo( positionX2, positionY2 );
}
terrain.addEventListener( MouseEvent.MOUSE_UP, relacheSouris );
function relacheSouris( event:MouseEvent ):void {
terrain.removeEventListener(MouseEvent.MOUSE_MOVE,bougesouris);
terrain.removeEventListener(MouseEvent.MOUSE_DOWN,clicSouris);
}
}
} |
Partager