I've hacked in a
temporary permanent but rather efficient way to include data in projects, like text files, images and SWF movies. The original intent was just the text file portion.
Instructions1) Create an "extras" folder under your game's folder.
2) Stick the desired files directly into that folder. Subdirectories are supported.
3) In-game, access your data like this:
Update: There is now an extension that does all of the below using blocks. Check it out!
http://community.stencyl.com/index.php/topic,35620.0.html
Text Filesvar s:String = nme.Assets.getText("assets/data/dict.txt");
Images (PNG, JPG, GIF)var img:nme.display.BitmapData = nme.Assets.getBitmapData("assets/data/sample.png");
com.stencyl.Engine.engine.root.addChild(new nme.display.Bitmap(img));
(Alter the second line as you see fit to attach to different targets.)
Movies (SWF)var bytes = nme.Assets.getBytes("assets/data/sample.swf");
var loader:nme.display.Loader = new nme.display.Loader();
loader.loadBytes(bytes);
loader.contentLoaderInfo.addEventListener(nme.events.Event.COMPLETE, function(_) {
com.stencyl.Engine.engine.root.addChild(loader.content);
});
(Variation - This auto-removes the clip after completion)
var bytes = nme.Assets.getBytes("assets/data/sample.swf");
var loader:nme.display.Loader = new nme.display.Loader();
loader.loadBytes(bytes);
loader.contentLoaderInfo.addEventListener(nme.events.Event.COMPLETE, function(_) {
var clip:nme.display.MovieClip = cast(loader.content, nme.display.MovieClip);
clip.addFrameScript(clip.totalFrames - 1,
function():Void {
clip.stop();
com.stencyl.Engine.engine.root.removeChild(clip);
}
);
com.stencyl.Engine.engine.root.addChild(clip);
});
(In local testing, you may get a security error that you have to dismiss each time. Only works on the Flash target. Some movies may not be supported, but this is made pretty clear by the Flash player. NME has a cross-platform SWF loader, but when I tried it, it did not render things correctly.)