Copy link to clipboard
Copied
I'm trying to load an old project into a new project via swf. My old project had local external swf dependencies.In other words A.swf is the old project swf and it loads in B.swf and C.swf. I want to load A.swf into my new project. All the .swf file are local and will be loaded locally. Using the url and loader to load the old project's swf into the new project, I get an error that says that the stage must not be null. I have put A.swf, B.swf, and C.swf all within the same folder together in the new project. Is the correct approach? I'd like to know if this is even possible and if so how should I do it? Thanks in advance!
Copy link to clipboard
Copied
If the A.swf file is attempting to target the stage and is doing so before it is completely loaded then there is a likelihood of getting a null stage error.
As far as having A.swf loading other swf's, that should not be a problem as long as you target the files appropriately.
Copy link to clipboard
Copied
Could you explain what target the stage means? Sorry I'm relatively new to AS3.
Copy link to clipboard
Copied
Targeting an object is the same for any object... if you add an event listener to a button you target the button...
btnName.addEventListener(etc...);
There might be code targeting the stage in the same manner, such as an event listener just like you might do for a button
stage.addEventListener(etc...);
Copy link to clipboard
Copied
Hmm I don't believe I have targeted the stage. Here's my code below.
package ExergameShell.screens
{
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import feathers.controls.Screen;
import starling.core.Starling;
import starling.events.Event;
public class Leaderboard extends Screen
{
private var url1:URLRequest;
private var loader1:Loader;
public function Leaderboard()
{
addEventListener(starling.events.Event.ADDED_TO_STAGE, init); // necessary for all screens
}
private function init():void
{
url1 = new URLRequest("A.swf");
trace(JSON.stringify(url1));
loader1 = new Loader();
loader1.load(url1);
//Starling.current.nativeStage.addChild(loader1);
//loader1.contentLoaderInfo.addEventListener(starling.events.Event.COMPLETE, resetFPS);
}
private function resetFPS(event:flash.events.Event):void
{
Starling.current.nativeStage.frameRate = 60;
}
}
}
Copy link to clipboard
Copied
The code breaks right before the comments.
Copy link to clipboard
Copied
What is the complete error message?
Copy link to clipboard
Copied
ArgumentError: Stage must not be null
at starling.core::Starling()
at Core::InXLeaderboard()
Copy link to clipboard
Copied
Can someone please help me out?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now