mercredi 25 novembre 2015

AS3 - set mcs to current label

I've got 3 dolls : sitting, jumping, and running. & I have dresses. All of my dresses models are designed in 3 positions : sitting, jumping & running.

  • dolls_btns contains 3 btns to choose the doll, who starts with undies, their name are : sitting_with_undies, jumping_with_undies, running_with_undies.
    (Undies are removed when a dress is applied).

  • dolls_mc contains :
    on frame 1 : nothing
    on frame 2 : sitting_with_undies, // label : sitting_with_undies
    on Frame 3 : sitting_naked, // label : sitting_naked
    on frame 4 : jumping_with_undies, // label : jumping_with_undies
    on frame 5 : jumping_naked, // label : jumping_naked
    on frame 6 : running_with_undies, // label : running_with_undies
    on frame 7: running_naked // label : running_naked

    • dresses_btns contains buttons which allow to choose the color of the dress

    • dresses_for_sitting contains:
      on frame 1: empty frame,
      on frame 2: 1 pink dress // label : pink_dress
      on frame 3: 1 red dress // label : red_dress
      on frame 4 : 1 green dress // label : green_dress
      and more dresses

    • dresses_for_jumping contains:
      on frame 1: empty frame,
      on frame 2: 1 pink dress // label : pink_dress
      on frame 3: 1 red dress // label : red_dress
      on frame 4 : 1 green dress // label : green_dress
      and more dresses

    • dresses_for_running contains:
      on frame 1: empty frame,
      on frame 2: 1 pink dress // label : pink_dress
      on frame 3: 1 red dress // label : red_dress
      on frame 4 : 1 green dress // label : green_dress
      and more dresses

Lets say I choose the sitting doll & then apply her a pink dress.
Next, if i click on dresses_btns.green_dress, as the doll is already set to sitting, the green sitting-shaped dress will come up. I can apply any other dress color, by clicking on my dresses_btns, as the position is set. // ok

But now if i click on running, the sitting-shaped dress doesn't disappear, as clicking on a doll only switches between dolls positions, but doesn't apply the correct shaped-dress.

So what i'm lookig for is :
1) I choose the sitting position & 2) apply it a pink dress. // ok, done
3) Then, when clicking on jumping > I want to remove the sitting pink dress, & replace it by jumping pink dress .


As I have many dresses, many positions, many hair styles, & clothes, & accessories, I need an easy way to manage all of my items, according to the last clicked position.

// here we are in dolls_btns

var myDolls = [sitting_with_undies, jumping_with_undies, running_with_undies];

for each ( var doll in myDolls)
{
    doll.addEventListener(MouseEvent.CLICK, onPositionClick);
    doll.buttonMode=true;
 }

function onPositionClick(e:MouseEvent):void
{ 
   MovieClip(parent).dolls_mc.gotoAndStop(e.target.name); // places the chosen doll's position on stage

if ( e.target == myDolls[2]  )  /// lets say I've clicked on running
     { 
         // what I'm trying to achieve : 
    if (  MovieClip(parent).dresses_for_sitting.currentLabel=="pink_dress")
       {  MovieClip(parent).dresses_for_sitting.gotoAndStop(1) // empty frame
          MovieClip(parent).dresses_for_running.gotoAndStop("pink_dress");    
          // That works, but I'd like to use dresses_for_sitting.currentLabel instead of naming each label one by one, as I have too many cases, clothes, hair colors, & hair styles, accessories, etc
       }
   } 
}

I've been searching the web for over 12 hours & tryied many solutions, in vain. I think currentLabel should do the trick but I lack of knowledge to complete my functions.

Anticipate thanks

Aucun commentaire:

Enregistrer un commentaire