troubleshooting Question

Help creating a flash preloader

Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland asked on
Adobe Flash
4 Comments1 Solution255 ViewsLast Modified:
Hi all,

we are trying to create a preloader for a flash banner on our site it is a large animations as it consists of a video embedded in it).

so we want to create a preloader to give the user some indication of how the download;

i found a skeleton preloader project. however it doesn't seem to be working?? we are using flash cs4.

it seems to fall over here;

      removeChild(myPreloader);

with the error

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/removeChild()
      at preloader_complete_fla::MainTimeline/showContent()[preloader_complete_fla.MainTimeline::frame1:25]
Cannot display source code at this location.

any ideas whats going on?
var myRequest:URLRequest = new URLRequest("flash_we_are_loading.swf");
var myLoader:Loader = new Loader();

myLoader.load(myRequest);

myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);

var myPreloader:Preloader = new Preloader();

function showPreloader(event:Event):void {
	addChild(myPreloader);
	myPreloader.x = stage.stageWidth/2;
	myPreloader.y = stage.stageHeight/2;
}

function showProgress(event:ProgressEvent):void {
	var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
	myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
	myPreloader.bar_mc.width = 198 * percentLoaded;
}

function showContent(event:Event):void {
	removeChild(myPreloader);
	addChild(myLoader);
}

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros