4

Are there any way to 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?

Andy Li
  • 5,894
  • 6
  • 37
  • 47

3 Answers3

2

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

Herms
  • 37,540
  • 12
  • 78
  • 101
Luis B
  • 1,684
  • 3
  • 15
  • 25
  • The workaround suggested in the 2nd link is quite good (+1 for that). But still none of those do static child component :( – Andy Li Oct 15 '09 at 16:56
  • Accepted this answer since it is the only thing can be done so far. Hope Flex 5 will support mxml static/private :( – Andy Li Oct 30 '09 at 18:14
0

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.

Amarghosh
  • 58,710
  • 11
  • 92
  • 121
0

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.

Henrik Aasted Sørensen
  • 6,966
  • 11
  • 51
  • 60