[flexcoders] Re: int not serializing properly from Java to ActionScript

2007-02-13 Thread lepusmars
Try changing getID to getId and setID to setId.

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

 I'm properly retrieving a result set from my database, but the
 serialization from Java to ActionScript screws up my id field along
 the way.
 
 --
 
 My Java VO:
 
 public class TestVO {
 
   private int id;
   private String data;
 
   public TestVO() { }
 
   public TestVO(int id, String data) {
 this.id = id;
 this.data = data;
   }
 
   public getID() { return id; }
 
   public setID(int id) { this.id = id; }
 
   public getData() { return data; }
 
   public setData(String data) { this.data = data; }
 
 }
 
 ---
 
 My ActionScript VO:
 
 public class TestVO {
 
   public var id:int;
   public var data:String;
 
 }
 
 
 
 ActionScript outputting the data (the ArrayCollection of my TestVO's
 are bound to a list with the following renderer:
 
 ?xml version=1.0 encoding=utf-8?
 mx:HBox xmlns:mx=http://www.adobe.com/2006/mxml;
 
   mx:Script
 ![CDATA[
   import mx.events.FlexEvent;
 
   import test.vo.TestVO;
 
   private var vo:TestVO;
 
   [Bindable]
   private var str:String;
 
   override public function set data(val:Object):void {
  if(val != null) {
super.data = val;
vo = val as TestVO;
str = vo.id +   + vo.data;
  }
  dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
   }
 ]]
   /mx:Script
 
   mx:Label text={str} /
 
 /mx:HBox
 
 When displaying the data in a list I see data field properly, but
 every id displays as 0 in Flex.  I've output the records on a JSP page
 which uses the same DAO, and the records output properly, so I know
 it's getting out of the database properly.
 
 Any suggestions?





[flexcoders] Re: Cross domain confusion

2007-02-13 Thread lepusmars
Under Flex Compiler in the project properties, there is an HTML
wrapper section.  uncheck all the boxes and most if not all of those
extra files will no longer be required. The debug files do not need to
be deployed and probably should not be deployed with the application.

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

 Matt, thanks so much that is what I figured it had to be something  
 simple.
 
 Now is there any way to that the .swf can be distributed by itself.   
 Right now the onlyway it works is to send out the entire bin folder,  
 with the .AC_OETags.js, history.js and debug files included?
 
 This is great news, I was really worried I was going to have to  
 recommend that we continue with VB instead of switching to flexbuilder.
 
 john
 



[flexcoders] Re: Can I use mx:Image to load images dynamically from an image.cfm page?

2007-02-13 Thread lepusmars
if you go to umage.cfm in a web browser does the image appear?  Are
you setting the ContentType header on the response correctly?

I've found the Image component to be very difficult to debug myself,
but those are places I would start.

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

 Our flex developer recently left our company, and I've been given the
 task of resuming work on an enormous project he was involved in. 
 Right now, I'm trying to do something where I display a tile list of
 images depending on the results from a database query returned by a
 call to a method in a CFC.
 
 I've written a coldfusion page called image.cfm that can take a URL
 parameter (the ID of the image from the database), retrieve the file
 from our filesystem, and simulate the content of the image by doing a
 cfcontent to spit out the binary data of the image.  This is
 obviously handy, because I don't need to know the location of any of
 the image files on my fileserver.  I can simply request
 image.cfm?id=12345 and the ColdFusion page will handle the rest,
 returning the image with ID 12345.  This works beautifully on our web
 site.
 
 The problem I'm having now is that I'm trying to implement something
 similar using Flex.  Each time I try, Flex only displays a broken
 image.  As I was trying to figure this out, I broke things down to as
 simple as I could make them.  I created a sample image called
 test.jpg.  I also modified image.cfm so that it only loads test.jpg. 
 When I navigate directly to image.cfm with my web browser
 
 http://myserver.com/image.cfm
 
 It displays the image just exactly as I'd expect it to.  However, when
 I run my Flex application with the following code:
 
 mx:Image x=0 y=0 source=image.cfm/
 mx:Image x=100 y=0 source=test.jpg/
 
 The second mx:Image displays just fine, but the first one does not.
 
 
 Does anyone know if it's possible to do something like this from
 inside Flex?  I'm very new to Flex, but not to development in general.
  I'd appreciate any information you might have.  Thanks!





[flexcoders] Re: should i convert pngs to jpegs before embedding them in a flash movie?

2007-02-13 Thread lepusmars
The SWF compiler when it embeds them should be flattening them. The
Fireworks PNG files are layered, but the Flash Player does not support
layered PNGs.  If I recall correctly the Fireworks PNG files have a
composite layer that is rendered by default and the swf compiler
simply pulls in that layer and discards the rest.  I could be wrong,
it has been a while (6-9 months) since I've used Fireworks, I'm a
photoshop guy.

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

 
  There is no reason to switch to JPEG, unless you like degraded pixel-
 based images.
 
 
 Ok but I'm using unflatted fireworks PNGs that are very large in file 
 size.  Will they compress upon being loaded into the SWF or do I need 
 to compress them before embedding them?





[flexcoders] Re: should i convert pngs to jpegs before embedding them in a flash movie?

2007-02-13 Thread lepusmars
What I mean is the Flash Player only displays the composite layer, all
other layers are discarded.  If you are loading png files directly
rather than embeding them  then you should flatten them.  But if you
Embed them in the swf then the compiler does the work of stripping out
the extra layers.

And of course you never lost data, the player can't alter your source
files.

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

 The SWF compiler when it embeds them should be flattening them. The
 Fireworks PNG files are layered, but the Flash Player does not support
 layered PNGs. 
  
 yes it does.  We have a Flash 8 app that shows layered Fireworks .pngs
 just fine.  We even open the graphics back up in Fireworks, make edits,
 save back to the server, load in Flash, and repeat.  Never lost any data
 doing that (though the files are huge).
  
 
 Jason Merrill 
 Bank of America
 Learning  Organizational Effectiveness





[flexcoders] Re: Propogating exception info from Web Service to Flex

2007-02-13 Thread lepusmars
throw new XFireFault(Fault String, XFireFault.SENDER);

This is how we do it. There are also methods for adding more details
to the Exception that get passed on the response.  Check out the
javadoc for more details.
http://envoisolutions.com/xfire/api/org/codehaus/xfire/fault/XFireFault.html

pd

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

 Does anybody has an example (using XFire WS implementation but really
 any similar env would be helpful too) how to properly pass exception
 information from web services to flex and make sure that fault
 handler receives faultDetail/faultString populated with meaningful
 data (some application specific error code/messages)?
 
 Thanks
 rd





[flexcoders] Re: Trouble Converting java List to ArrayCollection

2007-02-12 Thread lepusmars
I have to disagree about not throwing the Exception.  If you actually
handle the exception in the method then you shouldn't throw it, but
the exception is not being handled. The user needs to know that
something went wrong. And the bit about the Higher scope not importing
the DAOException, that's just plain wrong.  The higher scope will see
it as an Exception if it doesn't handle the specific Exception. Not
throwing the exception will simply return an empty list.

The real question is what is the Exception that is being thrown in the
try block?  That will tell us what the issue is and lead us to the
conclusion as to how to fix it.  Is there a Stack Trace available that
I can look at?

Also...
  vo.id = rs.getInt(id);
  vo.data = rs.getString(data);
... this is bad from. You shouldn't be accessing data members
directly, they should be encapsulated, and you should access them
using accesser methods.

Paul


--- In flexcoders@yahoogroups.com, André Rodrigues Pena
[EMAIL PROTECTED] wrote:

 Man.. Just remove the throws of your getList() method. Never use
throws at a
 service method. (specially in this example where the throws is USELESS
 because you are already treating the exception with the try clause) The
 throws clause passes the exception treatment to a higher scope, this
scope
 may not import de DAOException needed to process it properly. Simply
never
 do this.
 
 On 2/12/07, ytseshred [EMAIL PROTECTED] wrote:
 
I'm using RemoteObjects to connect to my backend. In one of my calls
  I'm trying to return a List of VO's I create after hitting my
database.
 
  On the Flex side, my result event is firing properly, but when I try
  to convert the result to an ArrayCollection, instead of getting a
  proper ArrayCollection I get single element that displays the
  following when I output it in an alert: obj is: '[object TestVO],
  [object TestVO], ... [object TestVO]'.
 
  If I return a single TestVO object directly instead of a List, I can
  properly cast the result to my ActionScript TestVO object and view the
  data properly. It's just returning the List that's giving me problems.
 
  Can anyone offer any suggestions please?
 
  My Flex result code is:
 
  public function result(evt:Object):void {
  if(evt.type  evt.type == ResultEvent.RESULT) {
  var re:ResultEvent = evt as ResultEvent;
  var col:ArrayCollection = new
  ArrayCollection(ArrayUtil.toArray(re.result));
  if(col) {
  Alert.show(obj is: ' + col.getItemAt(0) + ');
  }
  else Alert.show(Didn't cast properly!);
  }
  }
 
  My Java DAO code that returns the list is:
 
  public List getList() throws DAOException {
  List list = new ArrayList();
  Connection c = null;
 
  try {
  c = ConnectionHelper.getConnection();
  Statement s = c.createStatement();
  ResultSet rs = s.executeQuery(SELECT * FROM test);
  while(rs.next()) {
  TestVO vo = new TestVO();
  vo.id = rs.getInt(id);
  vo.data = rs.getString(data);
  list.add(vo);
  }
  } catch(Exception e) {
  e.printStackTrace();
  throw new DAOException(e);
  } finally {
  ConnectionHelper.close(c);
  }
  return list;
  }
 
   
 
 
 
 
 -- 
 André Rodrigues Pena
 
 LOCUS
 www.locus.com.br
 
 Blog
 www.techbreak.org





[flexcoders] Re: Trouble Converting java List to ArrayCollection

2007-02-12 Thread lepusmars
Another way is:

if(re.result is ArrayCollection) {
var col:ArrayCollection = ArrayCollection(re.result);
}

The as operation is more brief but accomplishes the same thing.  as
will leave your object as null, where as doing the is check you can
catch potential errors and not create any unnecessary objects. I don't
think either way is more right or wrong. 


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

 That was a typo on my Part.  They are being set using methods:
 
 TestVO vo = new TestVO();
 vo.setID(rs.getInt(id));
 vo.setData(rs.getString(data));
 
 The problem has been solved by casting the result to ArrayCollection
 using the as keyword.
 
 I'm not sure what was causing my first problem, but I originally had
 my VO's defined with constructors, so I could create the VO like:
 
 TestVO vo = new TestVO(rs.getInt(id), rs.getString(data));
 
 But Flex gave a runtime error when it was constructing the array
 collection saying something like TestVO init expected 2 arguments and
 got 0.
 



[flexcoders] Re: Trouble Converting java List to ArrayCollection

2007-02-12 Thread lepusmars
I think you misinterpreted, the TestVO is a java class.  Coding it
correctly should not affect the Flex versions of the class.  When the
bean is transfered to Flex it will contain publicly accessable
properties representing the private members that have public getters,
ie if you have getData there will be a property data on the transfered
object.  That is how Java Beans work.  If this convention is not
followed then if you start working with Enterprise level projects you
run into problems.

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

 Flex wants a public constructor with no arguments available, so the 
 solution is to just add your second constructor with whatever 
 arguments you want while keeping the default constructor.  That 
 would make both of the folowing valid:
 
  TestVO vo = new TestVO();
  TestVO vo = new TestVO(rs.getInt(id), rs.getString(data));
 
 It may arguably be bad form to access data members directly, but 
 strict adherence to good Java form in value objects just leads to 
 problems on the Flex side.  If, for example, you went the full route 
 and declared your data members private to force the use of accessor 
 methods, your Flex object would contain no properties since Flex 
 would have no visibility to the private members.  I usually just let 
 it slide, and create a Java good form wrapper object if I must for 
 accessing on the server side.
 
 Doug
 
 --- In flexcoders@yahoogroups.com, ytseshred ytseshred@ wrote:
 
  That was a typo on my Part.  They are being set using methods:
  
  TestVO vo = new TestVO();
  vo.setID(rs.getInt(id));
  vo.setData(rs.getString(data));
  
  The problem has been solved by casting the result to 
 ArrayCollection
  using the as keyword.
  
  I'm not sure what was causing my first problem, but I originally 
 had
  my VO's defined with constructors, so I could create the VO like:
  
  TestVO vo = new TestVO(rs.getInt(id), rs.getString(data));
  
  But Flex gave a runtime error when it was constructing the array
  collection saying something like TestVO init expected 2 arguments 
 and
  got 0.
  



[flexcoders] Re: xml-rpc

2007-02-12 Thread lepusmars
I had started working on one recently, but it's not ready for general
use yet.  If you don't find another I will forward you mine once it's
ready for third party testing.

Paul


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

 Does anyone know of an xml-rpc class or package for AS3? I found this  
 one: http://www.hrum.org/people/debedb/pro/blog/2006/12/ 
 xmlrpc_in_flex_2actionscript_3_1.html however, I cannot seem to get  
 it to work. XML-RPC from flex would be the ultimate solution for me.  
 Does any one know of any solutions? I don't think I could write this  
 myself, and amf - service - xml-rpc does not seem like a very  
 desirable option.
 
 Thanks in advance,





[flexcoders] Re: Trouble Converting java List to ArrayCollection

2007-02-12 Thread lepusmars
--- In flexcoders@yahoogroups.com, Doug Lowder [EMAIL PROTECTED] wrote:

 Nope, I didn't misinterpret.  I know TestVO is a Java class 
 (probably with a Flex counterpart class), and the way the Java class 
 is coded can definitely have an effect when it is accessed from 
 Flex.  It isn't a case of correctness, but a case of what Flex 
 expects from Java classes.  You can test this all out yourself by 
 implementing multiple constructors and/or declaring the properties 
 as private in your Java class.
 

Ok, I hate that I keep dragging this out but I also don't like when
people promote bad coding conventions. Here is a simple example java
bean, taken from Adobe.

package flex.testdrive.store;

public class Product {

private int productId;
private String name;
private String description;
private String image;
private String category;
private double price;
private int qtyInStock;

public Product() {

}

public Product(int productId, String name, String description,
String image, String category, double price, int qtyInStock) {
this.productId = productId;
this.name = name;
this.description = description;
this.image = image;
this.category = category;
this.price = price;
this.qtyInStock = qtyInStock;
}

public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public int getQtyInStock() {
return qtyInStock;
}
public void setQtyInStock(int qtyInStock) {
this.qtyInStock = qtyInStock;
}

}

You see all of the properties are private with public getters and
setters.  When the Flex Data Services transfers the object to the
Flash Player it has all of the expected properties. This is proper,
correct and safe coding. Adobe even recommends this kind of coding
in ActionScript, which is why you use the set and get methods.

Paul





[flexcoders] Re: Flex Coding Guidelines

2007-02-11 Thread lepusmars
I agree, a very interesting read, but one thing I have to disagree
with and bothers me a lot that Flex Builder does this when it creates
classes.  Close curly braces in its own line at the same position in
which the open curly brace is... nothing bothers me more than a curly
brace on it's own line, I think it makes code less readable and
contributes to excessive scrolling when editing and reviewing code. 
Oh and curly braces on case statements is weird, but actually a good
convention... that will take some relearning to work into my code.

For the most part I like what you have, I'd like to use it as a
starting point for my own organization. I think I've come from a
different wing of the java development community, since there is a lot
that bucks my own traditions.

Paul

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

 Hi Fabio
 
 I think it is a good document, beside the whitespace paragraphs.
 Distribution of whitespace is always worth a discussion :)
 
 There is only one thing, that makes me wonder.
 If methods should start with a verb, why don't you prefer
 handleMouseClick() over mouseClickHandler() ?
 
 Cheers,
 Ralf.
 
 
 On 2/10/07, Fabio Terracini [EMAIL PROTECTED] wrote:
 
Folks,
 
  As my commitment to community I'm releasing, with DClick support, our
  Adobe Flex Coding Guidelines, a document about Flex (MXML and
  ActionScript) coding conventions that we use on a regular basis.
 
  The objective is clear: provide a common and consistent language to
  help code comprehension between developers. The practices established
  in this document are based on Java conventions, Flex 2 SDK and DClick
  team experience (including myself).
 
  By releasing this document, the idea is to help the community improve
  their Flex code by using coding conventions as well and hear feedback
  from community to continuously improve this document, that by now is a
  community asset.
 
  I'll be happy to have volunteers to form a committee or something to
  evolve this project further.
 
  This way, comments on this document (including the best practices) are
  very welcome! Involve yourself in this flexcoders thread, at the
  flexdev (listaflexdev.org - portuguese list on Flex) or at DClick
  weblog
(http://blog.dclick.com.br/2007/02/10/adobe-flex-coding-guidelines/
  )
 
  English version:
 
 
http://blog.dclick.com.br/wp-content/uploads/adobe-flex-coding-guidelines-v12-english.pdf
 
  Portuguese version:
 
 
http://blog.dclick.com.br/wp-content/uploads/adobe-flex-coding-guidelines-v12-portugues.pdf
 
  Thanks,
  Fabio Terracini
   
 
 
 
 
 -- 
 Ralf Bokelberg [EMAIL PROTECTED]
 Flex  Flash Consultant based in Cologne/Germany
 Phone +49 (0) 221 530 15 35





[flexcoders] Re: Flex Coding Guidelines

2007-02-11 Thread lepusmars
I've seen more Java developers do it they way proposed with the curly
braces on the next line. It's always bothered me... I'm an old dog I
guess (actually I'm only 30), and a bit Obsessive Compulsive.


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

   I think it makes code less readable and
 
 Oh lets all agree to disagree on this one.
 
 Which side do you butter your bread? On the top or bottom, what???
On the
 sides!!! ?
 
 I can't stand curly braces on the method line, doesn't allow a space
from
 the method signature to fully read and seems cramped to me.
 
 But that is my point, you will never get people to agree on spaces,
braces
 and whatever else developers have a habit doing.
 
 ... Just because Java / C++ does it, doesn't mean its right. Things
always
 evolve.
 
 just kidding, maybe.
 
 Peace, Mike
 



[flexcoders] Re: TextInput - Incorrect focus behavior

2007-02-10 Thread lepusmars
Use a StringValidator that enables or disables fields based on the
validity of the field in question.  I use it all the time for forms
where the submit button is disabled until all required fields are
valid.  I think using the focus/blur events are the wrong way to go
about it. 

mx:StringValidator source={this.zipCodeInput} property=text
minLength=1 valid=this.phoneNumberInput.enabled=true;
invalid=this.phoneNumberInput.enabled=false; /


Paul


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

 
 Thanks for responding - TextInput does not have a property selectable
 ...
 
 My intention is that I don't want the user to be able to leave the field
 until a certain value has been entered.
 
 
 --- In flexcoders@yahoogroups.com, superstella_uk superstella_uk@
 wrote:
 
  --- In flexcoders@yahoogroups.com, acooleagle acooleagle@ wrote:
 
  Cant you just set the TextField.selectable = false ?
 
  
  
   Hi all,
  
   Seems to me that focus events in TextInputs are a bit out of whack.
  
   The test application below should never allow focus on the
   phoneNumberInput field, since its focusIn event immediately
 redirects
   focus back to the zipcodeInput field.
  
   However, the zipCodeInput field remains active (as indicated by
 the
   blue highlight) the phoneNumberInput retains the prompt (!!).
  
   This is a major problem for us as we would like the focus and the
 prompt
   to stay in the active field on occasions where the content of the
 field
   is invalid.
  
   As far as I am concerned this weird focus/prompt behavior is a bug.
  
   $5 million question now is : does anybody know a workaround?
  
   Thanks for all feedback,
  
   = Dirk
  
  
  
   ?xml version=1.0?
   mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;
  
mx:Form
mx:TextInput id=zipCodeInput /
mx:TextInput id=phoneNumberInput
   focusIn=zipCodeInput.setFocus() /
/mx:Form
  
   /mx:Application