开发者

static/private child component in mxml?

Are there any way t开发者_Python百科o declare a child component in mxml which is private/protected or even static?

Sure we can do this inside a script tag, but are there any other way?


Ashier suggests using the "Exclude" metadata tag, but Maskit offers its limitations and suggests alternative solutions:

http://blog.ashier.com/2008/03/25/hiding-properties-in-flex-components/
http://smaskit.blogspot.com/2008/07/making-mxml-subcomponent-private.html


In the strict meaning of these terms, no you can't do that using mxml. The second link posted by Luis contains some workarounds for private/protected behavior.


I found a solution to the static question. I wanted a quick memo pad that could be accessed anywhere in the mobile app, without one instance overwriting edits left open in a different screen.

I created a memo pad mxml control, and then placed it inside a declarations section in the top level application mxml. In each view that I wanted the memo to appear in, I added:

import mx.core.FlexGlobals;
import components.QuickMemo;

private var memo:QuickMemo;

In the view creation complete:

memo = FlexGlobals.topLevelApplication.memo;

In the viewActivation code, I added:

memo.visible = false;
addElement(memo);

In the viewDeactivation code, I included:

removeElement(memo);

The net effect is that only one instance of the memo exists at any time, and that one instance opens in whatever state it existed in the last view it appeared in.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜