mercredi 25 janvier 2017

Use a child in as3 adobe animate

I making a card game and i call some cards from the library randomly. But i cant use this cards. Is there any way to make this childs clickable? And another question please. If there any chance to use one print array for all the 22 cards i need to show on stage?Or i must to create a new printarray and a new random number for each card? Note:each card has different points.

var cards:Array = [k1, p1, s1, r1, r3,k4,p4,s4,r4,k5,p5,s5,r5
 ,k6,p6,s6,r6,k7,p7,s7,r7,k8,p8,s8,r8,k9,p9,s9,r9,k10,p10,s10,r10,
 kj,pj,sj,rj,kq,pq,sq,rq,kk,pk,sk,rk];

var printArray:Array = [];

for (var n:int = 1; n <= 1; n++)
{
    var randNo:int = int(Math.random() * 51);
    printArray.push(randNo);
}

for (var c:int = 0; c < printArray.length; c++)
{
    trace(printArray[c]);
    var mc:MovieClip = new cards[printArray[c]  ];
    addChild(mc);
    mc.width = 60;
    mc.height = 80;
    mc.x = 100;
    mc.y = 50;
}


var print1Array:Array = [];

for (var n1:int = 1; n1 <= 1; n1++)
{
   var rand1No:int = int(Math.random() * 51);
   print1Array.push(rand1No);
}

for (var c1:int = 0; c1 < print1Array.length; c1++)
{
    trace(print1Array[c1]);
    var mc1:MovieClip = new cards[print1Array[c1]  ];
    addChild(mc1);
    mc1.width = 60;
    mc1.height = 80;
    mc1.x = 70;
    mc1.y = 80;
}

stage.addEventListener(Event.ENTER_FRAME,looping);
function looping(event:Event):void
{
    //here ia want use the cards.Let say i want to if(mc1 is clicked)
}

Aucun commentaire:

Enregistrer un commentaire