[flexcoders] ExternalInterface Bug

2007-03-06 Thread gtuhl
I hope this isn't a bug and I am just doing something wrong.  The
situation is we have an object that looks like this (JSON notation):

pre
mainObject = {
id: 1234,
name: mainObject Name,
control: mainObject Control,
subObject: {
id: abcd,
name: subObject Name,
control: subObject Control
}
}
/pre

That is we have an object with a property that is another object type
and both objects share some property names.

When we route something like this through ExternalInterface I can
verify the object is exactly as described above using Firebug on the
JS side and remains that way right up through completion of the
ExternalInterface call.

Then immediately upon this object's arrival on the actionscript3 end
it looks like this:

pre
mainObject = {
id: abcd,
name: subObject Name,
control: mainObject Control,
subObject: {
id: abcd,
name: subObject Name,
control: subObject Control
}
}
/pre

The value of the same-named properties were all set to the values
found on the subObject.  It seems like there is some buggy
underlying implementation detail in ExternalInterface related to
maintenance of property names and values.  

Has anyone else had this problem before?  I am hoping we are just
doing something wrong, but I am out of code I can run a debugger on
(the corruption of property values is happening in core
ExternalInterface code).  I can verify the above quite explicitly by
debugging with Firebug and FlexBuilder on the two ends of the call.

The Flex-Ajax bridge seems buggy and if it uses ExternalInterface
internally I imagine it would have the same problems.  If we can't
figure this out we'll either need to build our own JSON
serialization/deserialization libraries or switch tech.  If Flex had
an eval capability deserializing JSON strings would be trivial but
unfortunately that method doesn't appear to be available.

Really appreciate any assistance, would be happy to provide additional
details if they are necessary.  If this is a bug, how have others
gotten past it through workarounds?

Joe



[flexcoders] Re: ExternalInterface Bug

2007-03-06 Thread gtuhl
There is a typo in my post.  The control property for subObject
should be named subObjectControl.  The purpose of it was to have a
differently named property to demonstrate that the issue is specific
to same-named properties.

Sorry about that,

Joe

--- In flexcoders@yahoogroups.com, gtuhl [EMAIL PROTECTED] wrote:

 I hope this isn't a bug and I am just doing something wrong.  The
 situation is we have an object that looks like this (JSON notation):
 
 pre
 mainObject = {
 id: 1234,
 name: mainObject Name,
 control: mainObject Control,
 subObject: {
 id: abcd,
 name: subObject Name,
 control: subObject Control
 }
 }
 /pre
 
 That is we have an object with a property that is another object type
 and both objects share some property names.
 
 When we route something like this through ExternalInterface I can
 verify the object is exactly as described above using Firebug on the
 JS side and remains that way right up through completion of the
 ExternalInterface call.
 
 Then immediately upon this object's arrival on the actionscript3 end
 it looks like this:
 
 pre
 mainObject = {
 id: abcd,
 name: subObject Name,
 control: mainObject Control,
 subObject: {
 id: abcd,
 name: subObject Name,
 control: subObject Control
 }
 }
 /pre
 
 The value of the same-named properties were all set to the values
 found on the subObject.  It seems like there is some buggy
 underlying implementation detail in ExternalInterface related to
 maintenance of property names and values.  
 
 Has anyone else had this problem before?  I am hoping we are just
 doing something wrong, but I am out of code I can run a debugger on
 (the corruption of property values is happening in core
 ExternalInterface code).  I can verify the above quite explicitly by
 debugging with Firebug and FlexBuilder on the two ends of the call.
 
 The Flex-Ajax bridge seems buggy and if it uses ExternalInterface
 internally I imagine it would have the same problems.  If we can't
 figure this out we'll either need to build our own JSON
 serialization/deserialization libraries or switch tech.  If Flex had
 an eval capability deserializing JSON strings would be trivial but
 unfortunately that method doesn't appear to be available.
 
 Really appreciate any assistance, would be happy to provide additional
 details if they are necessary.  If this is a bug, how have others
 gotten past it through workarounds?
 
 Joe





[flexcoders] Re: Flex 2 Compiler / Metadata Question

2007-02-16 Thread gtuhl
I've clarified the issue - posting so that if someone else runs into a
similar issue they can work around it.

In Flex Builder, the Additional compiler arguments field that is
available in Project-Properties-Flex Compiler is only applied when
the debug swf is built.  They are not applied for the non-debug swf
(or at least the keep-as3-metadata argument isn't).

This obviously is a bug, but it is a bug in Flex Builder specifically
and not in the Flex2 compiler or sdk.

If you want to use custom metadata in run mode you will have to build
your project with Ant.  I recommend using the new-ish Flex Ant tasks
even though they are quirky.  The additional problem with these is
that the mxmlc task doesn't support the keep-as3-metadata argument.  I
am guessing that a corresponding stub hasn't yet been included in the
Ant task to route the argument to mxmlc.

To get around this you will need to create a configuration file for
your project.  It might be named myProject-config.xml and might look
like this:

?xml version=1.0?
flex-config xmlns=http://www.adobe.com/2006/flex-config;
compiler
keep-as3-metadata
nameCollection/name
/keep-as3-metadata
keep-generated-actionscripttrue/keep-generated-actionscript
/compiler
/flex-config

Where Collection is the custom metadata tag we want to use in our
code.  You can put multiple name tags inside the keep-as3-metadata
tag.  Now instead of just having this in your mxmlc ant task:

load-config filename=${FLEX_HOME}/frameworks/flex-config.xml/

You will need this:

load-config filename=${FLEX_HOME}/frameworks/flex-config.xml/
load-config filename=myProject-config.xml/

It will first process the default config file and then bring in your
additional configuration information.

Let me know if I am mistaken with any of the above, but we are up and
running now with custom metadata.  We just develop in debug mode and
then use an Ant task to build and deploy a run mode swf to JBoss when
applicable.

Joe


--- In flexcoders@yahoogroups.com, gtuhl [EMAIL PROTECTED] wrote:

 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 flexcoders@yahoogroups.com, Ely Greenfield egreenfi@ wrote:
 
   
   
   
  I checked around internally

[flexcoders] Re: Html in Flex?

2007-02-13 Thread gtuhl
Hey, this sounds pretty cool.  I'll definitely give it a shot and let
you know how it goes.

--- In flexcoders@yahoogroups.com, dorkie dork from dorktown
[EMAIL PROTECTED] wrote:

 I have been secretly working on an html component for the last 2
months that
 is close to release. It has support for iframes but also support for
 straight html without iframes. I will be doing a beta in a few weeks and
 post a link to examples in the next couple of days. I've tested a
bunch of
 cool features (beta) but I can only work on about one more before
beta. So
 check my blog in the next few days http://www.judahfrangipane.com
and leave
 some good comments.
 
 On 1/10/07, gtuhl [EMAIL PROTECTED] wrote:
 
  We have an existing application that has a feature enabling a user to
  set content for and preview html newsletters.  We are in the process
  of researching Flex2 and determining whether the client-side of this
  application (currently xul/html/js) should be converted.
 
  Is there any way to render html in Flex2?  The htmlText property on
  Text won't cut it as it only supports a trivial subset of html.
 
  I essentially need to embed Gecko or another appropriate rendering
  engine so that the users can get a rough guess of what their content
  looks like.  The same pages allow the user to quickly send test
  e-mails to whichever accounts they desire, but the quick-preview
  feature provided by the current version of the application is heavily
  used and cannot be cut.
 
  Ideally Flex2 has something similar to the browser component in xul.
 
 
 
 
 
 
  --
  Flexcoders Mailing List
  FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
  Yahoo! Groups Links
 
 
 
 





[flexcoders] Re: Flex 2 Compiler / Metadata Question

2007-02-06 Thread gtuhl
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 flexcoders@yahoogroups.com, 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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of gtuhl
 Sent: Friday, February 02, 2007 6:08 AM
 To: flexcoders@yahoogroups.com
 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

[flexcoders] Re: Flex 2 Compiler / Metadata Question

2007-02-02 Thread gtuhl
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 flexcoders@yahoogroups.com, Tom Chiverton [EMAIL PROTECTED]
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.





[flexcoders] Flex 2 Compiler / Metadata Question

2007-02-01 Thread gtuhl
I had asked the original question here:

http://tech.groups.yahoo.com/group/flexcoders/message/62626

And received several helpful responses involving the ArrayElementType
metadata tag.  This works for the case of dealing with types of
objects in arrays, but doesn't resolve the more general question of
why does Flex2 throw out metadata information, and only allow
prevention of it being thrown out in debug mode?

Basically, we would like to use metadata much as Java 1.5 uses
annotations for a handful of scenarios.  This is entirely possible,
and works really well, but only if you use an obscure compiler flag,
and then only in debug mode.

Anyone have any ideas?



[flexcoders] Re: Flex2 Metadata / Compiler Options Question

2007-01-29 Thread gtuhl
That looks like it will do the trick for Arrays, thanks for the help. 

Anyone know why the compiler throws out metadata though?  There are
other situations in our code where we are marking up class definitions
to provide information to other code at runtime.

It seems rather odd that annotations (or something like it) are
completely supported and possible, but then prevented by some hidden
aspect of the compiler over which developers don't have control.  It
seems even stranger that compiler arguments can be used to make them
work in debug mode but not in run mode.

--- In flexcoders@yahoogroups.com, Tom Chiverton [EMAIL PROTECTED]
wrote:

 On Thursday 25 January 2007 12:46, gtuhl wrote:
  Does anyone have any idea for working around this? 
 
 http://livedocs.macromedia.com/flex/2/docs/1652.html#162732
 -- 
 Tom Chiverton
 Helping to preemptively optimize front-end ROI
 
 
 
 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.





[flexcoders] Flex2 Metadata / Compiler Options Question

2007-01-25 Thread gtuhl
I'll try to keep this brief and clear, bear with me and please request
additional information if it would help.  We came across a situation
in a very large Flex2 application where we wanted to know the types of
items inside of collections at runtime.  I can provide more details if
desired, but in short we are doing a lot of automatic detection of
object and property types to make a running locally on xml version
of the product work with very little pain and very little extra
configuration.

In Java 1.5, you can specify these types like this:

ListContactVO foo;

In Flex2, if you have something like this:

var foo : ArrayCollection;

There is obviously no way of discovering at runtime, by reading the
class definition, what types of objects are meant to be in that
ArrayCollection.

So we took advantage of the metadata construct in Flex2 to create a
sort of annotation, which would make the Flex2 example look like this:

[Collection(type=ContactVO)]
var foo : ArrayCollection;

Now by reading the metadata of the property foo, we are able to
determine at runtime both that foo is an ArrayCollection, and that it
is meant to contain ContactVO object instances.  This doesn't have the
Java benefit of actually enforcing the fact that only ContactVOs are
in the collection, but it at least allows us to make very useful
convention-based assumptions.

This is a pretty powerful option in my opinion, unfortunately Flex2
blindly throws out all metadata it doesn't understand.  Through some
google code searching, we were able to discover an obscure compiler
option that looks like this:

-keep-as3-metadata+=Collection

This option would then make it such that Flex does not throw out
[Collection] metadata.

The problem is, this compiler option only works in DEBUG mode.  In
debug mode all of our code affected by this works beautifully and
without fault (and would probably be a very useful tool to provide to
the community).  In RUN mode, it fails miserably.  In short, Flex2 is
ignoring these extra compiler options when not in DEBUG mode.  We are
no longer able to see the [Collection] metadata.

Does anyone have any idea for working around this?  We are using ANT
for our builds, and I can guarantee that the -keep-as3-metadata
compiler option is being used identically in all cases.  It simply
gets ignored in RUN mode, and Flex2 goes back to throwing out all
metadata it doesn't understand.





[flexcoders] Html in Flex?

2007-01-10 Thread gtuhl
We have an existing application that has a feature enabling a user to
set content for and preview html newsletters.  We are in the process
of researching Flex2 and determining whether the client-side of this
application (currently xul/html/js) should be converted.

Is there any way to render html in Flex2?  The htmlText property on
Text won't cut it as it only supports a trivial subset of html.

I essentially need to embed Gecko or another appropriate rendering
engine so that the users can get a rough guess of what their content
looks like.  The same pages allow the user to quickly send test
e-mails to whichever accounts they desire, but the quick-preview
feature provided by the current version of the application is heavily
used and cannot be cut.

Ideally Flex2 has something similar to the browser component in xul.






[flexcoders] Re: Html in Flex?

2007-01-10 Thread gtuhl
Yes it is just for display/preview.  My apologies if this is obvious,
fairly new to Flex2, but how do I use an IFrame?  The only
html-related bits I can find in the help system concerns the htmlText
property of text controls and iframe isn't listed as an understood tag.

I appreciate the quick response.

--- In flexcoders@yahoogroups.com, Jason Hawryluk [EMAIL PROTECTED] wrote:

 Would an iframe work for this? I mean is it just for display/preview not
 editing...
 
 jason
 
 -Message d'origine-
 De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la
 part de gtuhl
 Envoyé : mercredi 10 janvier 2007 21:34
 À : flexcoders@yahoogroups.com
 Objet : [flexcoders] Html in Flex?
 
 
 We have an existing application that has a feature enabling a user to
 set content for and preview html newsletters. We are in the process
 of researching Flex2 and determining whether the client-side of this
 application (currently xul/html/js) should be converted.
 
 Is there any way to render html in Flex2? The htmlText property on
 Text won't cut it as it only supports a trivial subset of html.
 
 I essentially need to embed Gecko or another appropriate rendering
 engine so that the users can get a rough guess of what their content
 looks like. The same pages allow the user to quickly send test
 e-mails to whichever accounts they desire, but the quick-preview
 feature provided by the current version of the application is heavily
 used and cannot be cut.
 
 Ideally Flex2 has something similar to the browser component in xul.