PDA

View Full Version : Loaded SWF Background dissappears on load!



zerobars
March 25th, 2008, 08:51 PM
I'm loading a SWF into my movie -- using code below. The only thing is that if I have a SWF that has a colored background, and content above that, on loading the background of the imported SWF comes through as _transparent_ (i.e. the color doesn't show) and only the objects _in_ the imported SWF show up --

Why would this be? How to fix? (I can add a colored rectangle that takes up whole stage -- that works OK, but wonder why actual background doesn't show)

Thanks!



public function loadContent(url:String):void {
var request:URLRequest = new URLRequest(url);
var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loadComplete);
loader.load(request);
addChild(loader);
}
function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace("Loading: "+percentLoaded+"%");
} function loadComplete(event:Event):void {
trace("Complete");
}

icio
March 25th, 2008, 11:42 PM
The background colour of a flash movie is in the stage, as opposed to the root. The problem you are experiencing is an example of there only being one stage but possibly multiple root (one for each you load.)

If you want to set a background colour draw a rectangle behind everything else in the SWF you're loading in.

zerobars
March 26th, 2008, 12:03 PM
Thanks. That solution was one I hit on last night, and works, but I didn't understand why…

icio
March 26th, 2008, 12:17 PM
Because


The background colour of a flash movie is in the stage, as opposed to the root. The problem you are experiencing is an example of there only being one stage but possibly multiple root (one for each you load.)


You can read up on this stuff in the ActionScript 3 documentation.
:thumb: