465 posts
  • Bought between 100 and 499 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 100 000 and 250 000 dollars
  • United States
CurtyCurt says

Hey guys, I’ve been using bulkloader for a while now and love it, Im probably gonna switch over to the new GS one soon but not today. Anyone know how to load multiple instances of the same swf on a page. I have a swf that is heavily XML editable and want to show multiple occurrences of the same swf on a page. Anyone done this before?

561 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Bought between 10 and 49 items
  • Contributed a Blog Post
  • Exclusive Author
  • Germany
  • Has been a member for 5-6 years
+1 more
radykal says

Yes, change!!

But you can do something like that. Create multiple add methods for the bulkloader instance with different keys:

//load all assets
var bulkLoader:BulkLoader = new BulkLoader();
bulkLoader.add("mainSwf.swf", {id:"swf1"});
bulkLoader.add("mainSwf.swf", {id:"swf2"});
bulkLoader.add("mainSwf.swf", {id:"swf3"});
bulkLoader.addEventListener(BulkProgressEvent.COMPLETE, assetsLoaded);
bulkLoader.start();

 function assetsLoaded(evt:BulkProgressEvent):void
{
//save each swf in a separate variable
var swf1:Movieclip = bulkLoader.getMovieClip("swf1");
var swf2:Movieclip = bulkLoader.getMovieClip("swf2");
var swf3:Movieclip = bulkLoader.getMovieClip("swf3");
}

I think this should work, but no guarantee. I dont test it. Let me know.

111 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 1 000 and 5 000 dollars
  • Taiwan
savorks says
pack whole extend swf into a Class and
loaderInfo.applicationDomain.getDefinition(className);

?

or maybe create multiple LoadingItem load same url but assign different id ( working like create multiple Loader load same URL , their content will be different instance ), but I think this will waste lots memory compare to the extract Class method.

EDIT . Oops one minute slower :S

465 posts
  • Bought between 100 and 499 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 100 000 and 250 000 dollars
  • United States
CurtyCurt says

Thanks guys!

@radykal that works and may be the solution I will use, only drawback is when I trace(event.bytesTotalCurrent); It actually loads the same swf twice instead of realizing its already been loaded

@savorks have no idea how to use the extract Class method, but that definitely is best way to do it for efficiency.

561 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Bought between 10 and 49 items
  • Contributed a Blog Post
  • Exclusive Author
  • Germany
  • Has been a member for 5-6 years
+1 more
radykal says

Yes, how get each flash movie the path of the xml file?

111 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 1 000 and 5 000 dollars
  • Taiwan
savorks says
This will get Class from a loaded MovieClip which loaded by BulkLoader.
var fileId:String = 'ExtendSwfFileId';
var className:String = 'ClassNameInExtendSwf';

var movieClip:MovieClip = bulkLoader.getMovieClip(fileId);
try
{
  var AClass:Class = Class(movieClip.loaderInfo.applicationDomain.getDefinition(className));
}
catch (er:Error)
{
  throw new Error('Can not find definition ' + className + ' from asset (id = ' + id + ' ).');
}

var newInstance:* = new AClass();

Hope it helps :)

465 posts
  • Bought between 100 and 499 items
  • Elite Author
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
  • Sold between 100 000 and 250 000 dollars
  • United States
CurtyCurt says

@savorks wow! wasn’t expecting that. Perfect solution, thanks so much!

111 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Sold between 1 000 and 5 000 dollars
  • Taiwan
savorks says

No problem mate :)

And for additional trick, if extend SWF have document class(in Flash IDE , just provide document class name, .as file isn’t necessary), you can use that class name for getting whole SWF ’s class definition.

I was hoping we can use “MainTimeline” (default constructor name of main timeline) for getting definition through a swf which doesn’t have document class, but can’t :S, maybe there is some others way to do it.

by
by
by
by
by
by