1 pièce(s) jointe(s)
Erreur systématique lors d'un premier changement d'état
Bonjour à tous :coucou:
J'utilise flex depuis pas mal de temps mais à chaque fois une chose m'échappe.
Je vous soumet mon problème en espérant que quelqu'un pourra m'aider à y voir plus clair.
Cette erreur se manifeste à chaque fois que j'utilise les états de l'application.
Celle-ci dispose d'un bouton lui permettant de changer d'état.
Or voici ce qui se produit à chaque premier clic sur ce bouton :
- une erreur se déclenche (référence nulle)
- l'application ne change pas d'état.
Tous les autres clics sur ce bouton :
- pas d'erreur
- le changement d'état s'opère
- la transition se déroule correctement
Le swf est disponible en pièces jointes et en voici le code source :
Code:
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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" height="100%" width="100%">
<mx:Script>
<![CDATA[
public function AjouterPrestation():void
{
pPrestations.enabled = false;
pPeriode.enabled = false;
vStack.selectedIndex = 1;
ajouterDate.selectedDate = date.selectedDate;
currentState = "stateEffect";
}
public function Retour():void
{
vStack.selectedIndex = 0;
pPrestations.enabled = true;
pSelection.enabled = false;
pPeriode.enabled = true;
this.currentState = "";
}
]]>
</mx:Script>
<mx:states>
<mx:State name="stateEffect">
<mx:SetProperty target="{vStack}" name="width" value="1000"/>
<mx:SetProperty target="{selectionTaches}" name="width" value="850"/>
<mx:SetProperty target="{selectionRemarque}" name="width" value="450"/>
<mx:SetProperty target="{ajouterTaches}" name="width" value="850"/>
<mx:SetProperty target="{ajouterRemarque}" name="width" value="450"/>
<mx:SetProperty target="{c2}" name="visible" value="false"/>
<mx:SetProperty target="{c3}" name="visible" value="false"/>
<mx:SetProperty target="{c4}" name="visible" value="false"/>
<mx:SetProperty target="{c6}" name="visible" value="false"/>
</mx:State>
</mx:states>
<mx:transitions>
<mx:Transition fromState="*" toState="*">
<mx:Sequence targets="{[pPrestations, vStack, selectionTaches, ajouterTaches, selectionTaches, ajouterRemarque]}">
<mx:Blur blurYFrom="0" blurYTo="10" duration="100" filter="move"/>
<mx:Parallel >
<mx:Move/>
<mx:Resize/>
</mx:Parallel>
<mx:Blur blurYFrom="10" blurYTo="0" duration="100" filter="move"/>
</mx:Sequence>
</mx:Transition>
</mx:transitions>
<mx:HBox id="app" height="100%" width="100%">
<mx:Panel id="pPeriode" title="Période" layout="vertical">
<mx:DateChooser id="date"/>
</mx:Panel>
<mx:Panel id="pPrestations" title="Prestations" height="100%" width="100%" layout="vertical">
<mx:DataGrid id="listePrestations" height="100%" width="100%">
<mx:columns>
<mx:DataGridColumn id="c1" headerText="Jour" dataField="jour" width="70"/>
<mx:DataGridColumn id="c2" headerText="Date" dataField="date" width="90"/>
<mx:DataGridColumn id="c3" headerText="Durée" dataField="duree" width="60"/>
<mx:DataGridColumn id="c4" headerText="Etape" dataField="etape" width="180"/>
<mx:DataGridColumn id="c5" headerText="Tâche" dataField="tache" width="350"/>
<mx:DataGridColumn id="c6" headerText="Remarque" dataField="remarque"/>
</mx:columns>
</mx:DataGrid>
<mx:HBox width="100%">
<mx:Label id="statut"/>
<mx:Spacer width="100%"/>
<mx:LinkButton id="boutonAjouterPrestation" label="Ajouter une prestation" click="AjouterPrestation()"/>
</mx:HBox>
</mx:Panel>
<mx:ViewStack id="vStack" minWidth="289">
<mx:Panel id="pSelection" title="Agir sur la sélection" enabled="false">
<mx:Form>
<mx:FormItem label="Tâche">
<mx:ComboBox id="selectionTaches" labelField="NomTache" width="160" rowCount="25"/>
</mx:FormItem>
<mx:FormItem label="Date">
<mx:DateField id="selectionDate" formatString="DD/MM/YYYY"/>
</mx:FormItem>
<mx:FormItem label="Heures">
<mx:NumericStepper id="selectionHeures" value="0" minimum="0" maximum="8" stepSize="1"/>
</mx:FormItem>
<mx:FormItem label="Minutes">
<mx:NumericStepper id="selectionMinutes" value="0" minimum="0" maximum="60" stepSize="5"/>
</mx:FormItem>
<mx:FormItem label="Remarque">
<mx:TextArea id="selectionRemarque" height="80"/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar>
<mx:Button label="Supprimer"/>
<mx:Spacer width="100%"/>
<mx:Button label="Enregistrer"/>
</mx:ControlBar>
</mx:Panel>
<mx:Panel id="pAjouter" title="Ajouter une prestation">
<mx:Form>
<mx:FormItem label="Tâche">
<mx:ComboBox id="ajouterTaches" labelField="NomTache" width="160" rowCount="25"/>
</mx:FormItem>
<mx:FormItem label="Date">
<mx:DateField id="ajouterDate" formatString="DD/MM/YYYY"/>
</mx:FormItem>
<mx:FormItem label="Heures">
<mx:NumericStepper id="ajouterHeures" value="0" minimum="0" maximum="8" stepSize="1"/>
</mx:FormItem>
<mx:FormItem label="Minutes">
<mx:NumericStepper id="ajouterMinutes" value="0" minimum="0" maximum="60" stepSize="5"/>
</mx:FormItem>
<mx:FormItem label="Remarque">
<mx:TextArea id="ajouterRemarque" height="80"/>
</mx:FormItem>
</mx:Form>
<mx:ControlBar>
<mx:Button label="Retour" click="Retour()"/>
<mx:Spacer width="100%"/>
<mx:Button id="boutonAjouter" label="Ajouter" enabled="false"/>
</mx:ControlBar>
</mx:Panel>
</mx:ViewStack>
</mx:HBox>
</mx:Application> |
Pour ceux qui auront la bonté d'âme de tester ce code dans un nouveau projet, d'avance un grand merci ! ;)