FORUMS: list search recent posts

AS3 - swapDepths work around

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Victoria Poole
AS3 - swapDepths work around
on Sep 10, 2010 at 12:16:05 am

Hello,


I'm making an interaction where you have 9 cards on one side of the screne and you have to drag and drop them onto 3 piles.

I have it so when you roll over a card, it scales up and becomes the front-most card.

What I want to have happen, is when you roll away from it, it goes back to the depth at which it started.

This is the code I tried:
private function rollCard(event:MouseEvent):void
{
this.scaleX = 1.5;
this.scaleY = 1.5;
event.target.parent.addChild(event.target); //makes the current card go in front of the rest
}

private function rollAway(event:MouseEvent):void
{
this.scaleX = 1;
this.scaleY = 1;
swapChildrenAt(0, 1);
}




But the roll away function makes the text on the card swap depths with the background of that card. I get what is happening I'm just not sure how to fix it.

Thanks for your help


Return to posts index

Brodd Nesset
Re: AS3 - swapDepths work around
on Sep 10, 2010 at 10:38:52 am

Hi! I think you may be adressing the wrong container in the Roll Away-function. When elements inside the card (i.e. the text, and bg graphics I assume) change places instead of the card itself, this may be the cause. Instead you must target the parent: it's the parent's children ('the cards in the deck') you want to swap - no? - not it's children's children ('the elements of that card').

I don't guarantee this is the solution, but I hope this helps you solving it.

B



Not everything that can be counted counts, and not everything that counts can be counted.



Return to posts index

Victoria Poole
Re: AS3 - swapDepths work around
on Sep 10, 2010 at 3:03:21 pm

Hi!Yes! I got it. I just added 'parent.' in front of 'swapChildrenAt'

Thank you so much for responding!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]