Jump to content
Sign in to follow this  
Guest Sandor

Making Useful AS3 Dependencies

Recommended Posts

Hey y'all!

 

So we've had dependencies for a little while now, a la Arthur. And they worked absolutely fantastic for receiving packets and the like. Well with a little bit of research, I've discovered a way to access dependencies from anywhere in the game, much like you would the interface, offering leaps and bounds of new possibilities.

 

Here's the basics of it:

When you start playing, the shell/interface/engine is loaded less than a second in, if that. And the path to the shell is generated as follows:

_level0.instanceu.world.world.instancev.instancex.instancey.instancez.shellContainer

Where u, v, x, y, and z are (fairly) randomly generated whole numbers. Yes, there is a method to that madness, but it's not important.

 

And in any SWF loaded into the game, this same path is accessed through _global.getCurrentShell(); That's important.

 

But let's take it a step further. At what path is a dependency loaded? Well, it's generated as follows:

_level0.instanceu.world.world.instancev.instancex.instancey.instancez.shellContainer.dependencyHolder.dependency_name

Where u, v, x, y, and z have the same values as before, and dependency_name is the ID of the dependency you are trying to access.

 

Now let's stitch it all together:

 

To Access A Dependency from Any SWF, Use the Following Code:

//in this example, the dependency is called "cpps". Replace for each additional dependency you use.
var SHELL = _global.getCurrentShell();
var DEPENDENCY_HOLDER = SHELL.dependencyHolder;
var CPPS = DEPENDENCY_HOLDER.cpps;
//I know these variables seem unnecessary, as you could do it all in one shot, but this makes it easier to access multiple.
//Example Function Calling:
CPPS.doSomething();

For each additional dependency holder, you just have to repeat the last variable, not the first two.

 

So that's it! Now that you can call functions from SWF to SWF, there's LOADS of opportunities for different creates, like:

  • An additional HUD for your CPPS
  • More efficient announcements or video players
  • A "game settings" swf. Like an easier one, that doesn't require the engine or shell. All you'd need is lots of variables and booleans. You could publish quickly and update without having to use game_configs.
  • And so many more!

I hope that this helps y'all create some cool new dependencies!

 

Yours truly,

-Sandor

 

PS: Thanks to Jad for using his localhost to trace the dependency and shell paths, as I was unable to.

 

Disclaimer: I'm yet to test this, but it should 100% work because there's not really a margin for error.

Share this post


Link to post
Share on other sites

Please note that the 'cpps.swf' should have this format in the dependencies:

	{
			"id": "cpps",
			"title": "testtt"
		},

Going deeper, the dependency holder calls a swf according to id, not title.

Share this post


Link to post
Share on other sites

One more thing, it seems that instaceu is actually instance7 set as default. It doesn't change.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×