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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" height="600" width="750" minWidth="955" minHeight="600"
applicationComplete="init()" frameRate="60">
<mx:UIComponent id="uioc" />
<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
<fx:Declarations>
</fx:Declarations>
<fx:Script>
<![CDATA[
import flash.utils.Timer;
import mouvement.Lancer;
import mx.controls.Alert;
import objet.Balle;
public function init():void
{
tracerSol();
/*laBalle = new Balle();
balleLance = new Lancer(laBalle);
uioc.addChild(balleLance);*/
}
public function goBalle():void
{
var timer:Timer = new Timer(10, 300);
var laBalle:Balle = new Balle();
var balleLance:Lancer = new Lancer(laBalle);
// Valeur des inputs
balleLance.setForce(int(input_force.text));
balleLance.setAngle(int(input_angle.text));
// Calcul le x et le y qui va faire bouger la balle
balleLance.calculPositionBalle();
// Accrocher au conténeur
uioc.addChild(balleLance);
/*balleLance.addEventListener(Event.ENTER_FRAME, balleLance.mouvementBalle);*/
timer.addEventListener(TimerEvent.TIMER, balleLance.mouvementBalle);
timer.start();
}
/**
* Fonction qui trace le sol
*/
public function tracerSol():void
{
var myShape:Shape = new Shape();
myShape.graphics.lineStyle(1, 0x990000, 0.75);
myShape.graphics.moveTo(0, 550);
myShape.graphics.lineTo(750, 550);
uioc.addChild(myShape);
}
]]>
</fx:Script>
<!-- Ajout d un panneau -->
<s:Button label="Lancer Balle" id="bouton_action" height="40" width="120" y="30" x="380" click="goBalle()"/>
<s:TextInput id="input_force" y="30" x="200" />
<s:TextInput id="input_angle" y="60" x="200" />
<s:Label x="114" y="30" text="Force" width="78" height="22" verticalAlign="middle" textAlign="right"/>
<s:Label x="114" y="59" text="Angle" width="78" height="22" verticalAlign="middle" textAlign="right"/>
</s:Application> |
Partager