A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Set several mcs at currentLabel

  1. #1
    Junior Member
    Join Date
    Nov 2015
    Posts
    3

    Set several mcs at currentLabel

    Hi there!


    Lets' say you've got 5 buttons, each triggering his own mc
    button1 makes mc1 visible
    button2 makes mc2 visible

    What I'm trying to achieve is : if user clicks on button n°4 > set mcs 1,2,3,5 at the same currentLabel, knowing that each mc contains 30 labels, which frame label is set through other buttons.
    I'm working on a dressup game. > First the user chooses a position for the doll (5 positions available), then she chooses a dress (mc containing 30 dresses = 30 labels).
    But if user selects another position, I need to remove the current dress, and apply the dress that fits the new position...

    I've been searching the web & trying for over 10 hours, without success,
    so many thanks for your kind help.

    Code:
    var myPositions = [position1_default, position2_default, position3_default, position4_default, position5_default];
    
    for each ( var pose in myPositions)
    {
    	pose.addEventListener(MouseEvent.CLICK, onPositionClick);
    	pose.buttonMode=true;
    }
    
    function onPositionClick(e:MouseEvent):void
    { 
       MovieClip(parent).positions_mc.gotoAndStop(e.target.name); // sets the doll's position
    
      if ( e.target == myPositions[i]  )  
        { 
         // what I'm trying to achieve : 
            if (  MovieClip(parent).myDresses_PreviousPosition.currentLabel=="currentDressLabel")
    	   {  MovieClip(parent).myDresses_PreviousPosition.gotoAndStop(1);	// empty frame to remove the dress that fits the last doll's position	     
    	      MovieClip(parent).myDresses_NewPosition.gotoAndStop("currentDressLabel");    
    	   }
       } 
    }
    I've been testing many functions in vain...
    Thanks for your help !!!

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I would need to see your file as I'm not sure what you are really asking for.

  3. #3
    Junior Member
    Join Date
    Nov 2015
    Posts
    3
    Thanks for your interest :
    I'm gonna try to make it easy to understand, & to do so, below you'll find my code modified to make it easier to read.

    lets say
    * animals_mc contains a bear, a rabbit, and a giraffe.

    * dresses_mc contains:
    on frame 1: empty frame,
    on frame 2: 1 pink dress shaped for the giraffe, // label : pink_dress_giraffe
    on frame 3: 1 pink dress designed for the rabbit, // label : pink_dress_rabbit
    on frame 4 : 1 pink dress tailored for the bear, // label : pink_dress_bear
    on frame 5 : 1 green dress for the giraffe, // label : green_dress_giraffe
    on frame 6: 1 green dress for the rabbit, // label : green_dress_giraffe
    on frame 7 : 1 green dress for the bear, // label : green_dress_giraffe
    and more dresses for each animal.

    All of my animals start naked.
    I choose the giraffe & apply it a pink dress.
    If i click on the green dress, as the animal is set to giraffe, it the giraffe-shaped dress will come up.
    I can apply any other dress color, by clicking on my dresses_btns, as the target animal is set. // so far so good!

    But now if i click on rabbit, the giraffe-shaped dress won't disappear, as by clicking on animal, it only switches between animals, but doesn't apply the correct dress, until i call dresses_mc & choose a new dress, as a new animal had been set when I clicked on rabbit,

    So what i'm lookig for is :
    I choose the giraffe & apply it a pink dress. // ok, done
    Then, by clicking on rabbit > I want to remove the giraffe pink dress (mc_dresses currentLabel), & replace it by rabbit pink dress .

    ---

    As I have many dresses, many animals, many hair styles, & clothes, & accessories, I need an easy way to manage all of my items, according to the last clicked animal. Looking for the correct loop
    ----


    NEW CODE easy to understand ( I guess & wish so)

    Code:
    // here we are in myAnimals buttons Display.
    
    var myAnimals = [rabbit, bear, giraffe, crocodile];
    
    for each ( var pet in myAnimals)
    {
    	pet.addEventListener(MouseEvent.CLICK, onAnimalClick);
    	pet.buttonMode=true;
    }
    
    function onAnimalClick(e:MouseEvent):void
    { 
       MovieClip(parent).animals_mc.gotoAndStop(e.target.name); // places the chosen animal on stage
    
      if ( e.target == myAnimals[3]  )  /// lets say I've clicked on crocodile
        { 
             // what I'm trying to achieve : 
            if (  MovieClip(parent).dresses_mc.currentLabel=="pink_dress_giraffe")
    	  {  MovieClip(parent).dresses_mc.gotoAndStop("pink_dress_crocodile");    // place the crocodile_pink_dress when crocodile is clicked, 
     // I'm looking to use dresses_mc.currentLabel instead of naming each label one by one
    	   }
       } 
    }

    Thanks !!!
    Last edited by Temp06; 11-25-2015 at 09:42 AM.

  4. #4
    Junior Member
    Join Date
    Nov 2015
    Posts
    3
    Why cant' I edit my post ???
    I made a mistake !!! u should read :



    Hi,

    Thanks for your interest :
    I'm gonna try to make it easy to understand, & to do so, I've modified my 1st post to make it easier to read.

    lets say
    * animals_mc contains a bear, a rabbit, a giraffe, a crocodile. I choose the giraffe.

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

    * dresses_for_rabbit_mc contains:
    on frame 2: 1 pink dress rabbit_shaped, // label : pink_dress
    on frame 3: 1 red dress rabbit_shaped, // label : red_dress
    on frame 4 : 1 green dress rabbit_shaped, // label : green_dress
    and more dresses

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



    etc for each animal




    I choose the giraffe & apply it a pink dress.
    If i click on the green dress, as the animal is set to giraffe, it the giraffe-shaped dress will come up.
    I can apply any other dress color, by clicking on my dresses_btns, as the target animal is set. // so far so good!

    But now if i click on rabbit, the giraffe-shaped dress won't disappear, as by clicking on animal, it only switches between animals, but doesn't apply the correct dress, until i click on dresses_mc & choose a new dress, as a new animal had been set when I clicked on rabbit,

    So what i'm lookig for is :
    I choose the giraffe & apply it a pink dress. // ok, done
    Then, by clicking on rabbit > I want to remove the giraffe pink dress (mc_dresses currentLabel), & replace it by rabbit pink dress .

    ---

    As I have many dresses, many animals, many hair styles, & clothes, & accessories, I need an easy way to manage all of my items, according to the last clicked animal. Looking for the correct loop

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You can edit a post within 15 minutes of posting it, after that you can not edit the post (I think it hasn't changed).

    Your extra posts are just making things even more complicated for me (maybe others too), you need to attach your *.fla or make it downloadable.

    There is too much going on to try and emulate your file.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center