Comments on: Skipping id in MXML to create private sub-components https://joshblog.net/2009/07/22/flex-mxml-private-child-id/ Archive of older blog posts written by Josh Tynjala about Flash, Flex, and ActionScript Wed, 26 Jun 2013 02:52:46 +0000 hourly 1 https://wordpress.org/?v=4.9.9 By: Josh Tynjala https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-9925 Wed, 18 May 2011 15:17:36 +0000 http://joshblog.net/?p=662#comment-9925 No, I don’t believe it has been addressed.

]]>
By: Alan G. https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-9920 Wed, 18 May 2011 12:34:01 +0000 http://joshblog.net/?p=662#comment-9920 Nice solution. Was SDK-219 ever addressed (its been around since 2007, wow)? Is there a cleaner way to achieve this now? This is clearly a problem from the standpoint of proper encapsulation.

]]>
By: Andy Gorman https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-1907 Fri, 30 Apr 2010 16:28:02 +0000 http://joshblog.net/?p=662#comment-1907 I think this is a very useful flex idiom. It may not be bullet proof, but I do feel better making an effort to increase encapsulation.

]]>
By: Matt Garland https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-1906 Thu, 23 Jul 2009 20:23:23 +0000 http://joshblog.net/?p=662#comment-1906 Thanks! I’ll take a look.

]]>
By: Josh Tynjala https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-1905 Thu, 23 Jul 2009 16:56:51 +0000 http://joshblog.net/?p=662#comment-1905 Hi Matt, it’s not the same as JQuery, but I created something I called DisplayQuery (name similarities unintentional) for AS3. It’s actually very much like E4X, but it’s for the display list instead of XML. Here’s an example of how it works:

var dq:DisplayQuery = new DisplayQuery(this);
//getChildByName() with @
var grandChild:Sprite = dq.@childName.@grandChildName.toDisplayObject();

//or

//descendants operator
grandChild = dq..@grandChildName.toDisplayObject();

I haven’t released it yet, but the code is floating around on my Google Code account: org.josht.dq.*. The classes work as closely to XML and XMLList as I could make them.

In the future, I may add support for CSS-style selectors, in addition to the @ and .. operators. I have a proof of concept where the code looks something like this:

var tf:TextField = dq..$["Sprite>TextField"];
]]>
By: Matt Garland https://joshblog.net/2009/07/22/flex-mxml-private-child-id/#comment-1904 Thu, 23 Jul 2009 16:36:54 +0000 http://joshblog.net/?p=662#comment-1904 I could see use cases for this, but after spending a week with JQuery, I’d rather go the opposite direction: Flex need more DOM-like functionality for the view. I’d like to grab types of objects more easily, either by id, partial id, class, etc. And I’d like the ability to step down the display hierarchy without worrying about enclosing objects with no or different ids. Give me this power and I will not abuse it, promise. I spend too much time collecting and accessing object references.

]]>