Ely,

Thanks for the response.  Here is a brief example.  I am now aware of
the [ArrayElementType] tag, but it still illustrates the issue well.

We have a value object that has some properties marked with metadata
like this:

----
public class ContactVO{
     [Collection(type="String")]
     public var phoneNumbers: ArrayCollection = new ArrayCollection();

     // more properties and methods follow
}
----

Now we have some code that attempts to read the "type" attribute out
of the [Collection] metadata tag we used.  Here is a intentionally
drawn out example that uses hardcoded values to illustrate the problem.  

----
var contact:ContactVO = new ContactVO();

// get the E4X XML object description
var typeInfo:XML = describeType(contact);

// get the phoneNumbers property we marked up with metadata
var phoneDesc:XMLList = typeInfo..accessor.(@name == "phoneNumbers");

// grab the "Collection" metadata description
var phoneMetaData:XMLList = 
     phoneDesc..metadata.(@name == "Collection");

// grab the "type" argument from the "Collection" metadata
var metaDataDesc:XMLList = phoneMetaData..arg.(@key == "type");

// finally, grab the value of this "type" argument
var typeValue:String = [EMAIL PROTECTED];

Alert.show(typeValue);
----

In debug mode all of the above works perfectly, and we see an alert
box with "String".  In run mode at some point in the metadata reading
code I get the following:

----
ReferenceError: Error #1065: Variable is not defined
     at global/flash.utils:getDefinitionByName()
     // more stuff, but in our code
----

It is difficult to show you where exactly the failure occurs because
in debug mode it works great - this prevents me from using
breakpoints, getting line numbers, or using trace.

Now to debug this in some manner, we added an Alert.show(typeInfo)
immediately after:
var typeInfo:XML = describeType(contact);

In debug mode, it looks roughly like this (clipped out stuff that
isn't relevant).

----
<type name="ContactVO" ...>
     <accessor name="phoneNumbers" ...>
          <metadata name="Bindable" .../>
          <metadata name="Collection" .../>
     </accessor>
</type>
----

In run mode, it looks like this:

----
<type name="ContactVO" ...>
     <accessor name="phoneNumbers" ...>
          <metadata name="Bindable" .../>
     </accessor>
</type>
----

Note that the only difference is that in run mode, the second
<metadata> tag corresponding with our custom [Collection] tag has been
thrown out.  We can provide a more complete example if desired, but
the xml difference really makes us believe the tag is being dropped.

In ALL of the above we are using a "-keep-as3-metadata+=Collection"
argument.  Literally the only difference is whether or not we are
running in debug mode.

I appreciate any assistance with this,

Joe Uhl

--- In [email protected], "Ely Greenfield" <[EMAIL PROTECTED]> wrote:
>
>  
>  
>  
> I checked around internally, and the feature is supposed to work in
> release mode, and evidently we have some proof that it does, at least in
> our scenarios.
>  
> So a simple sample that shows it failing might help.  
>  
> Ely.
>  
>  
> p.s. the reason metadata is stripped by default is for SWF size reasons.
>  
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of gtuhl
> Sent: Friday, February 02, 2007 6:08 AM
> To: [email protected]
> Subject: [flexcoders] Re: Flex 2 Compiler / Metadata Question
> 
> 
> 
> Sure thing,
> 
> The ideal scenario for us would be to use our own custom metadata tags
> in our Flex code. We have built a DWR wrapper that lets us use DWR in
> Flex 2, and many of the methods that automate this would benefit
> enormously from being able to read various things from an ActionScript
> object's metadata at run-time.
> 
> As examples, two of the cases that would be extremely helpful are:
> 
> - Mark properties of our IValueObject classes as transient such that
> the conversion code knows to skip them
> - Mark both the key type and value type of a hashmap-style data
> structure (like the Java Map interface and its various implementations)
> - Mark up classes such that their persistence policies can be
> specified in a declarative manner and then handled through a common
> set of functions
> 
> Flex has this metadata construct that is pretty powerful ([Bindable],
> [Effect], [Embed], etc) but it only allows you to use a small set of
> adobe-specified metadata tags that the core adobe code is aware of and
> uses.
> 
> We want to create and use our own custom metadata tags. Just as an
> example, if we made that transient tag, it could be as simple as:
> 
> [Transient]
> public var someProperty : String;
> 
> Now our code can read the metadata of an objects properties and
> determine at run-time which ones it can skip.
> 
> Flex lets you add your own metadata tags, and if you use the
> -keep-as3-metadata+=Transient compiler flag it works beautifully in
> Debug mode. But when you switch to run mode, it goes back to throwing
> out all metadata tags it doesn't understand.
> 
> We just want to find a way to keep them around in both run and debug
> modes. It seems like this metadata construct could be incredibly
> powerful for certain types of applications, especially libraries and
> tools.
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , Tom Chiverton <tom.chiverton@>
> wrote:
> >
> > On Thursday 01 Feb 2007, gtuhl wrote:
> > > Anyone have any ideas?
> > 
> > Remind us of the problem you are trying to solve.
> > 
> > -- 
> > Tom Chiverton
> > Helping to professionally strategize visionary supply-chains
> > 
> > ****************************************************
> > 
> > This email is sent for and on behalf of Halliwells LLP.
> > 
> > Halliwells LLP is a limited liability partnership registered in
> England and Wales under registered number OC307980 whose registered
> office address is at St James's Court Brown Street Manchester M2 2JF.
> A list of members is available for inspection at the registered
> office. Any reference to a partner in relation to Halliwells LLP means
> a member of Halliwells LLP. Regulated by the Law Society.
> > 
> > CONFIDENTIALITY
> > 
> > This email is intended only for the use of the addressee named above
> and may be confidential or legally privileged. If you are not the
> addressee you must not read it and must not use any information
> contained in nor copy it nor inform any person other than Halliwells
> LLP or the addressee of its existence or contents. If you have
> received this email in error please delete it and notify Halliwells
> LLP IT Department on 0870 365 8008.
> > 
> > For more information about Halliwells LLP visit www.halliwells.com.
> >
>


Reply via email to