Jump to content
Search Community

Load with DataLoader with format:binary, but then use it as a SWFLoader?

Indyaner test
Moderator Tag

Recommended Posts

Hi

 

I have a usecase, where I use DataLoader to load binary Data. This way I'm always able to look into the incoming data like so:

 
queue = new LoaderMax( {
name:"mainQueue",
autoLoad:true
});

[...]

var loader:DataLoader = new DataLoader("example.com/SESSIONSTRING", {
name:someParameter,
format: "binary",
onComplete:dataCompleteHandler
});

queue.append( loader );

[...]

function assetCompleteHandler(e:LoaderEvent):void {
var ba:ByteArray = LoaderMax.getLoader(e.target.name).content as ByteArray;

//Validation here, like checking if it is long enough, if not, are the first 5 Bytes read as a String saying "ERROR" and the server gave an Error back. Or is it long enough, but to short to be sure, so there might be a Warning or PHP Error coming back from the Server, then display te bytearray as a String for me to read "unexpextd error on PHP Line...". I like handling with the raw ByteArray

}
 

 

 

 

This is all great, but I want to be able to then convert the Binary Data into a Movieclip. That does only seem to work when doing so:

var mc:MovieClip = LoaderMax.getLoader(ID).rawContent as MovieClip;

The Problem is, that only SWFLoader has the rawContent accessable. When using DataLoader I only have access to Content but not rawContent.

 

My problem is this generally:

When I use DataLoader, I can scoop into the ByteArray and do all kind of magic, but am not able to create a MC from the loaded Data.

When I use SWFLoader, I can play with the Loaded SWF/MC with easy, but have no Access to the ByteArray.

 

Am I missing something? How can I have both features? Being able to have a accessable SWF and being able to scroop the Data befor allowing it to be injected into my App?

 

 

 

Indy

Link to comment
Share on other sites

Sorry, there is nothing in DataLoader that is going to assist you in converting a ByteArray into a swf. I'm not even sure that is possible or how you would do it. A quick google search isn't very promising.

 

Likewise, SWFLoader is only going to give you access to the rawContent and I'm not optimistic about getting the ByteArray from a loaded DisplayObject.

Link to comment
Share on other sites

Mh, well. Then it has to be that way I guess. I will try to make my PHP Script throw HTTP Errors instead and try to Capture those with the onHTTPStatus. 

Or what would you do? I want to capture Errors from the server that I throw out of knowledge (Like: Request rejected because of a wrong GET-Parameter) and Errors that dont come from me but from the Code itself (A typical PHP Errors has soemthing between 100-200 Bytes, a MYSQL Errror has something between 150 and 500 Bytes). How can I track those errors? Now that I switched to SWFLoader by default (ByteArrays are nice, but nothing beats the power of rawContent), I get alot of Error-Messages that always say "Has wrong Type" on so on. What of the SWFLoader Events is able to say "Look, here is something that is not a SWF and I want you to know that your server responded with: MYSQL Error foo is not a Table of your Database"

 

Indy

Link to comment
Share on other sites

Sorry, I wish I had a great answer for you but unfortunately I don't. It's a bit beyond the scope of what we normally provide in the forums here, and to be totally honest, I haven't spent much time in Flash for the last couple of years. The LoaderMax documentation has all the info about how you can get error reporting from the classes (if that's what you're after). Feel free to crack open the source code too and see what's going on. If you find anything that could be improved, we're all ears. 

  • Like 2
Link to comment
Share on other sites

Well, let me thank you that you guys still support the ActionScript Codebase. Thats is anything but granted. Thank you.

 

btw: I was wondering what you do now a days. GSAP all the way I guess? I used it and love it as well. Where are you located? In all these years, I couldnt get a good Idea of who you guys are where you work (Chicago?) and how your day by day bussiness works (and why Adobe never bought you, or did they?). Now with GSAP you really should put your head out and talk more about Greensocks (club). I see you have now a google+ Page... without any Photos or glimpse behind the scenes. I would love to read more from greensocks. Now more then ever.

 

 

 

Indy

  • Like 1
Link to comment
Share on other sites

Great to hear you've been a long-time user/supporter. And yes, I agree - we need to get out and connect with the community more. We've been hunkered down focusing on making the animation platform as solid as possible, and we're about to launch a completely redesigned web site which took way longer than it should have :) Hopefully we'll get some time to connect more soon. 

 

Yes, GSAP for HTML5/JS has gotten the lion's share of our devotion for the last couple of years because our customers have made it pretty clear that it's where they need the tools the most. I must admit that it's a lot of fun too. I really enjoy it (well, once I got over the "oh my gosh I can't stand browser inconsistencies" phase). 

 

I'm near Chicago and Carl is near New York.

 

No, Adobe never bought us, but we talk with them regularly :) They've got some cool people there. And nobody builds a better GUI. 

 

Carl and I are full-time devoted to building these tools and supporting them, answering questions, refining things, training, etc. This is NOT a side-project. In fact, I work an insane amount of hours. My body is slowly adjusting to a consistent state of sleep deprivation. :)

 

Thanks for the suggestion about the "behind the scenes" stuff. I think that's an excellent point. Sometimes we're so focused on the tools themselves that we neglect the more personal side of things. We really owe all the success to supporters like you who take an interest, recognize the hard work we've put in, and spread the word. So thanks. 

 

Happy tweening (and loading)!

  • Like 4
Link to comment
Share on other sites

  • 3 years later...
On 8/4/2014 at 5:01 AM, Indyaner said:

pretty easy:


var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaderOnComplete);
loader.loadBytes(ba);

protected function loaderOnComplete(event:Event):void{
	addChild(loader);
}

 

 

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.
×
×
  • Create New...