开发者

Interface IDisposable gone in Flex 4.5?

开发者 https://www.devze.com 2023-03-05 04:26 出处:网络
It seems that Flex 4.5 can not compile my old AIR applications that implement the IDisposable interface. What? Why? And how should memory management be done from now on?

It seems that Flex 4.5 can not compile my old AIR applications that implement the IDisposable interface. What? Why? And how should memory management be done from now on?

I've searched the Adobe 开发者_开发技巧site, various forums and of course googled the net up and down.

Cheers


I can't say I've ever seen a class called IDisposable in the API even after looking at all the docs and searching online. I mean there are tons of interfaces for it, but it's not in the API. I believe you're just missing a file or a reference to a library that had an IDisposable so that you can programically 'destroy' objects and leave it for the GC to collect.

Here's an easy implementation of the pattern:

public interface IDisposable {
    function dispose():void;
}

public class MyComponent implements IDisposable {

    // Implements dispose method that must be called just before
    // releasing a MyComponent object
    public function dispose():void {
        // Clean up:
        //      - Remove event listeners
        //      - Stop timers
        //      - Set references to null
        //      - ...
    }

    ...
}

This is a good pattern for follow, but often times isn't needed if each Flex component is encapsulated and uses a good component lifecycle practice.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号