A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: button controlling two movieclips, not working so well

Threaded View

  1. #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.

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