创建Flash SharedObject(Flash Cookie)
//create SO var mySharedObject:SharedObject = SharedObject.getLocal("republicofcode"); mySharedObject.data.firstName = "John"; mySharedObject.data.lastName = "Doe"; mySharedObject.flush(); //Read SO var mySharedObject:SharedObject = SharedObject.getLocal("republicofcode"); trace(mySharedObject.data.firstName); trace(mySharedObject.data.lastName); //Delete SO var mySharedObject:SharedObject = SharedObject.getLocal("republicofcode"); mySharedObject.clear(); //example for SO where it stored a X & Y coordinates of a movie //////////////////////////////////////////////////////////////// var mySO:SharedObject = SharedObject.getLocal("republicofcode"); movie_mc.x = mySO.data.my_x; movie_mc.y = mySO.data.my_y; if (!mySO.data.my_y) { movie_mc.x = 150; movie_mc.y = 100; } movie_mc.addEventListener (MouseEvent.MOUSE_DOWN, onDown); function onDown (e:MouseEvent):void { var my_mc = e.target; my_mc.startDrag (); } movie.addEventListener (MouseEvent.MOUSE_UP, onUP); function onUP (e:MouseEvent):void { logo_mc.stopDrag (); mySO.data.my_x = movie_mc.x; mySO.data.my_y = movie_mc.y; mySO.flush (); } movie_mc.buttonMode=true;