Bonjour,
Je voulais créer un custom component pour la gestion de fenêtres dynamiques. L'idée est de créer un canvas contenant deux panels. Et après, permettre l'ajout des éléments dans ces panels.
Pour ce faire j'ai créé:
- une classe qui hérité du Canvas appelée "WindowControler".
- un MXML component appelé "WindowContainer" comme suit:
Et je l'appelle dans l'application comme suit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0" encoding="utf-8"?> <s:Group 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:window="window.*"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> <fx:String id="iconeHeaderSource"/> <fx:Number id="iconeHeaderHeight"/> <fx:Number id="iconeHeaderWidth"/> <fx:Number id="iconeHeaderXLocation"/> <fx:Number id="iconeHeaderYLocation"/> <fx:String id="iconeResizeSource"/> <fx:Number id="iconeResizeHeight"/> <fx:Number id="iconeResizeWidth"/> </fx:Declarations> <fx:Style source="WindowCSS.css" /> <window:WindowControler id="controler" view="{this}" height="100%" width="100%" creationComplete="{controler.init()}"> <mx:Panel id="panelPrincipal" title="Panel Principal" x="30" y="30"> <mx:Panel id="panelContent"> </mx:Panel> </mx:Panel> </window:WindowControler> </s:Group>
Mais lorsque je veux ajouter des éléments dans le panel "panelContent" (un bouton par exemple), j'ai le message d'erreur "In initializer for 'panelContent', type mx.controls.Button is not assignable to target type 'mx.containers.Panel'."
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?xml version="1.0"?> <!-- dragdrop\DandDImage.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:s="library://ns.adobe.com/flex/spark" horizontalAlign="left" xmlns:window="window.*"> <window:WindowContainer id="conteneur" iconeHeaderSource="D:/Flex Projects/assets/icone.png" iconeHeaderHeight="50" iconeHeaderWidth="50" iconeHeaderXLocation="0" iconeHeaderYLocation="0" iconeResizeSource="D:/Flex Projects/assets/resizeIcone.png" iconeResizeHeight="16" iconeResizeWidth="16"> <window:panelContent> <mx:Button label="test"> </mx:Button> </window:panelContent> </window:WindowContainer> </mx:Application>
Pourriez vous m'aider à résoudre le problème?
Merci d'avance.
Partager