Skip to main content
Participant
May 6, 2008
Question

Enhanced States Syntax

  • May 6, 2008
  • 6 replies
  • 850 views
I just saw that Flex 4 state names will be restricted to the intersection valid AS3 and XML identifiers. What is the rationale behind that?

This conflicts with how we are using URI's for hierarchical states within our application framework. We can pretty easily get around it by using a subclass of state, that adds a uri property instead of using name, and we were already considering doing that anyway for other reasons. But, in case it is helpful or anyone wants to discuss this, I'll explain what we are doing:

Our apps use a global state string, which is a URI. Individual views define states which may match parts of that URI, and respond to global state change by assuming the closest parent-or-self to the global state.

For example, a view might define states:

"/a"
"/a/b/c"
"/a/b/d"
"/a/b"

If the global state is "/a/b/c" then the view will go into state "/a/b/c",
If the global state is "/a/b/foo/bar" then the view will go into the
state "/a/b",
If the global state is "/a/xyz/abc" then the view will go to the state "/a".

This structure lets us control states very cleanly, without knowledge
of the actual views, and it separates the containment structure of the views from the screens that have been designed and approved by a client. The result is that the views know how to render themselves in any given application state, but you don't need to know how to address any particular view component instance in order to make it do that.

Peter
This topic has been closed for replies.

6 replies

Participating Frequently
May 6, 2008
One consideration would be whether we wanted to use namespaces for language or component properties. If states also were done via namespaces, we couldn't scope attributes in both say a language namespace and a states namespace.
Participant
May 6, 2008
I haven't seen that spec yet but, from the little I've heard, I<br />assumed it was more for meta information, rather than accessing<br />properties that are defined in AS3 namespaces, in which case there<br />wouldn't be a problem.<br /><br />Peter<br /><br /><br />On Tue, May 6, 2008 at 8:00 PM, Corey Lucier <member@adobeforums.com> wrote:<br />> A new message was posted by Corey Lucier in<br />><br />> Developers --<br />> Enhanced States Syntax<br />><br />> Most definitely this was considered. But as you will see in the pending MXML<br />> Language specification, MXML 2009 (Flex 4) will support namespaces with<br />> attributes. I won't go into the details here in depth but...<br />><br />> That's really the issue. If some attribute is already scoped to a specific<br />> namespace then you can't really stack another namespace on top (e.g.<br />> state:ns:attribute) - not XML 1.0 friendly.<br />><br />> -C<br />><br />><br />> On 5/6/08 12:49 PM, "peterjoel" <member@adobeforums.com> wrote:<br />><br />> > A new message was posted by peterjoel in<br />> ><br />> > Developers --<br />> > Enhanced States Syntax<br />> ><br />><br />> > Were any other syntaxes discussed, besides the |property.stateName| ?<br />> ><br />> > An alternative, involving namespaces would work pretty well, but would<br />> > introduce some extra boilerplate code, that might feel a bit<br />> > unnecessary. ie, where the following both do the same thing:<br />><br />><br />><br />><br />> ------------------------------------------------------<br />> View/reply at <a href=http://www.adobeforums.com/webx?13@@.59b52ce5/3><br />><br />> Replies by email are OK.<br />> Use the unsubscribe form at <a href=http://www.adobeforums.com/webx?280@@.59b52ce5!folder=.3c060fa3> to cancel your email subscription.<br />>
Participant
May 6, 2008
Most definitely this was considered. But as you will see in the pending MXML<br />Language specification, MXML 2009 (Flex 4) will support namespaces with<br />attributes (to a very limited degree). I won't go into the details here in depth but...<br /><br />That's really the issue. If some attribute is already scoped to a specific<br />namespace then you can't really stack another namespace on top (e.g.<br />state:ns:attribute) - not XML 1.0 friendly. And if we chose to support more in depth namespacing schemes for attributes (such as your style:foo, or on:click ), then they would certainly clash.<br /><br />-C<br /><br />On 5/6/08 12:49 PM, "peterjoel" <member@adobeforums.com> wrote:<br /><br />> A new message was posted by peterjoel in<br />> <br />> Developers --<br />> Enhanced States Syntax<br />> <br />> Were any other syntaxes discussed, besides the |property.stateName| ?<br />> <br />> An alternative, involving namespaces would work pretty well, but would<br />> introduce some extra boilerplate code, that might feel a bit<br />> unnecessary. ie, where the following both do the same thing:
Participant
May 6, 2008
Were any other syntaxes discussed, besides the |property.stateName| ?<br /><br />An alternative, involving namespaces would work pretty well, but would<br />introduce some extra boilerplate code, that might feel a bit<br />unnecessary. ie, where the following both do the same thing:<br /><br /><mx:Application xmlns:mx="http://ns.adobe.com/mxml/2009"><br /> <mx:states><br /> <mx:State name="state1" /><br /> </mx:states><br /> <mx:Button label="normal label" label.state1="another label" /><br /></mx:Application><br /><br /><br /><mx:Application xmlns:mx="http://ns.adobe.com/mxml/2009"<br />xmlns:s1="URIForState1" ><br /> <mx:states<br /> <mx:State name="state1" ns="URIForState1" /><br /> </mx:states><br /> <mx:Button label="normal label" s1:label="another label" /><br /></mx:Application><br /><br /><br /><br />Peter<br /><br /><br />On Tue, May 6, 2008 at 6:01 PM, Corey Lucier <member@adobeforums.com> wrote:<br />> A new message was posted by Corey Lucier in<br />><br />> Developers --<br />> Enhanced States Syntax<br />><br />> Hi Peter, Thanks for giving the draft spec a read through.<br />><br />> The limitation is primarily intending to render state identifiers compatible<br />> with XML attributes (sans '.' and ':'), less so AS3 identifiers (will<br />> clarify that portion of the draft soon). This is to allow for state-specific<br />> properties to be expressed as XML attributes (color.StateA="red").<br />><br />> To your point it should be somewhat straight forward to adapt to the new<br />> restriction by extending State or by providing a transformer of sorts to<br />> roundtrip your path-centric identifiers to a form suitable for use with the<br />> new states.<br />><br />><br />> ________________________________<br />> View/reply at Enhanced States Syntax<br />> Replies by email are OK.<br />> Use the unsubscribe form to cancel your email subscription.<br />><br />>
Participant
May 6, 2008
Actually, it's pretty obvious that the restriction is required for the<br />new dot syntax...<br /><br />Peter<br /><br /><br />On Tue, May 6, 2008 at 5:41 PM, peterjoel <member@adobeforums.com> wrote:<br />> A new discussion was started by peterjoel in<br />><br />> Developers --<br />> Enhanced States Syntax<br />><br />> I just saw that Flex 4 state names will be restricted to the intersection<br />> valid AS3 and XML identifiers. What is the rationale behind that?<br />><br />> This conflicts with how we are using URI's for hierarchical states within<br />> our application framework. We can pretty easily get around it by using a<br />> subclass of state, that adds a uri property instead of using name, and we<br />> were already considering doing that anyway for other reasons. But, in case<br />> it is helpful or anyone wants to discuss this, I'll explain what we are<br />> doing:<br />><br />> Our apps use a global state string, which is a URI. Individual views define<br />> states which may match parts of that URI, and respond to global state change<br />> by assuming the closest parent-or-self to the global state.<br />><br />> For example, a view might define states:<br />><br />> "/a"<br />> "/a/b/c"<br />> "/a/b/d"<br />> "/a/b"<br />><br />> If the global state is "/a/b/c" then the view will go into state "/a/b/c",<br />> If the global state is "/a/b/foo/bar" then the view will go into the<br />> state "/a/b",<br />> If the global state is "/a/xyz/abc" then the view will go to the state<br />> "/a".<br />><br />> This structure lets us control states very cleanly, without knowledge<br />> of the actual views, and it separates the containment structure of the<br />> views from the screens that have been designed and approved by a client. The<br />> result is that the views know how to render themselves in any given<br />> application state, but you don't need to know how to address any particular<br />> view component instance in order to make it do that.<br />><br />> Peter<br />><br />> ________________________________<br />> View/reply at Enhanced States Syntax<br />> Replies by email are OK.<br />> Use the unsubscribe form to cancel your email subscription.<br />><br />>
Participant
May 6, 2008
Hi Peter, Thanks for giving the draft spec a read through.

The limitation is primarily intending to render state identifiers compatible with XML attributes (sans '.' and ':'), less so AS3 identifiers (will clarify that portion of the draft soon). This is to allow for state-specific properties to be expressed as XML attributes (color.StateA="red").

To your point it should be somewhat straight forward to adapt to the new restriction by extending State or by providing a transformer of sorts to roundtrip your path-centric identifiers to a form suitable for use with the new states.