Bonjour,
je revient vers vous pour un probléme de ciblage dans le quel je suis paumer :
voici mon code qui sert à créer des cartes dans un clip(dèjà présent sur la scéne dont l'occurence s'appel "j1_aff_main", quand je veut rendre mes cartes "clickable" je rencontre un probléme de ciblage :
pour le test j'appel ma fonction ainsi : creation_carte("j1");
j'ai essayé pour test les écriture suivante :
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 function creation_carte(joueur) { /************ toute cette partie fonctionne (apparement) *************/ var id:int=this[joueur+"_main"].length-1; var maCarte:MovieClip = new carte(); maCarte.name="carte-"+id; this[joueur+"_aff_main"].addChild(maCarte); this[joueur+"_aff_main"].getChildByName("carte-"+id).x=32*id+5; this[joueur+"_aff_main"].getChildByName("carte-"+id).y=-5; this[joueur+"_aff_main"].getChildByName("carte-"+id)["nom_carte"].text=this[joueur+"_main"][id]; /*******************************************************************/ this[joueur+"_aff_main"].getChildByName("carte-"+id).addEventListener(MouseEvent.MOUSE_UP,carte_action); trace(this[joueur+"_aff_main"].name); function carte_action() { trace(this[joueur+"_aff_main"].getChildByName("carte-"+id).name); /* au click ça renvoie cette ereur TypeError: Error #1010: Un terme n'est pas défini et n'a pas de propriété.*/ at MethodInfo-8() } }
enfin bref il y a un truc qui m'échappe...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 trace(j1_aff_main.getChildByName("carte-"+id).name);//<- ça marche trace(root[joueur+"_aff_main"].getChildByName("carte-"+id).name);/* ça marche, mais le root il vaux mieux éviter il me semble.*/ trace(parent[joueur+"_aff_main"].getChildByName("carte-"+id).name); /* ça renvoie Error #1069: La propriété j1_aff_main est introuvable sur flash.display, ce qui me parait normal*/
Partager