I'm trying to implement a download queue for a list of files.
Initially I create a connection using UrlLoader.new(url) and add the appropriate event listeners.
The first thing both the ERROR and COMPLETE listeners do is remove both listeners from the connection.
I then parse the downloaded file and then create a new connection (still from within the original callback) and re add the event listeners (my thinking here is that the listeners were associated with the PREVIOUS connection not THIS one), however once the original callback has finished my app appears to hang and the new connection handlers never get called.
Anyone (
@Atilim ) got any ideas?
@Scouser suggested creating a single connection without the URL and using the load() function - is this a better solution, anyone got any code they want to share?
Thanks (in advance)
WhiteTree Games - Home, home on the web, where the bits and bytes they do play!
#MakeABetterGame! "Never give up, Never
NEVER give up!" -
Winston Churchill
Comments
I'm going to try adding a simple enterFrame listener that will initialise the load calls via a simple finite state machine, I know I can make multiple calls to UrlLoader objects as I've done it elsewhere (just not processing a queue), so I'm going to try this and let you know how I get on.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
To download a single file you must create an instance of a UrlLoader and assign the appropriate event handlers to it.
Once the download is complete you are free to work with the data - BUT you can't reuse the connection (ie make a subsequent :load() call), other than removing the event handlers you also CAN'T do anything with the instance of the connection (ie the original return value from UrlLoader:new()) - you certainly can't create a NEW connection and assign it to the variable (don't ask me why!) otherwise the any attempt to download will just cause it to crash.
The way I got round the problem was to have a table of UrlLoader instances and create one per file.
Initially the table was empty - and I used a onEnterFrame listener to watch the state of a flag that was set each time a download completed and was then used to trigger the next load from the onEnterFrame listener.
Once all the files had been downloaded I then set a different flag which caused the onEnterFrame listener to pickup the fact that all the files had been downloaded and then nil out all the references to the UrlLoader instances before continuing.
I'm not sure if this the best method to use but until I get official word from those "in the know" it'll do.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
I tried to create a trivial example to show off the problem and it ended up working ???
I then went back to try and undo the changes and make my project not work and that's working as well... ( even more ???? )
Must go and have a chat with the IT guy who manages the site and find out if he's messed with anything!
Anyway if anyone's interested here's an example of downloading a list of files...
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill