开发者

Difficulty copying/extending singleton manager class

I want to extend or copy the PopUpManager class to add the ability to keep track of the number of windows. I just want to add a simple windowCount++ when a window is added and windoCount-- when it's removed.

the problem is PopUpManager is a Singleton class... I wasn't able to make it work properly by extending it. And now I have tried to copy the code from the PopUpManager.as file and just add my variable to the end of its functions. It doesn't seem to be working though since it says my properties are un开发者_如何学运维defined even though they are declared above the constructor.

I am thinking I would have to make a copy of the PopUpManagerImpl.as since that's wehre it seems much of the business resides (PopUpManagerImpl extends EventDispatcher implements IPopUpManager) would that allow me to have access to the variable? and should I ignore the manager and just put it in the implementation class?


here is a link about Using the Flex Singleton register, which helped me out when finding myself in the same situation.

I hope you can inspire from that too.


You likely didn't declare yours properties as static. The PopUpManager uses all static methods - this is why working with it you use syntax like:

PopUpManager.createPopUp(...

instead of

var popUpManager:PopUpManager = new PopUpManager();
popUpManager.createPopUp(...

This means that any variables declared in the PopUpManager need to also be static so as to be accessible at the class level.

public static var windowCount:int
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜