Need help with a mod I wrote (1 Viewer)

Zalord

Content Creator
Joined
Jun 12, 2013
Hi there.

I'm have a small problem with a mod that I've written. What my mod does is select a random background from a folder named "bgs" and applies it to the character. It's a pretty simple thing, but it's my first ever AS3 project which means I screwed up somewhere.

It works... for the most part. It does select a random background, but the message "Mod Loading Failed" still pops up in the top right corner. I am pretty sure that this is because I don't have a unloadMod() statement in the code. Whenever I put it in there, the error goes away but none of the backgrounds load.

I've attached a working character folder with the mod in it, including the .as file and the as3->swf compiler. A sample bgs folder is also included.

Can someone take a look at it and tell me what I'm doing wrong? Thanks.
 

Attachments

BGLoader.zip
1.9 MB · Views: 71

ModGuy

Content Creator
Joined
Feb 17, 2011
Use modSettingsLoader/modDataLoader instead of URLLoader to get files from the same directory, you pass in cData. More info in the dev guide.
It's almost always a bad idea to utilise loading objects from within the loader such as obgLdr, consider implementing your own version if you get it working.
It's good practice to avoid nested functions, use anonymous functions if you must.
 

Zalord

Content Creator
Joined
Jun 12, 2013
I have another version which uses modSettingsLoader. I switched over to URLLoader so that bgs.txt would be simpler to use. This is what I had to use for that other version:

bgs=3
bg1=bgs/bg1.png
bg2=bgs/bg2.png
bg3=bgs/bg3.png

Where with the version I posted, it's just:

bg1.png
bg2.png
bg3.png


I'm glad you brought up obgLdr. That line was pretty much ripped straight from Mods/DevExamples/Data Examples/ModDataLoader/Mod.as in the loader package. I tried finding where obgLoader came from in the decompiled loader that sby posted somwhere, but couldn't find it. So what should I be using to load in a background?

And is there a way I could use MSL/MDL to read from the text file in the way that I mentioned?

Thanks.

EDIT: I've attached that other version which uses MSL. It's pretty much the ModDataLoader example that I've gutted into something that works, even though I don't know how. This one actually doesn't have the "Mod Loading Failed" problem.
 

Attachments

Mod.as
1.6 KB · Views: 77

ModGuy

Content Creator
Joined
Feb 17, 2011
Sure.
Code:
package flash
{
	import flash.display.Loader;
	public dynamic class Main extends flash.display.MovieClip
	{
		private var mdl;
		public var cData;
		public var modDataLoader:Class;
		public function initl(l)
		{
			mdl = new modDataLoader("bgs/bgs.txt", cData ,dataLoaded);
			mdl.addEventListener("dataNotFound",noDataFound);
		}
		function noDataFound(e){
			e.loader.unloadMod();		
		}
		function dataLoaded(e)
		{
			var bgs = e.loader.standardLines(e.binData.toString());
			var randint:int = int(Math.random() * bgs.length);
			mdl = new modDataLoader("bgs/" + bgs[randint], cData, bgLoaded);
			mdl.addEventListener("dataNotFound",noDataFound);
		}
		function bgLoaded(e){
			var obgLdr = new Loader();
			obgLdr.contentLoaderInfo.addEventListener("complete",e.loader.onOBG);
			obgLdr.loadBytes(e.binData);
			e.loader.unloadMod();
		}
	}
}
 

Zalord

Content Creator
Joined
Jun 12, 2013
Wow, that works. Where can I find the ModDataLoader source code? I was searching for it yesterday and couldn't find it.

I feel like I need to add more to it now that you've pretty much written the whole thing. There are a few other things I want to try out with it before I post it to the Loader Imports forum, but this was the biggest thing.

Thanks a bunch!
 

Users who are viewing this thread

Top


Are you 18 or older?

This website requires you to be 18 years of age or older. Please verify your age to view the content, or click Exit to leave.