Flash gallery app
Writing about web page http://www2.warwick.ac.uk/services/elearning/experts/elat/about/stevencarpenter/flash/galleries/
As if working/parenting/studying/planning a wedding didn’t take up enough of my time, in the odd moment here and there in between I’ve been building this Flash gallery application (needs the new Flash 8 player), and finally got it working. I’ve wasted more than few hours on the following bugs though;
- V2 object depth bug; V2 components that are instantiated using this.getNextHighestDepth() won’t remove properly due to a bug in MX - after many hours of Googling and trying different things I finally found that using unloadMovie() does work
- Loader class event bug – I nearly gave up on this, but finally found out that the Loader class requests an image 3 times, then gives up. But rather than just giving up, it sends a ‘complete’ event to the listener anyway, the net result being that anything I tried to do to the object within the listener didn’t work, because nothing was there. The workaround was to use Jeff Tappers excellent IELoader subclass which fixed it for IE. Firefox was still refusing to load and display all the images though, but only if I had set the Loader object scaleContent to true; setting it to false would result in a full set of images but at full size. I never found a satisfactory way to rescale the images without problems, so it was time to turn to a new Flash 8 class that offers an alternative to the Loader; MovieClipLoader. Except that…
- MovieClipLoader onLoadComplete() event. This new class seems to operate in a slightly odd way. There are several events this class can fire off, including onLoadInit(), which fires when the first chunk of data arrives, onLoadError(), onLoadProgress() and onLoadComplete(). Now which one of those would you think would tell you when you have all your image data (and can therefore perform things like a resize/reposition)? Wrong! onLoadComplete should do that, but for some reason it doesn’t. onLoadInit() does though. Macromedia changed the LiveDoc on this yesterday after I’d figured it out myself…
“When you use the onLoadComplete and onLoadInit events with the MovieClipLoader class, it’s important to understand how this differs from the way they work with your SWF file. The onLoadComplete event is called after the SWF or JPEG file has loaded, but before the application has been initialized. At this point it is impossible to access the loaded movie clip’s methods and properties, and because of this you cannot call a function, move to a specific frame, and so on. In most situations, it’s better to use the onLoadInit event instead, which is called after the content has loaded and is fully initialized.”
Mr. Macromedia, no-one loves using Flash more than me, but this kind of stuff is such a pain in the rear. While there’s a certain satisfaction to be gained from being a ‘god-of-asynchronous-event-programming’ (and the new features like dynamic filtering rock), the cost in terms of hours wasted is somewhat higher than many of us would like.
Paul, Hannah and Kieran – thanks for all the help!
Anyway, enjoy…if it breaks, I’m not here…

