Thursday, May 7, 2009

level lock code in AS3

write this code in 1st frame
/////////////////////////
var unLock:*;


var my_so:SharedObject = SharedObject.getLocal("store4");





if (my_so.size == 0) {

unLock = Level
;

} else {

unLock=my_so.data.UNLOCK





;
}


//////////////////////////////////
make movieclips (to show all levels)
//////
L1.buttonMode = true;//// its open
L1.addEventListener(MouseEvent.CLICK,LevelPlay);


function LevelPlay(e:Event) {
gotoAndStop("play");
distance_joint1();
Level=1

;
}
//////////////////



L2.addEventListener(MouseEvent.CLICK,LevelPlay1);///its closed


function LevelPlay1(e:Event) {

if(L2.buttonMode==true)
{
gotoAndStop("play");
distance_joint1();
Level=2
}

;
}

//////////

/// this is the code for making button visible and non visible
for( var i=1;i<=unLock;i++)
{
this["L"+i].buttonMode=true//mouseEnabled=true//alpha=0//buttonMode=true
//trace(this["L"+i])



}


//////////////////////////////////////

finaly in UPdate fucntion() pass the data and store it like this

//////////////////
my_so.data.UNLOCK=Level



my_so.flush()
my_so.close()

////////////////////////////////////////
its done :)

No comments:

FEEDJIT Live