I got a client with a GUI for my game and i tried adding when you press a button to open another swf file. So basically after when the button is being pressed to be redirected to the other swf file. Here is the code:
override public function set pressed(param1:Boolean) : void
{
super.pressed = param1;
bitmap.y = !!param1 ? Number(1) : Number(0);
}
And i have tried doing this:
override public function set pressed(param1:Boolean) : void
{
super.pressed = param1;
bitmap.y = !!param1 ? Number(1) : Number(0);
mainLoader = new Loader();
url = new URLRequest("battle/battle.swf");
mainLoader.load(url);
addChild(mainLoader);
}
But it just messes up everything in the client and it doesn't even work...
Ok, I still find your " expected behavior " explanations to be exceedingly confusing, but I assume you want your application to show another SWF just like next page in browser.
function nextSWF(url:String):void
{
// Keep the stage reference because it will be lost
// once everything is detached from the stage,
// and that is exactly what's about to happen.
var aStage:Stage = stage;
var aLoader:Loader = new Loader;
// Remove the current application visuals.
dismantle(aStage);
// Load the new content.
aStage.addchild(aLoader);
aLoader.load(new URLRequest(url));
}
// This method recursively destroys the whole display list
// branch, starting from the given display list node.
function dismantle(target:DisplayObjectContainer):void
{
if (!target) return;
while (target.numChildren)
{
// Get a reference to the topmost display child.
var aChild:DisplayObject = target.getChildAt(target.numChildren - 1);
// Dismantle it as well if it contains things,
// then remove it from the display list.
dismantle(aChild as DisplayObjectContainer);
target.removeChild(aChild);
}
}
Then, you use it in your script as following:
override public function set pressed(param1:Boolean) : void
{
// The remnants of your script, whatever it is.
super.pressed = param1;
bitmap.y = !!param1 ? Number(1) : Number(0);
// Remove the current content and load the next one.
nextSWF("battle/battle.swf");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.