<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jiramot.info &#187; flex</title>
	<atom:link href="http://www.jiramot.info/tag/flex/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jiramot.info</link>
	<description>me?.note.each{ println it }</description>
	<lastBuildDate>Fri, 30 Jul 2010 19:57:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex printing using FlexPrintJob</title>
		<link>http://www.jiramot.info/flex-printing-using-flexprintjob</link>
		<comments>http://www.jiramot.info/flex-printing-using-flexprintjob#comments</comments>
		<pubDate>Sat, 16 Jan 2010 03:49:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=482</guid>
		<description><![CDATA[วันนี้ว่างๆ ก็เลยนั่งลองหาดูว่า Flex มันติดต่อเครื่องพิมพ์ได้อย่างไร ก็เลยไปเจอเข้าว่ามันใช้ FlexPrintJob ในการทำงาน คล้ายๆกับ Java เลยที่ใช้ PrintJop แล้วก็ Draw Graphic ลงไปเอา
ส่วน FlexPrintJob ก็คล้ายๆกัน แต่เอา Component ยัดลงไปได้เลย

 Create an instance of the FlexPrintJob class

var printJob:FlexPrintJob = new FlexPrintJob();

Start the print job:

printJob.start();

Add one or more objects to the print job and specify how to scale them:

printJob.addObject(myObject, FlexPrintJobScaleType.MATCH_WIDTH);

Send the print job to the printer:

printJob.send();

Free [...]]]></description>
			<content:encoded><![CDATA[<p>วันนี้ว่างๆ ก็เลยนั่งลองหาดูว่า Flex มันติดต่อเครื่องพิมพ์ได้อย่างไร ก็เลยไปเจอเข้าว่ามันใช้ FlexPrintJob ในการทำงาน คล้ายๆกับ Java เลยที่ใช้ PrintJop แล้วก็ Draw Graphic ลงไปเอา</p>
<p>ส่วน FlexPrintJob ก็คล้ายๆกัน แต่เอา Component ยัดลงไปได้เลย</p>
<ol>
<li> Create an instance of the FlexPrintJob class</li>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">var printJob:FlexPrintJob = new FlexPrintJob();</pre></div></div>

<li>Start the print job:</li>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">printJob.start();</pre></div></div>

<li>Add one or more objects to the print job and specify how to scale them:</li>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">printJob.addObject(myObject, FlexPrintJobScaleType.MATCH_WIDTH);</pre></div></div>

<li>Send the print job to the printer:</li>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">printJob.send();</pre></div></div>

<li>Free up any unneeded objects.</li>
</ol>
<p><span id="more-482"></span><br />
ตัวอย่างคับ</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- printing\DGPrint.mxml --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">            import mx.printing.*;</span>
&nbsp;
<span style="color: #339933;">            // Create a PrintJob instance.</span>
<span style="color: #339933;">            private function doPrint():void {</span>
<span style="color: #339933;">                // Create an instance of the FlexPrintJob class.</span>
<span style="color: #339933;">                var printJob:FlexPrintJob = new FlexPrintJob();</span>
&nbsp;
<span style="color: #339933;">                // Start the print job.</span>
<span style="color: #339933;">                if (printJob.start() != true) return;</span>
&nbsp;
<span style="color: #339933;">                // Add the object to print. Do not scale it.</span>
<span style="color: #339933;">                printJob.addObject(myDataGrid, FlexPrintJobScaleType.NONE);</span>
&nbsp;
<span style="color: #339933;">                // Send the job to the printer.</span>
<span style="color: #339933;">                printJob.send();</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:VBox</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myVBox&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGrid</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myDataGrid&quot;</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;300&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:dataProvider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Object</span> <span style="color: #000066;">Product</span>=<span style="color: #ff0000;">&quot;Flash&quot;</span> <span style="color: #000066;">Code</span>=<span style="color: #ff0000;">&quot;1000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Object</span> <span style="color: #000066;">Product</span>=<span style="color: #ff0000;">&quot;Flex&quot;</span> <span style="color: #000066;">Code</span>=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Object</span> <span style="color: #000066;">Product</span>=<span style="color: #ff0000;">&quot;ColdFusion&quot;</span> <span style="color: #000066;">Code</span>=<span style="color: #ff0000;">&quot;3000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Object</span> <span style="color: #000066;">Product</span>=<span style="color: #ff0000;">&quot;JRun&quot;</span> <span style="color: #000066;">Code</span>=<span style="color: #ff0000;">&quot;4000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:dataProvider<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGrid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;myButton&quot;</span> </span>
<span style="color: #009900;">            <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Print&quot;</span> </span>
<span style="color: #009900;">            <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;doPrint();&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:VBox<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>source <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=printing_3.html">http://livedocs.adobe.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/flex-printing-using-flexprintjob/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Callback Function</title>
		<link>http://www.jiramot.info/flex-callback-function</link>
		<comments>http://www.jiramot.info/flex-callback-function#comments</comments>
		<pubDate>Thu, 14 Jan 2010 11:31:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=480</guid>
		<description><![CDATA[
  public function firstFunction():void{
    trace(&#34;call first function&#34;)
  }
  public function secondFunction(callbackFunction:Function):void{
    trace(&#34;call second function&#34;)
    callbackFunction()
  }
  public function thirdFunction():void{
    trace(&#34;call third function&#34;)
  }

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">  public function firstFunction():void{
    trace(&quot;call first function&quot;)
  }
  public function secondFunction(callbackFunction:Function):void{
    trace(&quot;call second function&quot;)
    callbackFunction()
  }
  public function thirdFunction():void{
    trace(&quot;call third function&quot;)
  }</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/flex-callback-function/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate Data in DataGrid</title>
		<link>http://www.jiramot.info/validate-data-in-datagrid</link>
		<comments>http://www.jiramot.info/validate-data-in-datagrid#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:34:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=477</guid>
		<description><![CDATA[
itemEditBegin – Fired when you click on an editable cell of the datagrid (also when the editedItemPosition is set on an editable DataGrid)
itemEditBeginning &#8211; Fired when the mouse is released
itemEditEnd &#8211; Fired when the edit is committed / editor is destroyed there by terminating the edit session.


1
2
3
4
5
6
7
8
9
    &#60;mx:DataGrid editable=”true” id=”datagrid” x=”105″ y=”85″ [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
itemEditBegin – Fired when you click on an editable cell of the datagrid (also when the editedItemPosition is set on an editable DataGrid)</p>
<p>itemEditBeginning &#8211; Fired when the mouse is released</p>
<p>itemEditEnd &#8211; Fired when the edit is committed / editor is destroyed there by terminating the edit session.
</p></blockquote>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGrid</span> <span style="color: #000066;">editable</span>=”true” <span style="color: #000066;">id</span>=”datagrid” <span style="color: #000066;">x</span>=”105″ <span style="color: #000066;">y</span>=”85″ <span style="color: #000066;">height</span>=”176″ <span style="color: #000066;">width</span>=”317″ <span style="color: #000066;">dataProvider</span>=”<span style="color: #66cc66;">&#123;</span>arr<span style="color: #66cc66;">&#125;</span>” <span style="color: #000066;">itemEditEnd</span>=”doValidation<span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span>”<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=”Data” <span style="color: #000066;">dataField</span>=”disp” <span style="color: #000066;">editable</span>=”false”<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=”Available” <span style="color: #000066;">dataField</span>=”value” <span style="color: #000066;">editable</span>=”false”<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;">&lt;!– itemEditor is set to our class CustomNumericStepper. Always remember to set the editorDataField to the dataField on which the operation is performed–<span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:DataGridColumn</span> <span style="color: #000066;">headerText</span>=”Order Qty” <span style="color: #000066;">dataField</span>=”order” <span style="color: #000066;">itemEditor</span>=”CustomNumericStepper” <span style="color: #000066;">editorDataField</span>=”value”<span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:columns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:DataGrid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>source <a href="http://blog.flexgeek.in/2007/05/tips-tricks-itemeditors-ii/">http://blog.flexgeek.in</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/validate-data-in-datagrid/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a view cursor on an ArrayCollection in Flex</title>
		<link>http://www.jiramot.info/creating-a-view-cursor-on-an-arraycollection-in-flex</link>
		<comments>http://www.jiramot.info/creating-a-view-cursor-on-an-arraycollection-in-flex#comments</comments>
		<pubDate>Tue, 12 Jan 2010 07:35:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=472</guid>
		<description><![CDATA[ปกติเวลาจะหา data จาก ArrayCollection ก็จะวนลูปแล้ว if เอา วันนี้เล่นเน็ตไปมาเลยไปเจอว่าเค้าทำกันแบบนี้ได้

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;!-- http://blog.flexexamples.com/2008/04/15/creating-a-view-cursor-on-an-arraycollection-in-flex/ --&#62;
&#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34;
        layout=&#34;vertical&#34;
        verticalAlign=&#34;middle&#34;
        backgroundColor=&#34;white&#34;
        creationComplete=&#34;init();&#34;&#62;
&#160;
    &#60;mx:Array id=&#34;arr&#34;&#62;
      [...]]]></description>
			<content:encoded><![CDATA[<p>ปกติเวลาจะหา data จาก ArrayCollection ก็จะวนลูปแล้ว if เอา วันนี้เล่นเน็ตไปมาเลยไปเจอว่าเค้าทำกันแบบนี้ได้</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2008/04/15/creating-a-view-cursor-on-an-arraycollection-in-flex/ --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">verticalAlign</span>=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">backgroundColor</span>=<span style="color: #ff0000;">&quot;white&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Array</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;arr&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>One<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Two<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Three<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Four<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Five<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:String<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:ArrayCollection</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;arrColl&quot;</span> <span style="color: #000066;">source</span>=<span style="color: #ff0000;">&quot;{arr}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">            import mx.collections.IViewCursor;</span>
<span style="color: #339933;">            import mx.collections.Sort;</span>
<span style="color: #339933;">            import mx.collections.SortField;</span>
&nbsp;
<span style="color: #339933;">            [Embed(&quot;assets/accept.png&quot;)]</span>
<span style="color: #339933;">            public var acceptIcon:Class;</span>
&nbsp;
<span style="color: #339933;">            [Embed(&quot;assets/exclamation.png&quot;)]</span>
<span style="color: #339933;">            public var exclamationIcon:Class;</span>
&nbsp;
<span style="color: #339933;">            private var cursor:IViewCursor;</span>
&nbsp;
<span style="color: #339933;">            private function init():void {</span>
<span style="color: #339933;">                var sortField:SortField = new SortField(null, true);</span>
<span style="color: #339933;">                var sort:Sort = new Sort();</span>
<span style="color: #339933;">                sort.fields = [sortField];</span>
&nbsp;
<span style="color: #339933;">                arrColl.sort = sort;</span>
<span style="color: #339933;">                arrColl.refresh();</span>
&nbsp;
<span style="color: #339933;">                cursor = arrColl.createCursor();</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function button_click(evt:MouseEvent):void {</span>
<span style="color: #339933;">                var found:Boolean = cursor.findAny(textInput.text);</span>
<span style="color: #339933;">                if (found) {</span>
<span style="color: #339933;">                    img.source = acceptIcon;</span>
<span style="color: #339933;">                    list.selectedItem = cursor.current;</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    img.source = exclamationIcon;</span>
<span style="color: #339933;">                    list.selectedItem = null;</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:ApplicationControlBar</span> <span style="color: #000066;">dock</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Canvas<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:TextInput</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;textInput&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Image</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;img&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">verticalCenter</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Canvas<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;button&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Find&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;button_click(event);&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:ApplicationControlBar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:List</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;list&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">dataProvider</span>=<span style="color: #ff0000;">&quot;{arrColl}&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">rowCount</span>=<span style="color: #ff0000;">&quot;{arrColl.length}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/mx:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>ผลการรันก็ได้อย่างนี้คับ<br />
<span id="more-472"></span><br />
<iframe width="100%" height="200" src="http://blog.flexexamples.com/wp-content/uploads/IViewCursor_findAny_test/bin/main.html"/></p>
<p>ที่มา <a href="http://blog.flexexamples.com/2008/04/15/creating-a-view-cursor-on-an-arraycollection-in-flex/">http://blog.flexexamples.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/creating-a-view-cursor-on-an-arraycollection-in-flex/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cloning ArrayCollection</title>
		<link>http://www.jiramot.info/cloning-arraycollection</link>
		<comments>http://www.jiramot.info/cloning-arraycollection#comments</comments>
		<pubDate>Tue, 12 Jan 2010 04:58:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=468</guid>
		<description><![CDATA[There are plenty of occasions where you might want to be able to create an exact clone of a complex/nested data objects, without your new object simply referencing the old one&#8217;s values. To do this, you need to force the creation of new values and references. Depending on the complexity of the data stored, this [...]]]></description>
			<content:encoded><![CDATA[<p>There are plenty of occasions where you might want to be able to create an exact clone of a complex/nested data objects, without your new object simply referencing the old one&#8217;s values. To do this, you need to force the creation of new values and references. Depending on the complexity of the data stored, this will be achieved through shallow or deep copying:</p>
<p><span id="more-468"></span></p>
<p><strong>Shallow Copy</strong></p>
<p>Fine if your collection only contains values and references that can be shared/reused around the app:</p>
<div>
<p>var newAC:ArrayCollection = new ArrayCollection( originalAC.source.slice( 0,</p>
<p>originalAC.length ) );</p>
</div>
<p><strong>Deep Copy</strong></p>
<p>Heavier going; but as well as creating cloned values, it creates new references (pointers) for everything too. Only really necessary if you don&#8217;t want your new object to hold the same object references that your old one did:</p>
<div>
<p>private function clone( source:Object ) :*</p>
<p>{</p>
<p>var myBA:ByteArray = new ByteArray();</p>
<p>myBA.writeObject( source );</p>
<p>myBA.position = 0;</p>
<p>return( myBA.readObject() );</p>
<p>}</p>
<p>newAC:ArrayCollection = new ArrayCollection( clone( originalAC.source ) );</p>
</div>
<p>The clone method in the code above can be used for cloning just about any object (<strong>including deep copying of ByteArray</strong>), and would make a good utility method in any custom framework (both within or outside of the Flex framework). Please note that readObject() will not work with Flash DisplayObjects; however, it will work with complex objects derived from simple types.</p>
<p>The Flex frameworks includes the ObjectUtil that allows you to perform a clean copy using the copy() method.</p>
<div>
<p>var myAC:ArrayCollection = new ArrayCollection( mx.utils.ObjectUtil.copy( myAC.source ) );</p>
<p>source <a href="http://jodieorourke.com/view.php?id=105&amp;blog=news">http://jodieorourke.com/view.php?id=105&amp;blog=news</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/cloning-arraycollection/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AIR Encrypted SQLite Database</title>
		<link>http://www.jiramot.info/air-encrypted-sqlite-database</link>
		<comments>http://www.jiramot.info/air-encrypted-sqlite-database#comments</comments>
		<pubDate>Thu, 19 Nov 2009 03:06:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=448</guid>
		<description><![CDATA[import flash.data.*;
import flash.filesystem.File;

private var dbConn:SQLConnection = new SQLConnection();
private var dbStatement:SQLStatement = new SQLStatement();

private function init(): void {
  // create a seed string of your choice
  var mySeed:String = "AIR15IsAGreatProduct";

  // prepare a bytearray variable to hold the encryption key
   var myKey:ByteArray = new ByteArray();

 // create the myKey ByteArray
  [...]]]></description>
			<content:encoded><![CDATA[<pre>import flash.data.*;
import flash.filesystem.File;

private var dbConn:SQLConnection = new SQLConnection();
private var dbStatement:SQLStatement = new SQLStatement();

private function init(): void {
  // create a seed string of your choice
  var mySeed:String = "AIR15IsAGreatProduct";

  // prepare a bytearray variable to hold the encryption key
   var myKey:ByteArray = new ByteArray();

 // create the myKey ByteArray
  var i:int = 0;
  for (var j:int=0; j&lt;16; j++) {
    // use hexToInt function and the seed to create the key
    i = (hexToInt(mySeed.charCodeAt(j))*15) +
hexToInt(mySeed.charCodeAt(j+1));

    // use the writeByte method - Writes byte to the byte stream
    myKey.writeByte(i&amp;0x00FF);
  }
  var dbFile:File =
File.desktopDirectory.resolvePath("Encryptedemployees.db");
  dbStatement.sqlConnection = dbConn;

  //pass the key, myKey, to the open method of the SQLConnection,
dbConn
  dbConn.open(dbFile, SQLMode.CREATE, false, 2048, myKey);
}

private function hexToInt(hex:Number):int {
    return parseInt("0x" + hex);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/air-encrypted-sqlite-database/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQLite example for AIR</title>
		<link>http://www.jiramot.info/sqlite-example-for-air</link>
		<comments>http://www.jiramot.info/sqlite-example-for-air#comments</comments>
		<pubDate>Thu, 19 Nov 2009 03:04:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=446</guid>
		<description><![CDATA[Here is a very simplistic Flex Builder 3 and AIR example that adds and removes records from a table in a local SQLite database. This is not a fully completed AIR project but this code can probably be reused by anyone wanting to get started with AIR+SQLite. There are a couple of other AIR+SQLite examples [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a very simplistic Flex Builder 3 and AIR example that adds and removes records from a table in a local SQLite database. This is not a fully completed AIR project but this code can probably be reused by anyone wanting to get started with AIR+SQLite. There are a couple of other AIR+SQLite examples out there to check out and don’t forget the documentation on the adobe site.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.data.SQLResult</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.filesystem.File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.data.SQLStatement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.data.SQLConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.events.SQLEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">flash.events.SQLErrorEvent</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">User</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> var exampleDB<span style="color: #339933;">:</span>SQLConnection<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> var exampleDBFile<span style="color: #339933;">:</span><span style="color: #003399;">File</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> var dbStatement<span style="color: #339933;">:</span>SQLStatement<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#91;</span>Bindable<span style="color: #009900;">&#93;</span>
<span style="color: #000000; font-weight: bold;">private</span> var userData<span style="color: #339933;">:</span><span style="color: #003399;">Array</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    initAndOpenDatabase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function initAndOpenDatabase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    exampleDBFile <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;app-resource:/ExampleDatabase.db&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    exampleDB <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    exampleDB.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">OPEN</span>, onExampleDBOpened<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    exampleDB.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span>SQLErrorEvent.<span style="color: #006633;">ERROR</span>, onExampleDBError<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    exampleDB.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span>exampleDBFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onExampleDBOpened<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>SQLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">type</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;open&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        getRecords<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onExampleDBError<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>SQLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function getRecords<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    dbStatement <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">itemClass</span> <span style="color: #339933;">=</span> User<span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">sqlConnection</span> <span style="color: #339933;">=</span> exampleDB<span style="color: #339933;">;</span>
    var sqlQuery<span style="color: #339933;">:</span><span style="color: #003399;">String</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from Users&quot;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> sqlQuery<span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">RESULT</span>, onDBStatementSelectResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onDBStatementSelectResult<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>SQLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    var result<span style="color: #339933;">:</span>SQLResult <span style="color: #339933;">=</span> dbStatement.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>result <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        userData <span style="color: #339933;">=</span> result.<span style="color: #006633;">data</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onDBStatementInsertResult<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>SQLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>exampleDB.<span style="color: #006633;">totalChanges</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        getRecords<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function addUserToDatabase<span style="color: #009900;">&#40;</span>user<span style="color: #339933;">:</span>User<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    var sqlInsert<span style="color: #339933;">:</span><span style="color: #003399;">String</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;insert into Users values('&quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">firstname</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;','&quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">lastname</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;','&quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">email</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;');&quot;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> sqlInsert<span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">removeEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">RESULT</span>, onDBStatementSelectResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">RESULT</span>, onDBStatementInsertResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onAddUserButtonClicked<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    var user<span style="color: #339933;">:</span>User <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    user.<span style="color: #006633;">firstname</span> <span style="color: #339933;">=</span> firstNameTextInput.<span style="color: #006633;">text</span><span style="color: #339933;">;</span>
    user.<span style="color: #006633;">lastname</span> <span style="color: #339933;">=</span> lastNameTextInput.<span style="color: #006633;">text</span><span style="color: #339933;">;</span>
    user.<span style="color: #006633;">email</span> <span style="color: #339933;">=</span> emailTextInput.<span style="color: #006633;">text</span><span style="color: #339933;">;</span>
    addUserToDatabase<span style="color: #009900;">&#40;</span>user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onUsersDataGridChanged<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span><span style="color: #003399;">Event</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onRemoveUserButtonClicked<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    removeUserFromDatabase<span style="color: #009900;">&#40;</span>usersDataGrid.<span style="color: #006633;">selectedItem</span> as User<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function removeUserFromDatabase<span style="color: #009900;">&#40;</span>user<span style="color: #339933;">:</span>User<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    var sqlDelete<span style="color: #339933;">:</span><span style="color: #003399;">String</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;delete from Users where firstname='&quot;</span><span style="color: #339933;">+</span>
                                  user.<span style="color: #006633;">firstname</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;' and lastname='&quot;</span><span style="color: #339933;">+</span>
                                  user.<span style="color: #006633;">lastname</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;' and email='&quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">email</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;';&quot;</span><span style="color: #339933;">;</span>
    trace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sqlDelete=&quot;</span><span style="color: #339933;">+</span>sqlDelete<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">text</span> <span style="color: #339933;">=</span> sqlDelete<span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">removeEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">RESULT</span>, onDBStatementInsertResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">addEventListener</span><span style="color: #009900;">&#40;</span>SQLEvent.<span style="color: #006633;">RESULT</span>, onDBStatementDeleteResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    dbStatement.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> function onDBStatementDeleteResult<span style="color: #009900;">&#40;</span>event<span style="color: #339933;">:</span>SQLEvent<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">void</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>exampleDB.<span style="color: #006633;">totalChanges</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        getRecords<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/sqlite-example-for-air/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex EncryptedLocalStore and SharedObject</title>
		<link>http://www.jiramot.info/flex-encryptedlocalstore-and-sharedobject</link>
		<comments>http://www.jiramot.info/flex-encryptedlocalstore-and-sharedobject#comments</comments>
		<pubDate>Fri, 23 Jan 2009 12:23:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=200</guid>
		<description><![CDATA[วันนี้นั่งงงกับการลบ ShareObject ของ Flash ว่าทำไม ลบแล้วยังดึงค่า username และ password จาก EncryptedLocalStore มาได้อีก ที่แห้ก็พึ่งรู้ว่ามันดันแยก AIR ออกไปไกลเลย โดยสำหรับ Windows XP จะอยู่ที่ Path นี้ครับ
SharedObject 
C:\Documents and Settings\User\Application Data\Macromedia\Flash Player\#SharedObjects
EncryptedLocalStore
C:\Documents and Settings\User\Application Data\Adobe\AIR\ELS
- -*
]]></description>
			<content:encoded><![CDATA[<p>วันนี้นั่งงงกับการลบ ShareObject ของ Flash ว่าทำไม ลบแล้วยังดึงค่า username และ password จาก EncryptedLocalStore มาได้อีก ที่แห้ก็พึ่งรู้ว่ามันดันแยก AIR ออกไปไกลเลย โดยสำหรับ Windows XP จะอยู่ที่ Path นี้ครับ</p>
<p>SharedObject </p>
<blockquote><p>C:\Documents and Settings\User\Application Data\Macromedia\Flash Player\#SharedObjects</p></blockquote>
<p>EncryptedLocalStore</p>
<blockquote><p>C:\Documents and Settings\User\Application Data\Adobe\AIR\ELS</p></blockquote>
<p>- -*</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/flex-encryptedlocalstore-and-sharedobject/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.</title>
		<link>http://www.jiramot.info/certain-actions-such-as-those-that-display-a-pop-up-window-may-only-be-invoked-upon-user-interaction-for-example-by-a-mouse-click-or-button-press</link>
		<comments>http://www.jiramot.info/certain-actions-such-as-those-that-display-a-pop-up-window-may-only-be-invoked-upon-user-interaction-for-example-by-a-mouse-click-or-button-press#comments</comments>
		<pubDate>Wed, 14 Jan 2009 05:23:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=179</guid>
		<description><![CDATA[พอดีว่าวันนี้ ตั่งใจเปลี่ยน file download ใน flex จากเดิม ใช้ navigateToUrl(urlRequest) ให้เป็น fileReference.download(urlRequest) ปรากฏว่าเจอ error 55+
Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
เนื่องจากว่า Flash player 10 มันมี security check ไว้ ถ้าจะใช้ไฟล์ดาวโหลด ต้องเป็น event ที่มาจาก User interface ไม่สามารถสั่งจากตรงไหนของ code ก็ได้ [...]]]></description>
			<content:encoded><![CDATA[<p>พอดีว่าวันนี้ ตั่งใจเปลี่ยน file download ใน flex จากเดิม ใช้ navigateToUrl(urlRequest) ให้เป็น fileReference.download(urlRequest) ปรากฏว่าเจอ error 55+</p>
<blockquote><p>Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.</p></blockquote>
<p>เนื่องจากว่า Flash player 10 มันมี security check ไว้ ถ้าจะใช้ไฟล์ดาวโหลด ต้องเป็น event ที่มาจาก User interface ไม่สามารถสั่งจากตรงไหนของ code ก็ได้ &#8211; -* </p>
<blockquote><p>Upload and download require user interaction</p>
<p>In Flash Player 9, ActionScript could perform uploads and downloads at any time. With Flash Player 10, the FileReference.browse and FileReference.download operations may be initiated only through ActionScript that originates from user interaction. This includes actions such as clicking the mouse or pressing the keyboard.<br />
What is impacted?</p>
<p>This change can potentially affect any SWF file that makes use of Filereference.browse or FileReference.download. This change affects SWF files of all versions played in Flash Player 10 beta and later. This change affects all non-app content in Adobe AIR (however, AIR app content itself is unaffected).<br />
What do I need to do?</p>
<p>Any existing content that invokes a browse dialog box using Filereference.browse or FileReference.download outside of an event triggered by user interaction will need to be updated. The dialog box will now have to be invoked through a button, keyboard shortcut, or some other event initiated by the user.</p></blockquote>
<p>ที่มา <a href="http://www.adobe.com/devnet/flashplayer/articles/fplayer10_security_changes_02.html#head3">flash player 10 security change</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/certain-actions-such-as-those-that-display-a-pop-up-window-may-only-be-invoked-upon-user-interaction-for-example-by-a-mouse-click-or-button-press/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DragOver Event in Flex and Air</title>
		<link>http://www.jiramot.info/dragover-event-in-flex-and-air</link>
		<comments>http://www.jiramot.info/dragover-event-in-flex-and-air#comments</comments>
		<pubDate>Tue, 18 Nov 2008 08:42:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.jiramot.info/?p=64</guid>
		<description><![CDATA[ก็เนื่องจากงานที่ต้องทำ มันมีการเขียน Code หาตำแหน่ง MouseY ในส่วนของฟังก์ชั้น DragOverHandler ซึ่งมันก็ทำงานปกติใน Web Application (ใช้ Flash player) แต่เมื่อเอามารันบน Air ปรากฏว่า มันดันหาค่าพิกัด Y ออกมาเป็นค่าคงที่ตลอด ก็เลยงง ทำไมรันบน flash มันเวิร์ก แต่พอมารันบน air กลับไม่เวิร์ก
addEventListener(DragEvent.DRAG_OVER, dragOverHandler);
private function dragOverHandler(event:DragEvent):void{
  trace(&#8220;MouseY: &#8221; + mouseY);
}

ข้อแตกต่างเลยสิ่งแรกใน flash เวลารัน มันในโหมดดีบัก จะเห็นได้ว่ามีการโชว์เจ้า track ออกมาก็ต่อเมื่อ เม้าส์ over เข้าไปใน component แล้วก็เมาส์เลื่อนด้วยคับ  ถ้าหากว่าเมาส์ ไม่ได้เลื่อน ก็จะไม่ dispatch event ออกมา ต่างกับ air เมื่อเมาส์เรา [...]]]></description>
			<content:encoded><![CDATA[<p>ก็เนื่องจากงานที่ต้องทำ มันมีการเขียน Code หาตำแหน่ง MouseY ในส่วนของฟังก์ชั้น DragOverHandler ซึ่งมันก็ทำงานปกติใน Web Application (ใช้ Flash player) แต่เมื่อเอามารันบน Air ปรากฏว่า มันดันหาค่าพิกัด Y ออกมาเป็นค่าคงที่ตลอด ก็เลยงง ทำไมรันบน flash มันเวิร์ก แต่พอมารันบน air กลับไม่เวิร์ก</p>
<blockquote><p>addEventListener(DragEvent.DRAG_OVER, dragOverHandler);</p></blockquote>
<blockquote><p>private function dragOverHandler(event:DragEvent):void{<br />
  trace(&#8220;MouseY: &#8221; + mouseY);<br />
}</p></blockquote>
<p><span id="more-64"></span><br />
ข้อแตกต่างเลยสิ่งแรกใน flash เวลารัน มันในโหมดดีบัก จะเห็นได้ว่ามีการโชว์เจ้า track ออกมาก็ต่อเมื่อ เม้าส์ over เข้าไปใน component แล้วก็เมาส์เลื่อนด้วยคับ  ถ้าหากว่าเมาส์ ไม่ได้เลื่อน ก็จะไม่ dispatch event ออกมา ต่างกับ air เมื่อเมาส์เรา over เข้าไปใน component ก็จะ dispatch event ออกมาเรื่อยๆ  ไม่ว่าจะเลื่อนเมาส์หรือไม่ก็ตาม จะหยุดก็ต่อเมื่อ เมาส์ exit ออกไปจาก component แล้ว และที่สำัคัญ ค่าของเจ้า mouseY และ mouseX จะไม่เปลี่ยนแปลง  นั่นก็คือ ครั้งแรกมัน dispatch event ได้ค่า mouseX และ mouseY ค่าอะไร มันก็จะ dispatch ค่านั่นออกมาตลอด</p>
<p>เหอะๆ ไอเราก็กะว่าตอนแรก จะหาทางไม่ให้มัน dispatch event ออกมาตลอด กะเปลี่ยนไปใช้<br />
DragEvent.DRAG_ENTER แล้ว add MouseEvent.MOUSE_MOVE เข้าไป เพื่อให้ได้พิกัน MouseY แล้วในจังหวะที่เป็น DragEvent.DRAG_EXIT ค่อย remove MouseEvent.MOUSE_MOVE ออก </p>
<blockquote><p>addEventListener(DragEvent.DRAG_ENTER, dragEnterHandler);<br />
addEventListener(DragEvent.DRAG_EXIT, dragEnterHandler);</p></blockquote>
<blockquote><p>private function dragEnterHandler(event:DragEvent):void{<br />
  trave(&#8220;ENTER&#8221;)<br />
  addEventListener(MuseEvent.MOUSE_MOVE, mouseMovehandler);<br />
}<br />
private function dragExitHandler(event:DragEvent):void{<br />
  trace(&#8220;EXIT&#8221;)<br />
  removeListener(MouseEvent.MOUSE_MOVE, mouseMovehandler);<br />
}<br />
private function mouseMoveHandler(event:MouseEvent):void{<br />
  trace(&#8220;MOVE&#8221;)<br />
}</p></blockquote>
<p>ปรกฏว่าเมื่อเมาส์ enter เข้าไป มันก็ trace message &#8220;ENTER&#8221; ออกมา แต่ว่าเวลาเราเลื่อนเมาส์ มันกลับไม่พิมพ์ &#8220;MOVE&#8221; ออกมาเลย และเวลาเราเอาเมาส์ออกจาก component มันก็พิมพ์ &#8220;EXIT&#8221; &#8211; -*<br />
แต่ว่าหากเราเอาเมาส์เข้าไปใน component แล้ว ปล่อยคลิ๊กหละก้อ มันก็จะพิมพ์ &#8220;MOVE&#8221; ๆๆๆๆ ออกมาเรื่อยๆ เหมือนมันพึ่งจะ add MouseMove ให้เรา &#8211; -*</p>
<p>จนต้องหาทางแก้สุดท้าย เข้าไปใช้ ตัวแปรของ DragEvent ซึ่งก็คือ localX และ localY เพื่อหาค่าพิกัน X, Y นั่นเอง แต่ว่าค่าทีไ่ด้เป็นค่าที่อ้างอิงจากพิกัดของ Component นั้นๆ </p>
<p>ลองต่อไป คงต้องกลับไปอ่าน flex doc ดูใหม่อีกแระ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jiramot.info/dragover-event-in-flex-and-air/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
