//Variable Declarations var flag:Boolean=true; var part_name:Array=new Array(); //Storing the original dimensions of the Avatar movie clip. old_width=Avatar._width; old_height=Avatar._height; //============================================================= //Function to Reset the avatar //============================================================= function resetavatar() { //Set the flag to false so that the function doesn't get called repeatedly flag=false; //Default Background : Bg1 Avatar.attachMovie('Bg1_MC','Bg1_MC',0); part_name[0]='Bg1_MC'; //Default Eyes : Eyes1 Avatar.attachMovie('Eyes1_MC','Eyes1_MC',1); part_name[1]='Eyes1_MC'; //Default Avatar/Body : Avatar1 Avatar.attachMovie('Avatar1_MC','Avatar1_MC',2); part_name[2]='Avatar1_MC'; //Default Lips : Lips1 Avatar.attachMovie('Lips1_MC','Lips1_MC',3); part_name[3]='Lips_MC'; //Default Hair : Hair1 Avatar.attachMovie('Hair1_MC','Hair1_MC',4); part_name[4]='Hair1_MC'; //Default Attire : Attire1 Avatar.attachMovie('Attire1_MC','Attire1_MC',5); part_name[5]='Attire1_MC'; //Resizing the default addons Avatar.Bg1_MC._width = old_width; Avatar.Bg1_MC._height = old_height; Avatar.Eyes1_MC._width = old_width; Avatar.Eyes1_MC._height = old_height; Avatar.Avatar1_MC._width = old_width; Avatar.Avatar1_MC._height = old_height; Avatar.Lips1_MC._width = old_width; Avatar.Lips1_MC._height = old_height; Avatar.Hair1_MC._width = old_width; Avatar.Hair1_MC._height = old_height; Avatar.Attire1_MC._width = old_width; Avatar.Attire1_MC._height = old_height; } //============================================================= /*============================================================= Event Handler's for each set of buttons. Each category would have an array of buttons. A loop goes till the number of buttons*/ //part_no is the body_part no. /* 0: Bg 1: Eyes 2: Avatar 3: Lips 4: Hair 5: Attire */ function handleclip(id:String,part_no:Number,depth:Number) { Avatar[part_name[part_no]].removeMovieClip(); Avatar.attachMovie(id,id,depth); part_name[part_no]=id; //Storing the current part_no value Avatar[part_name[part_no]]._Height=old_height; Avatar[part_name[part_no]]._Width=old_width; } //================================================================= //Calling the reset function IFF flag=true if (flag) { resetavatar(); }