FORUMS: list search recent posts

AS3 - arrays

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Victoria Poole
AS3 - arrays
on Sep 13, 2010 at 10:31:54 pm

Hello again,

So I'm creating this game where I have 9 information cards (dynamically loaded onto the stage) that the user will drag one by one onto their choice of 3 category cards (movie clips that are on the stage)

I created a class for the cards to make them scale up and be draggable when clicked.

Now I'm trying to write the code for when you drop a card onto a category.

What I (I think?)want to have happen is when the card is dropped it becomes a child of the card it's dropped on (in this case, talented_mc) and then it gets scaled down so a mini version of the card can be seen over talented_mc.

That part works.

When I drop another card on the same talented_mc, I want it to scale down and go next to the card that's already there (if there is one already there) instead of on top of it.

I don't know how to make that work.

I also will want to be able to track what cards got placed where after all the cards are placed, which is why I created the array, "talentChoice". But when I push "choiceCard" to the array, it will only ever hold one card. The item in the array gets overwritten if a new item is pushed to it.

Sorry this is so long. Hope you can help!

Here's part of what I have so far:

var cardList:Array = new Array();
for(var i:uint=0; i<boardW*boardH; i++)

for(var x:uint=0;x<boardW;x++)
for(var y:uint=0;y<boardH;y++)
var c:Card = new Card();
c.x = x*cardHSpacing+boardOffsetX;
c.y = y*cardVSpacing+boardOffsetY;

var r:uint = Math.floor(Math.random()*cardList.length);
c.cardface = cardList[r];

c.addEventListener(MouseEvent.CLICK, clickCard);

function clickCard(event:MouseEvent)
var thisCard:Card = (event.currentTarget as Card);


c.addEventListener(MouseEvent.MOUSE_UP, checkTarget);

function checkTarget(event:MouseEvent):void
var choiceCard:Card = (event.currentTarget as Card);
var _talentX:Number = 50;
var _talentY:Number = 100;
var talentChoice:Array = new Array();

if (choiceCard.dropTarget != null && choiceCard.dropTarget.parent == talented_mc)
trace("dropped on talented");

choiceCard.scaleX = .3;
choiceCard.scaleY = .3;
choiceCard.x = _talentX;
choiceCard.y = _talentY;
_talentY += choiceCard.height + 50;

if (choiceCard.cardface == 1)
trace("boss relationships");

trace("not dropped on talented");

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved