Archive for March, 2008

removeEventListener causing memory leak?

Update

After inspecting my dispatcher .. i find this awful mistake:

override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0.0, useWeakReference:Boolean=false):void {
_node.addEventListener(type, listener, useCapture, priority, useWeakReference)
}

override public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void {
_node.addEventListener(type, listener, useCapture)
}

(DOH!!!!!!!!!! LOL)

——

To cut to the chase, in my personal AS3 framework, I’ve implemented deconstructors in all my DisplayObjects objects. The deconstructors mostly feature removeEventListener calls as I try to stay away from using weak refs. Today, while making a regular memory leak check using Flex Builder 3’s profiler, I noticed that I had a few DisplayObjects still latched onto an event dispatcher model object they were supposed to have let go of.

The first thing I did was to put a trace() in my deconstructor to make sure it was being called, yes it was. WTF? After some more digging, I then saw that this particular DisplayObject was flagged to not attach itself to the event dispatcher in the first place. (Wait, you mean that addEventListener hadn’t even been called in the first place? Yes!) So I switched the flag so that the DisplayObject would attach to the event dispatching model and guess what, this time it got GC’d after the deconstructor call.

So why is removeEventListener causing this to happen, the API docs define the method as:

“Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.”

Has no effect, huh? But it seems to be doing something. Has anyone noticed anything similar to this?

San Flashcisco Meet tonight feat. eBay Desktop

Reminder: San Flashcisco March meet is tonight.

This month we are honored to have eBay Technical Evangelist, Alan Lewis, as our special guest. Alan will be presenting a case study on the high profile Adobe AIR project, eBay Desktop. Then afterwards he’ll be available to answer all of your burning questions in an AIR Q&A panel.

We shall also be exploring new workflows within the Flash Authoring IDE for creating and publishing AIR projects and taking a brief look over the new AIR APIs/features.

Cost: Free to attend & free PIZZA & BEER

Details & RSVP

San Flashcisco: March Meeting feat. eBay Desktop

San Flashcisco has just announced the agenda for the March 20th San Flashcisco meet up.

This month we are honored to have eBay Technical Evangelist, Alan Lewis, as our special guest. Alan will be presenting a case study on the high profile Adobe AIR project, eBay Desktop. Then afterwards he’ll be available to answer all of your burning questions in an AIR Q&A panel.

We shall also be exploring new workflows within the Flash Authoring IDE for creating and publishing AIR projects and taking a brief look over the new AIR APIs/features.

Cost: Free to attend & free PIZZA & BEER

RSVP Now!.

Flash on iPhone & Flash 10 Thoughts

This week I’ve been reading a lot of posts from people complaining about the lack of Flash support for the iPhone. A lot of this commentary has risen from Steve Jobs himself having said that “it performs too slowly on the iPhone“. Now, I don’t doubt his reasoning for a second, but I’m not saying that AVC2 isn’t blazing fast. I’m saying that a lot of SWF on the Internet are poorly constructed, resulting in CPU bombardment.

The cost of a cycle on a handheld CE device is great because sooner or later you’re going to run out of power. If you’re running poorly constructed SWFs all day long from random-bogus-flash-site.com then your either going to run our of power fast or leak memory everywhere.

Today I could be viewing a small flash banner ad from website X that will motor up my laptops fans with what appears to be next to no functionally or animation - what the hell!? I propose that someone please start a Flash name & shame website that decompiles these SWFs so that common mistakes can filter down to the people who created them.

I believe that poorly constructed SWFs are the main reason why you won’t be seeing Flash on the iPhone anytime soon. Steve wants a consistent Safari experience for it’s users. It would be too painful if Safari crashed every couple of minutes because ‘Banner ad company XYZ’ hired the lowest bidder.

And of course it would only be naive to say that Flash on the iPhone isn’t a clash of interests. Why would Apple want another media player on the iPhone? Remember that at the end of the day, the iPhone is still the flagship iPod. Apple won’t sell any iTunes media if you can stream it for free all day long.

Of course Apple could choose to disable Flash in Safari, but allow you to create springboard apps. But this is really what the iPhone SDK is all about, so I don’t really think Flash fits here. Maybe platform portability is the best argument to have Flash apps, but why would Apple go for that. For starters, Apple doesn’t want famous iPhone app “Q” to one day start running on a Sony Ericsson phone. How would that sell iPhones?

The iPhone is extremely powerful in terms of multimedia rendering, You’re able to utilize its engaging Core Animation framework featuring embedded OpenGL to create the kinds of real time effect you would see in ‘Photo Booth’ for example. The ability to draw power from hardware acceleration means that the iPhone can pushing bits around the screen at a very decent frame-rate without bothering the CPU too much.

Could Flash 10 with hardware acceleration be the answer to the iPhone SDK? It seems today that AVM2 can push code around with ease but its display list rendering is greatly lacking. Could Flash 10 solved this? Could 10 be the platform of choice for competing mobile brands? It seems to me that portable mobile apps are the best way to compete with the iPhone right now. So, wouldn’t it be great if those portable apps were F10 SWFs?!