-
1. Re: Async loading of test swf is never caught by listener
Michael Labriola Oct 22, 2010 11:50 AM (in response to Happy Spud)Can you provide a project that shows the issue?
1) Are you sure it actually occurs within the 10 seconds you are allowing?
2) Did you check to see if you are getting any of the other events that the loader dispatches? You are checking for complete... what if you are getting a security error or other such issue in Flash?
Mike
-
2. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 22, 2010 3:51 PM (in response to Michael Labriola)Thanks so much for answering; will try and put together an example project shortly. In the meantime I'll answer the questions...
1. Yes. I've tried referencing the file both locally and remotely (i.e. stuck the .swf on a server). Firebug displays a 200 return and accurately reflects how large the .swf is, so it's being called alright
2. Tried IO_ERROR at one point too but that didn't work either I don't think
Regarding loading the file in locally; what should be the correct load path from where the test is running from? My .swf(s) end up in a standard setup of bin-debug or bin-release but I've been trying to target using just the name of the .swf when running locally (i.e. no directory or subdir path). Should that be correct? When I try locally however the .swf I'm trying to load doesn't even appear in Firebug, so I'm guessing not...
-
3. Re: Async loading of test swf is never caught by listener
Michael Labriola Oct 22, 2010 4:05 PM (in response to Happy Spud)Be sure to look at more than just IO_ERROR. There are half a dozen events emitted by that Loader. Firebug seeing a 200 is great, but it means little. That just means the browser was able to get the file. Whether flash player loads it correct... and is able to use it... is the work of the Loader.
So, you could see a 200, but Flash could be throwing a security error
Mike
-
4. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 22, 2010 4:29 PM (in response to Happy Spud)Sample now here (and thanks once again): https://dl.dropbox.com/u/877754/flexunittests.zip
-
5. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 22, 2010 4:36 PM (in response to Michael Labriola)Wouldn't the debug Flash player reveal any security errors though? As I said, I've tried loading it in locally (currently in that example file I linked to) and remotely.
Remotely the browser gives the 200, locally it doesn't seem to get it at all. Both cases the timeout kicks in.
-
6. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 24, 2010 5:04 AM (in response to Happy Spud)If I specify a non-existant URL then I get this error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
...so the previous URLs I've been specifying must've been verified by the Flash player before failing in some respect somewhere else.
No event listeners seem to pick up on anything. I've tried adding a few extra (not in the example link I supplied previously yet) but the timeout function is the one which is always hit.
_loader.addEventListener(Event.INIT, Async.asyncHandler(this, initHandler, 10000, null, handleTimeout));
_loader.addEventListener(IOErrorEvent.IO_ERROR, Async.asyncHandler(this, onIoError, 10000, null, handleTimeout));I've tried moving these listeners up in the [Before] block too with similar results.
-
7. Re: Async loading of test swf is never caught by listener
Daniel Rinehart Oct 24, 2010 5:25 AM (in response to Happy Spud)The events you are listening for are not dispatched from the Loader
instance, but from its contentLoaderInfo property. If you update your
test as follows it should start working:
[Test(async, description="Async Success Example")]
public function loadSwf():void
{
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
Async.asyncHandler(this, verifySwfLoad, 10000, null, handleTimeout));
loader.load(request);
}
-- Daniel R. <danielr@neophi.com> http://danielr.neophi.com/
-
8. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 24, 2010 6:18 AM (in response to Daniel Rinehart)Thanks a lot Daniel!
I am still trying to work out a couple of things however, namely why Firebug doesn't reveal it's trying to load the .swf if loaded in locally (it appears when you specify a remote URL), and why can't I add more than one listener than the Event.COMPLETE...it results in the test failing when subsequently run:
Error: Asynchronous Event Received out of Order
Adding the eventListeners in the [Before] function doesn't help. Does FlexUnit4 support more than one eventListener being applied at a time?
-
9. Re: Async loading of test swf is never caught by listener
Daniel Rinehart Oct 24, 2010 11:10 AM (in response to Happy Spud)It has been my experience that Firebug does not report files loaded
through a file:// based URL.
You can use multiple listeners but you must add them in the oder that
they will fire, hence the "out of order" failure you are seeing.
Unless you are explicitly testing the ordering of events, I'd
recommend just waiting on the COMPLETE event as in the code snippet I
posted earlier.
-- Daniel R. <danielr@neophi.com> http://danielr.neophi.com/
-
10. Re: Async loading of test swf is never caught by listener
Happy Spud Oct 24, 2010 11:16 AM (in response to Daniel Rinehart)Once again, thanks a million.
-
11. Re: Async loading of test swf is never caught by listener
Michael Labriola Oct 24, 2010 12:53 PM (in response to Happy Spud)daniels advice is spot on.
btw, keep your eyes open as the order of events is something we are addressing very soon
mike


