Copy link to clipboard
Copied
I have created an test app for test shared objects.I have three fla,two game and one main fla for call other swf files(external).
Main FLA
import tsiko;
var mypipi:Loader = new Loader(); // create a new instance of the Loader class
var myurl:URLRequest = new URLRequest("game2.swf"); // This is game 2
var mypipi2:Loader = new Loader();
var myurl2:URLRequest = new URLRequest("game1.swf"); //This is game 1 in this case both SWFs are in the same folder
wh3gna.addEventListener(MouseEvent.CLICK, dinsvslov);
function dinsvslov(event:MouseEvent😞void
{
mypipi.load(myurl); // load the Game 2
addChild(mypipi);
}
stage.addEventListener(Event.ENTER_FRAME,bibisa);
function bibisa(oly:Event) {
//if game 2 done than call the game 1 and remove game 2
if(tsiko.sansangelme==true){
mypipi2.load(myurl2); // load the SWF file
addChild(mypipi2);
mypipi.unloadAndStop();
tsiko.sansangelme=false;
}
}
Game 2 save the number.
import tsiko;
import flash.net.SharedObject;
import flash.events.NetStatusEvent;
var mynumber:Number=555;
var bsa4:SharedObject = SharedObject.getLocal("goster");
bsa4.data.tok = mynumber; bsa4.flush();
var flashstatus:String=bsa4.flush();
if(flashstatus !=null){ switch(flashstatus)
{ case SharedObjectFlushStatus.PENDING: trace("waiting")
break;
case SharedObjectFlushStatus.FLUSHED: trace("great saved")
break;
}
}
tsiko.sansangelme=true; // Goto main menu stop();And game 1 for show the shared number but it's not working.
import tsiko;
import Turn;
import flash.net.SharedObject;
import flash.events.NetStatusEvent;
var bsa1:SharedObject = SharedObject.getLocal("goster");
var myno:Number=0;
myno=bsa1.data.csok;
tipo.text = String(myno);
stop();
Game 2 flushed the number perfect but I can't see on the game 1 swf.
I get NaN message.How should I do for display the data on game 2.
each fla has a different sharedobject.
you can create one sharedobject in you main fla and access it from each loaded game fla.
Copy link to clipboard
Copied
each fla has a different sharedobject.
you can create one sharedobject in you main fla and access it from each loaded game fla.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now