A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: button controlling two movieclips, not working so well

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    12

    button controlling two movieclips, not working so well

    Okay, it's a bit complicated to explain my problem but I'll try!
    I made a dress-up game (well a got a lot of help with the coding), a while ago.
    And now I want to have the option to change skintones. That's not a problem in it self, I just made two buttons that control the skin-MC. But the problem is that I also have the option to change her feet, from standing on her toes or not. And when I now for example have chosen the dark skin color, and then change the feet to standing on her toes, the skin color of the feet turns to the light skin color.
    I don't think it's so difficult to fix, I suppose I have to tell the feet-buttons that "if the skin-color is on
    skin1, go to feet1" or something like that, I just can't figure out the code.

    I just can't get the file size below 300k, since it's not in vector. And you kind of have to see the girl and the feet to get my problem.. But it's only 390k and you can download it here from my server:
    http://www.annagrape.se/style-small.fla

    I would be sooo grateful if anyone will help me!

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

    I took a look at your file, this will help you, although I am not sure how it will effect the other items as they were not in the file, replace all of your code on the timeline with this
    PHP Code:
    var marginal 70;

    var 
    skinType "1";// added to name skin type from start - 1 for white, 2 for dark

    dra = function ()
    {
        
    this.startDrag(false);
        
    this.swapDepths(_root.getNextHighestDepth());
    };

    slapp = function ()
    {
        
    this.stopDrag();
        if (
    this._x > -marginal && this._x marginal && this._y > -marginal && this._y marginal)
        {
            
    trace("snap");
            
    this._x 0;
            
    this._y 0;
        }
        else
        {
            
    trace("no snap");
        }
    };

    var 
    hairPlagg:Array = new Array();
    var 
    skirtsPlagg:Array = new Array();
    var 
    dressesPlagg:Array = new Array();
    var 
    bottomsPlagg:Array = new Array();
    var 
    topsPlagg:Array = new Array();
    var 
    accessoriesPlagg:Array = new Array();
    var 
    shoesPlagg:Array = new Array();
    var 
    costumesPlagg:Array = new Array();

    costumesPlagg.push(cos1);
    costumesPlagg.push(cos2);
    costumesPlagg.push(cos3);
    costumesPlagg.push(cos4);

    shoesPlagg.push(shoes1);
    shoesPlagg.push(shoes2);
    shoesPlagg.push(shoes3);
    shoesPlagg.push(shoes4);

    hairPlagg.push(hair1);
    hairPlagg.push(hair2);
    hairPlagg.push(hair3);
    hairPlagg.push(hair4);

    skirtsPlagg.push(skirt1);
    skirtsPlagg.push(skirt2);
    skirtsPlagg.push(skirt3);
    skirtsPlagg.push(skirt4);

    dressesPlagg.push(dress1);
    dressesPlagg.push(dress2);
    dressesPlagg.push(dress3);
    dressesPlagg.push(dress4);

    bottomsPlagg.push(bottom1);
    bottomsPlagg.push(bottom2);
    bottomsPlagg.push(bottom3);
    bottomsPlagg.push(bottom4);

    topsPlagg.push(top1);
    topsPlagg.push(top2);
    topsPlagg.push(top3);
    topsPlagg.push(top4);

    accessoriesPlagg.push(acc1);
    accessoriesPlagg.push(acc2);
    accessoriesPlagg.push(acc3);
    accessoriesPlagg.push(acc4);

    for (
    0shoesPlagg.lengthi++)
    {
        
    shoesPlagg[i].onPress dra;
        
    shoesPlagg[i].onRelease slapp;
        
    shoesPlagg[i].onReleaseOutside slapp;
    }

    for (
    0hairPlagg.lengthi++)
    {
        
    hairPlagg[i].onPress dra;
        
    hairPlagg[i].onRelease slapp;
        
    hairPlagg[i].onReleaseOutside slapp;
    }

    for (
    0skirtsPlagg.lengthi++)
    {
        
    skirtsPlagg[i].onPress dra;
        
    skirtsPlagg[i].onRelease slapp;
        
    skirtsPlagg[i].onReleaseOutside slapp;
    }

    for (
    0dressesPlagg.lengthi++)
    {
        
    dressesPlagg[i].onPress dra;
        
    dressesPlagg[i].onRelease slapp;
        
    dressesPlagg[i].onReleaseOutside slapp;
    }

    for (
    0bottomsPlagg.lengthi++)
    {
        
    bottomsPlagg[i].onPress dra;
        
    bottomsPlagg[i].onRelease slapp;
        
    bottomsPlagg[i].onReleaseOutside slapp;
    }

    for (
    0topsPlagg.lengthi++)
    {
        
    topsPlagg[i].onPress dra;
        
    topsPlagg[i].onRelease slapp;
        
    topsPlagg[i].onReleaseOutside slapp;
    }

    for (
    0accessoriesPlagg.lengthi++)
    {
        
    accessoriesPlagg[i].onPress dra;
        
    accessoriesPlagg[i].onRelease slapp;
        
    accessoriesPlagg[i].onReleaseOutside slapp;
    }

    for (
    0costumesPlagg.lengthi++)
    {
        
    costumesPlagg[i].onPress dra;
        
    costumesPlagg[i].onRelease slapp;
        
    costumesPlagg[i].onReleaseOutside slapp;
    }

    visaGarderob = function (vilken)
    {
        if (
    shoesPlagg[i]._x != && shoesPlagg[i]._y != 0)
        {
            
    shoesPlagg[i]._visible false;
        }
    };
    for (
    0hairPlagg.lengthi++)
    {
        if (
    hairPlagg[i]._x != && hairPlagg[i]._y != 0)
        {
            
    hairPlagg[i]._visible false;
        }
    }

    for (
    0skirtsPlagg.lengthi++)
    {
        if (
    skirtsPlagg[i]._x != && skirtsPlagg[i]._y != 0)
        {
            
    skirtsPlagg[i]._visible false;
        }
    }

    for (
    0dressesPlagg.lengthi++)
    {
        if (
    dressesPlagg[i]._x != && dressesPlagg[i]._y != 0)
        {
            
    dressesPlagg[i]._visible false;
        }
    }

    for (
    0bottomsPlagg.lengthi++)
    {
        if (
    bottomsPlagg[i]._x != && bottomsPlagg[i]._y != 0)
        {
            
    bottomsPlagg[i]._visible false;
        }
    }

    for (
    0topsPlagg.lengthi++)
    {
        if (
    topsPlagg[i]._x != && topsPlagg[i]._y != 0)
        {
            
    topsPlagg[i]._visible false;
        }
    }

    for (
    0accessoriesPlagg.lengthi++)
    {
        if (
    accessoriesPlagg[i]._x != && accessoriesPlagg[i]._y != 0)
        {
            
    accessoriesPlagg[i]._visible false;
        }
    }

    for (
    0costumesPlagg.lengthi++)
    {
        if (
    costumesPlagg[i]._x != && costumesPlagg[i]._y != 0)
        {
            
    costumesPlagg[i]._visible false;
        }
    }

    for (
    0vilken.lengthi++)
    {
        
    vilken[i]._visible true;
    }

    //}

    btn_shoes.onPress = function()
    {
        
    visaGarderob(shoesPlagg);
    };

    btn_hair.onPress = function()
    {
        
    visaGarderob(hairPlagg);
    };

    btn_skirts.onPress = function()
    {
        
    visaGarderob(skirtsPlagg);
    };

    btn_dresses.onPress = function()
    {
        
    visaGarderob(dressesPlagg);
    };

    btn_bottoms.onPress = function()
    {
        
    visaGarderob(bottomsPlagg);
    };

    btn_tops.onPress = function()
    {
        
    visaGarderob(topsPlagg);
    };

    btn_accessories.onPress = function()
    {
        
    visaGarderob(accessoriesPlagg);
    };

    btn_costumes.onPress = function()
    {
        
    visaGarderob(costumesPlagg);
    };

    //make-up

    btn_mun1.onPress = function()
    {
        
    _root.munnar.gotoAndPlay("mun1");
    };

    btn_mun2.onPress = function()
    {
        
    _root.munnar.gotoAndPlay("mun2");
    };

    btn_mun3.onPress = function()
    {
        
    _root.munnar.gotoAndPlay("mun3");
    };

    btn_mun4.onPress = function()
    {
        
    _root.munnar.gotoAndPlay("mun4");
    };

    btn_eye1.onPress = function()
    {
        
    _root.eyes.gotoAndPlay("eye1");
    };

    btn_eye2.onPress = function()
    {
        
    _root.eyes.gotoAndPlay("eye2");
    };

    btn_eye3.onPress = function()
    {
        
    _root.eyes.gotoAndPlay("eye3");
    };

    btn_eye4.onPress = function()
    {
        
    _root.eyes.gotoAndPlay("eye4");
    };

    //feet

    btn_heels.onPress = function()
    {
        
    _root.feet.gotoAndPlay("heels");
        
    // *** added
        
    if (skinType == "1")
        {
            
    _root.feet.heels.gotoAndPlay("heels1");
        }
        else
        {
            
    _root.feet.heels.gotoAndPlay("heels2");
        }
        
    // *** end added
        
    _root.bottom3.gotoAndPlay("flat");
        
    _root.bottom4.gotoAndPlay("flat");
        
    _root.bottom5.gotoAndPlay("flat");
        
    _root.bottom6.gotoAndPlay("flat");
        
    _root.bottom19.gotoAndPlay("flat");
    };

    btn_toes.onPress = function()
    {
        
    _root.feet.gotoAndPlay("toes");
        
    // *** added
        
    if (skinType == "1")
        {
            
    _root.feet.toes.gotoAndPlay("toes1");
        }
        else
        {
            
    _root.feet.toes.gotoAndPlay("toes2");
        }
        
    // *** end added
        
    _root.bottom3.gotoAndPlay("toes");
        
    _root.bottom4.gotoAndPlay("toes");
        
    _root.bottom5.gotoAndPlay("toes");
        
    _root.bottom6.gotoAndPlay("toes");
        
    _root.bottom19.gotoAndPlay("toes");
    };

    //skin

    btn_skin1.onPress = function()
    {
        
    skinType "1";// added
        
    _root.skin.gotoAndPlay("skin1");
        
    _root.feet.toes.gotoAndPlay("toes1");
        
    _root.feet.heels.gotoAndPlay("heels1");
    };

    btn_skin2.onPress = function()
    {
        
    skinType "2";// added
        
    _root.skin.gotoAndPlay("skin2");
        
    _root.feet.toes.gotoAndPlay("toes2");
        
    _root.feet.heels.gotoAndPlay("heels2");
    };

    visaGarderob(shoesPlagg); 
    I have commented the bits i added
    the flat dark feet were missing from the file too

    hope it sorts your problem for you

    my hobby
    Last edited by fruitbeard; 04-11-2013 at 08:53 AM.

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    oh my god. Thank you SO MUCH! This is exactly what I wanted, it's so annoying when I know what needs to be done but just don't know the code. At least I learn stuff as I go along
    I tried it in my file with all the stuff in it, and it works perfectly!

    thank you again and again!

  4. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    Oh I forgot to ask. Will this work if I add more skin colors?
    Can I just add
    Code:
    else
        {
            _root.feet.heels.gotoAndPlay("heels3");
        }
    for example, or will that mess everything up?
    Now it's skin1, else skin2 but i suppose it won't work with if else, else right?
    sorry for being such a newbie.. hehe

  5. #5
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    oh nevermind, I actually figured it out by myself. else if! wohoo

Tags for this Thread

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