Jump to content


Going from Loader to LoaderMax

Recommended Posts

I am trying to switch over to LoaderMax because of all the added features, but I can't seem to convert my old Loader code to what LoaderMax needs. Here's my old code:

import flash.display.Loader;

[Embed(source="localBA.ba", mimeType="application/octet-stream")]
var BAClass:Class;
var BA:ByteArray = new BAClass as ByteArray;

var loader:Loader = new Loader();

var mySprite:Sprite;
function loaded(evt:Event):void {
  mySprite = loader.getChildAt(0) as Sprite;

And my new code:

var dataLoader:DataLoader = new DataLoader("localBA.ba",name:"localBA",format:"binary",estimatedBytes:10000,onComplete:dataLoaded});
var mySprite:Sprite;
function dataLoaded(evt:LoaderEvent):void {
  var BA:ByteArray = LoaderMax.getContent("D20BA");
  mySprite = BA as Sprite; //mySprite apparently is null

Any ideas about what I'm doing wrong? What is the DataLoader version of loadBytes?


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.