Using httpservice in Flex/Actionscripts passing XML file with only one item

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

I encountered a problem with passing xml file to Flex using Httpservice.
If the XML file I pass to the flex has only one item, e.g.:

<DATA>

<SoftwareName>Photoshop </SoftwareName>

</DATA>

Then if you use an arraycollection to save the data.

e.g.

[Bindable]
public var SoftwareData:ArrayCollection;

[Bindable] public var SoftwareData:ArrayCollection;

http://casario.blogs.com/mmworld/2006/07/arraycollection.html

<s:HTTPService id=”getSoftware” url=”{SoftwareServer}” result=”getSoftware_resultHandler(event)” fault=”getSoftware_faultHandler(event)”  />

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

if we use “SoftwareData=getSoftware.lastResult.DATA.Software; “, it will not work for only one item.

The solution is :

if(getSoftware.lastResult.DATA.Software==null)

{ Alert.show(“No record”); }

else if(getSoftware.lastResult.DATA.Software is ObjectProxy)

{ SoftwareData=new ArrayCollection([getSoftware.lastResult.DATA.Software]); }

else{SoftwareData=getSoftware.lastResult.DATA.Software as ArrayCollection; }

Reference:  from a guy called chunk

http://casario.blogs.com/mmworld/2006/07/arraycollection.html

Read More

Date arithmatic in Flex/Actionscripts

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Today I spent some time working on the date arithmetic. I don’t believe there is built-in Date arithmetic in Flex. Therefore, there probably only two solutions.

One is using DateUtils open source library: http://flexdateutils.riaforge.org/

The other one is converting date into milliseconds and then do deductions or additions.

public static const millisecondsPerMinute:int = 1000 * 60;
public static const millisecondsPerHour:int = 1000 * 60 * 60;
public static const millisecondsPerDay:int = 1000 * 60 * 60 * 24;
public static const millisecondsPerWeek:int = 1000 * 60 * 60 * 24*7;

var startDate:Date;
startDate = new Date(dateNow.getTime() – (millisecondsPerHour));
Note here, if we set millisecondsPerWeek to 1000 * 60 * 60 * 24*30, if will exceed the maximum value of a int number!(2^31)-1, which is 2,147,483,647 !

Read More