Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Flash/Flex > Flex
Flex Forum d'entraide sur la programmation Adobe Flex : applications Internet riches (RIA)
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 02/09/2011, 16h16   #1
Invité de passage
 
Inscription : septembre 2011
Messages : 3
Détails du profil
Informations forums :
Inscription : septembre 2011
Messages : 3
Points : 3
Points : 3
Par défaut Récupération de variables entre deux fichiers MXML frères en passant par leur père

Salut à toi ami développeur,

Je vais synthétiser mon problème pour le clarifier, j'ai 3 fichiers MXML :


panelAlpha.mxml (un Panel)
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
<?xml version="1.0" encoding="utf-8"?>
<!--
	panelAlpha.mxml
-->
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
	 xmlns:s="library://ns.adobe.com/flex/spark" 
	 xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
	<fx:Script>
		<![CDATA[
			public var _variableStatic : String = "Variable publique et statique";
			public var _variable : String = "Variable publique mais non statique";
			[Bindable]
			public var _variableStaticBindable : String = "Variable publique, statique et liable";
			[Bindable]
			public var _variableBindable : String = "Variable publique et liable mais non statique";
		]]>
	</fx:Script>
</s:Panel>
panelBeta.mxml (un autre Panel)
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
<?xml version="1.0" encoding="utf-8"?>
<!--
	panelBeta.mxml
-->
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
	 xmlns:s="library://ns.adobe.com/flex/spark" 
	 xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
		 creationComplete="init()">
	<fx:Script>
		<![CDATA[
			public var _variable : String;
 
			private function init() : void {
				_variable = '';
			}
		]]>
	</fx:Script>
</s:Panel>
exemple.mxml (celui qui lance l'application)
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<?xml version="1.0" encoding="utf-8"?>
<!--
	exemple.mxml
-->
<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"
		   xmlns:panel="panel.*"
		   width="821" height="300" minWidth="955" minHeight="600">
	<panel:panelAlpha />
	<panel:panelBeta x="421" y="0"/>
</s:Application>
Tu peux donc remarquer que j'ai inséré mes deux panels dans mon composant principal.

Ma question est simple, comment et avec quelle variable de panelAlpha.mxml puis-je initialiser ma variable _variable dans panelBeta.mxml ?



Je te remercie d'avance
Smoke Hyzbade est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 02/09/2011, 16h27   #2
Invité de passage
 
Inscription : septembre 2011
Messages : 3
Détails du profil
Informations forums :
Inscription : septembre 2011
Messages : 3
Points : 3
Points : 3
Par défaut Réponse

La réponse est dans le code les amis !


Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
<?xml version="1.0" encoding="utf-8"?>
<!--
	panelBeta.mxml
-->
<s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
	 xmlns:s="library://ns.adobe.com/flex/spark" 
	 xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
		 creationComplete="init()">
	<fx:Script>
		<![CDATA[
			import mx.core.FlexGlobals;
			public var _variable : String;
 
			private function init() : void {
				_variable = FlexGlobals.topLevelApplication.panelAlpha._variable;
			}
		]]>
	</fx:Script>
</s:Panel>


Je vous remercie quand même et espère que ça aidera
Smoke Hyzbade est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 05/09/2011, 10h53   #3
Membre Expert
 
Avatar de Madfrix
 
Inscription : juin 2007
Messages : 2 279
Détails du profil
Informations personnelles :
Localisation : France, Gironde (Aquitaine)

Informations forums :
Inscription : juin 2007
Messages : 2 279
Points : 2 325
Points : 2 325
Bonjour,

il vaut mieux toujours passer par des événements (perso ou non) afin de découpler les composants au maximum
__________________
Je ne réponds pas aux questions envoyées par mp
Madfrix est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h29.


 
 
 
 
Partenaires

Hébergement Web