tag:blogger.com,1999:blog-24059059926587298592024-03-13T14:36:44.412-07:00Adobe flex and J2EEsajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2405905992658729859.post-69508856758240756272012-06-07T16:32:00.000-07:002012-06-07T16:32:33.116-07:00Rounding a Decimal number to a given precision in Action sript<div dir="ltr" style="text-align: left;" trbidi="on">
I found the below blog very useful for this problem<br />
<a href="http://chrispaddison.com/flex/rounding-numbers-to-decimal-places-in-actionscript-3/">Truncating and Rounding Numbers in ActionScript 3</a><br />
<br />
will also write something about it later</div>sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com0tag:blogger.com,1999:blog-2405905992658729859.post-59219066421758410912012-06-07T15:49:00.004-07:002012-06-07T16:33:50.271-07:00Setting all the dates before today as unsetectable in Date Field<div dir="ltr" style="text-align: left;" trbidi="on">
If you want to have a date field where user is allowed to only select either today or any date after today you will have to use the disabledRanges property of Date filed like being used in the example below<br />
<br />
<br />
<mx:DateField id="startDateForRAC" yearNavigationEnabled="true"<br />
<br />
change="dateChanged(DateField(event.target).selectedDate)" width="91"<br />
disabledRanges="{[ {rangeEnd: new Date(new Date().getFullYear(),new Date().getMonth(),new Date().getDate()-1)} ]}" <br />
selectedDate="{new Date(today.getFullYear(), today.getMonth(), today.getDate())}" /><br />
<br />
Note that only rangeEnd will be used to have a similar date field.</div>sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com0tag:blogger.com,1999:blog-2405905992658729859.post-32697632038577249522012-05-22T02:32:00.002-07:002012-05-23T05:56:29.507-07:00Changing the state of a check box by setting selected property to true will not call the change event<div dir="ltr" style="text-align: left;" trbidi="on">
Strange , but I was assuming that if I set the "selected" property of a CkeckBox in flex it will call the change event :) but it wont. Below is an example<br />
<br />
<pre></pre>
<pre> </pre>
<pre><?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" </pre>
<pre>layout="absolute" creationComplete="init()">
<mx:Script>
< ![CDATA[
import mx.controls.Alert;
function checkBoxClicked():void{
Alert.show("Check box clicked");
}
function init():void{
//cb.selected=true;
cb.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
]] >
</mx:Script>
<mx:CheckBox x="93" y="43" id="cb" label="Checkbox"</pre>
<pre> change="checkBoxClicked()"/>
</mx:Application> </pre>
<pre> </pre>
<pre></pre>
<mx:application creationcomplete="init()" layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml"><mx:checkbox change="checkBoxClicked()" id="cb" label="Checkbox" x="93" y="43"></mx:checkbox></mx:application><br />
<br />
<br />
this didn't work , than I had to change the "init" function like below<br />
<br />
function init():void{<br />
cb.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); <br />
}<br />
<br />
Note now I am pragmatically calling the mouse click event and to my surprise it worked , that's not good or am I missing something?<br />
<br />
So Let's start looking in to the API documentation which states<br />
<br />
<table cellpadding="0" cellspacing="0" class="detailHeader"><tbody>
<tr><td class="detailHeaderName"><h2>
change</h2>
</td><td class="detailHeaderType">Event </td><td class="detailHeaderRule"></td></tr>
</tbody></table>
<div class="detailBody">
<span class="label">Event Object Type: </span><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html"><code>flash.events.Event</code></a><br />
<span class="label">property Event.type = </span><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/Event.html#CHANGE"><code>flash.events.Event.CHANGE</code></a><br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td style="white-space: nowrap;" valign="top"><b>Language Version: </b></td><td>ActionScript 3.0</td></tr>
</tbody></table>
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td style="white-space: nowrap;" valign="top"><b>Product Version: </b></td><td>Flex 3</td></tr>
</tbody></table>
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr><td style="white-space: nowrap;" valign="top"><b>Runtime Versions: </b></td><td>Flash Player 9, AIR 1.1</td></tr>
</tbody></table>
Dispatched when the <code>selected</code> property
changes for a toggle Button control. A toggle Button control means that the
<code>toggle</code> property is set to <code>true</code>.
For the RadioButton controls, this event is dispatched when the <code>selected</code>
property changes.<i><b>
For the CheckBox controls, this event is dispatched only when the
user interacts with the control by using the mouse.
</b></i></div>
<br />
This is really strange but this is how things work in ActionScript.<br />
<br />
<br />
<br /></div>sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com2tag:blogger.com,1999:blog-2405905992658729859.post-69463082881412391312012-05-16T02:58:00.002-07:002012-05-16T02:58:20.880-07:00Calling The MouseClick Event Programetically UsingAction Script<div dir="ltr" style="text-align: left;" trbidi="on">
<code>Let's say you have a button call myButton , you can use below line to call the Mouse Click or "click" event in Action Script</code><br />
<code><br /></code><br />
<code>myButton.dispatchEvent(new MouseEvent(MouseEvent.CLICK));</code></div>sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com0tag:blogger.com,1999:blog-2405905992658729859.post-17687417976888679822011-05-11T00:21:00.000-07:002012-05-23T05:55:50.961-07:00Flex Date Problem<div dir="ltr" style="text-align: left;" trbidi="on">
If you don't already know than there is a difference between American and British date formats<br />
<b>American is (Or American preferred Date format)</b>mm/dd/yyyy (like 9/11/2003 or 9.1.2003)<br />
<b>While the British preferred date format is</b>dd/mm/yyyy (like 11/9/2003 or 11.9.2003)<br />
<br />
In Flex when you are creating a Date object by passing it the date String and if mistakenly you pass it date in British format it might show you unpredictable results, below is an example<br />
<b>Alert.show(new Date('15/11/2011').toDateString());</b>will give you following date<br />
<b>Sun Mar 11 2012</b>Of course this is not the date you wanted, and this is because flex was expecting data to be provided as mm/dd/yyyy but the data you provided was dd/mm/yyyy and surprisingly in this case flex will convert it into a wrong date.<br />
So be carefull when you are supplying dates to Date class of action script and always make sure the date you are passing to it is in mm/dd/yyyy otherwise you will see unexpected results.<br />
<br />
To understand my point here is another example<br />
7/12/06, in American format , is July 12th, 2006 = 12 July 2006<br />
7/12/06, In British format, is 7th December 2006 = 7 December 2006</div>sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com0tag:blogger.com,1999:blog-2405905992658729859.post-13301631777347602662009-04-28T02:38:00.000-07:002009-04-28T04:00:16.803-07:00Development in Flex and J2EEI will share my experience in flex here , Those who just have started flex they can see a very good two article series at javajavaworld for getting started in flex<br /><br /><a href="http://www.javaworld.com/javaworld/jw-01-2009/jw-01-javaee-flex-1.html?page=1">http://www.javaworld.com/javaworld/jw-01-2009/jw-01-javaee-flex-1.html?page=1</a><br /><br /><a href="http://www.javaworld.com/javaworld/jw-02-2009/jw-02-javaee-flex-2.html">http://www.javaworld.com/javaworld/jw-02-2009/jw-02-javaee-flex-2.html</a><br /><br />well i will keep updating this blog in future.sajjad parachahttp://www.blogger.com/profile/09656212868317790693noreply@blogger.com0