<?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>ADM Blog &#187; actionscript</title> <atom:link href="http://blog.another-d-mention.ro/tag/actionscript/feed/" rel="self" type="application/rss+xml" /><link>http://blog.another-d-mention.ro</link> <description>No matter how you see things, reality changes when you reach understanding</description> <lastBuildDate>Fri, 22 Jul 2011 06:56:49 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1</generator> <item><title>ExtendedImage Component</title><link>http://blog.another-d-mention.ro/programming/extendedimage-component/</link> <comments>http://blog.another-d-mention.ro/programming/extendedimage-component/#comments</comments> <pubDate>Thu, 12 Nov 2009 12:36:42 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[component]]></category> <category><![CDATA[flex]]></category> <category><![CDATA[library]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=753</guid> <description><![CDATA[I just finished writing a Flex3 library that will allow you to read a great number of image formats using flex and actionscript 3. The component uses a codec like rendering system, so each time you provide it with a source, the codecs attempt one by one to read the file signature and decide which [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/adding-ellipsis-points-in-a-textarea-component-in-flex/' rel='bookmark' title='Permanent Link: Adding ellipsis points in a TextArea component in Flex'>Adding ellipsis points in a TextArea component in Flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/' rel='bookmark' title='Permanent Link: Read/Load files from ZIP in JavaScript'>Read/Load files from ZIP in JavaScript</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li></ol>]]></description> <content:encoded><![CDATA[<p>I just finished writing a Flex3 library that will allow you to read a great number of image formats using flex and actionscript 3. The component uses a codec like rendering system, so each time you provide it with a source, the codecs attempt one by one to read the file signature and decide which one is fit to decode the image.<br
/> So doing this, it won't matter the file extension or the way you provide the image asset (archived, link, base64 encoded, plain text, byteArray or embedded at compile time)</p><p>It's a work in progress but curently I've made codecs for the following formats:</p><ul><li>PointLineCAD 3D objects (*.p3d)</li><li>Photoshop images (*.psd, *.pdd)</li><li>ZSoft images (*.pcx)</li><li>Truevision TGA (*.tga, *. icb, *.vda, *.vst, *.win)</li><li>Windows icon files (*.ico)</li><li>GIF images (*.gif – static and animated gifs)</li><li>JPEG images (*.jpg. *.jpeg, *.gfif)</li><li>PNG (Portable network graphic) images (*.png)</li><li>Windows Bitmap images ( *.bmp, *.rle, *.dib)</li><li>Adobe Shockwave Flash (*.swf)</li></ul><p>As I said before, the way you provide the source doesn't really matter. You can zip up all your images in an archive and as source you can just point to the file inside the zip.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>adm :ExtendedImage id=<span style="color: #ff0000;">&quot;img&quot;</span> source=<span style="color: #ff0000;">&quot;archive.zip://image.png&quot;</span> <span style="color: #66cc66;">/&gt;</span></pre></td></tr></table></div><p>This way, you greatly reduce the number of requests to the server. But this is not all. Source can be also provided as a base64 encoded string, or as plain text (only p3d can take advantage of this since the p3d file is plain text as well).</p><p>For a bit more details, a <a
href="http://blog.another-d-mention.ro/downloads/extended-image/">demo</a> and API description, visit <a
href="http://blog.another-d-mention.ro/downloads/extended-image/">this page</a></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/adding-ellipsis-points-in-a-textarea-component-in-flex/' rel='bookmark' title='Permanent Link: Adding ellipsis points in a TextArea component in Flex'>Adding ellipsis points in a TextArea component in Flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/read-load-files-from-zip-in-javascript/' rel='bookmark' title='Permanent Link: Read/Load files from ZIP in JavaScript'>Read/Load files from ZIP in JavaScript</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/extendedimage-component/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How to identify at runtime if the swf is in debug or release mode/build</title><link>http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/</link> <comments>http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/#comments</comments> <pubDate>Tue, 07 Jul 2009 11:43:37 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[debug]]></category> <category><![CDATA[flex]]></category> <category><![CDATA[release]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=513</guid> <description><![CDATA[It may be interesting to know at runtime whether an application is running from a debug or release SWF file. It allows the application to automatically execute debug specific code when the file is a debug SWF file and ignore this code when it is published as a release file. Also, it should be nice [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/' rel='bookmark' title='Permanent Link: Read data directly from base64 without decoding'>Read data directly from base64 without decoding</a></li><li><a
href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li></ol>]]></description> <content:encoded><![CDATA[<p>It may be interesting to know at runtime whether an application is running from a debug or release SWF file. It allows the application to automatically execute debug specific code when the file is a debug SWF file and ignore this code when it is published as a release file. Also, it should be nice to know if you have a debug flash player just for the same reasons. But for the last one, there is a function in the Capabilities class called isDebugger.</p><p>One solution would be to use <a
href="http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html" target="_blank">conditional compilation</a>. The other solution is in the following code (hack).</p><div
class="wp_syntax"><div
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> org<span style="color: #000066; font-weight: bold;">.</span>adm<span style="color: #000066; font-weight: bold;">.</span>runtime
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.system</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Capabilities</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ModeCheck
	<span style="color: #000000;">&#123;</span>
		<span style="color: #3f5fbf;">/**
		 * Returns true if the user is running the app on a Debug Flash Player.
		 * Uses the Capabilities class
		 **/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> isDebugPlayer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">Capabilities</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">isDebugger</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Returns true if the swf is built in debug mode
		 **/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> isDebugBuild<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getStackTrace</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">search</span><span style="color: #000000;">&#40;</span><span style="color: #009966; font-style: italic;">/:[0-9]+]$/m</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&gt;</span> <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/**
		 * Returns true if the swf is built in release mode
		 **/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> isReleaseBuild<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Boolean</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">!</span>isDebugBuild<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div><p>This code simply searches for line numbers of errors in StackTrace result. Only StackTrace result of a debug SWF file contains line numbers. Then we know that we are running a debug or release SWF file.</p><p>This class is also available in the <a
href="http://blog.another-d-mention.ro/downloads/components-pack/">Components Pack</a> at Runtime subpackage</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li><li><a
href='http://blog.another-d-mention.ro/programming/java-script/read-data-directly-from-base64-without-decoding/' rel='bookmark' title='Permanent Link: Read data directly from base64 without decoding'>Read data directly from base64 without decoding</a></li><li><a
href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>How to clone (duplicate) an object in ActionScript 3</title><link>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/</link> <comments>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/#comments</comments> <pubDate>Fri, 05 Jun 2009 20:33:44 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[How To's]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[clone]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[flex]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=440</guid> <description><![CDATA[For a project I needed to clone an object of unknown type. And by clone I mean to create a new instance of that same type and then fill out all its properties (including getters and setters) to mirror the original object. Thanks to a friend, I discovered the describeType function in AS3. But this alone [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol>]]></description> <content:encoded><![CDATA[<p>For a project I needed to clone an object of unknown type. And by clone I mean to create a new instance of that same type and then fill out all its properties (including getters and setters) to mirror the original object.</p><p>Thanks to a friend, I discovered the <a
href="http://livedocs.adobe.com/flex/2/langref/flash/utils/package.html#describeType%28%29">describeType </a>function in AS3. But this alone will only take care of the copying part. To create an object of the same type as another one we use <a
href="http://livedocs.adobe.com/flex/2/langref/flash/utils/package.html#getDefinitionByName%28%29">getDefinitionByName</a>.</p><p>Although Flash reflection is pretty basic, with a little work it will do the trick.</p><p>Get the <a
href="http://cache.another-d-mention.ro/stuff/cloneTest.zip">application files</a>.</p><p>Here's the code:</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
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000066; font-weight: bold;">?&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;</span>mx <span style="color: #000066; font-weight: bold;">:</span>Application xmlns<span style="color: #000066; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #990000;">&quot;absolute&quot;</span> xmlns<span style="color: #000066; font-weight: bold;">:</span>local=<span style="color: #990000;">&quot;*&quot;</span> creationComplete=<span style="color: #990000;">&quot;init()&quot;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">&gt;&lt;</span>mx <span style="color: #000066; font-weight: bold;">:</span>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
 <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000066; font-weight: bold;">!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">import</span> mx<span style="color: #000066; font-weight: bold;">.</span>controls<span style="color: #000066; font-weight: bold;">.</span>Alert<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">:</span>DataObject = <span style="color: #0033ff; font-weight: bold;">new</span> DataObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> cloneObject<span style="color: #000066; font-weight: bold;">:</span>DataObject<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> = <span style="color: #990000;">'John Doe'</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">.</span>howMany = <span style="color: #000000; font-weight:bold;">4.5</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">.</span>when = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">.</span>complexProp = <span style="color: #0033ff; font-weight: bold;">new</span> DataObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">.</span>complexProp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> = <span style="color: #990000;">'Name in sub-object'</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         cloneObject = UtilFunctions<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> DataObject<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
         Alert<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">show</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Clone:<span style="">\n</span>name = &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> cloneObject<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>howMany = &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> cloneObject<span style="color: #000066; font-weight: bold;">.</span>howMany <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>when = &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> cloneObject<span style="color: #000066; font-weight: bold;">.</span>when <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;<span style="">\n</span>complexProp.name = &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> cloneObject<span style="color: #000066; font-weight: bold;">.</span>complexProp<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #3f5fbf;">/**
&nbsp;
      * describeType will produce this (for a DataObject instance):
      *
      * &lt;type name=&quot;DataObject&quot; base=&quot;Object&quot; isDynamic=&quot;false&quot; isFinal=&quot;false&quot; isStatic=&quot;false&quot;&gt;
&nbsp;
           &lt;extendsclass type=&quot;Object&quot;/&gt;
           &lt;accessor name=&quot;isHandicap&quot; access=&quot;writeonly&quot; type=&quot;Boolean&quot; declaredBy=&quot;DataObject&quot;/&gt;
&nbsp;
           &lt;variable name=&quot;howMany&quot; type=&quot;Number&quot;/&gt;
           &lt;accessor name=&quot;complexProp&quot; access=&quot;readwrite&quot; type=&quot;DataObject&quot; declaredBy=&quot;DataObject&quot;/&gt;
&nbsp;
           &lt;variable name=&quot;name&quot; type=&quot;String&quot;/&gt;
           &lt;variable name=&quot;when&quot; type=&quot;Date&quot;/&gt;
&nbsp;
&nbsp;
      *
      * */</span>
&nbsp;
 <span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">&gt;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">&lt;/</span>mx<span style="color: #000066; font-weight: bold;">&gt;</span></pre></td></tr></table></div><p>And the UtilFunctions.as file:</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
73
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">describeType</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getDefinitionByName</span><span style="color: #000066; font-weight: bold;">;</span>
 <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getQualifiedClassName</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
 <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> UtilFunctions
 <span style="color: #000000;">&#123;</span>
&nbsp;
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> newSibling<span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:*</span> <span style="color: #000000;">&#123;</span>
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
             <span style="color: #6699cc; font-weight: bold;">var</span> objSibling<span style="color: #000066; font-weight: bold;">:*;</span>
             <span style="color: #0033ff; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span>
                 <span style="color: #6699cc; font-weight: bold;">var</span> classOfSourceObj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span> = <span style="color: #004993;">getDefinitionByName</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">getQualifiedClassName</span><span style="color: #000000;">&#40;</span>sourceObj<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span>
                 objSibling = <span style="color: #0033ff; font-weight: bold;">new</span> classOfSourceObj<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
             <span style="color: #000000;">&#125;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">catch</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">return</span> objSibling<span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #000000;">&#125;</span>
         <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">clone</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">clone</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000066; font-weight: bold;">;</span>
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
             <span style="color: #004993;">clone</span> = newSibling<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">clone</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                 copyData<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">clone</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
             <span style="color: #000000;">&#125;</span>
         <span style="color: #000000;">&#125;</span>
&nbsp;
         <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #004993;">clone</span><span style="color: #000066; font-weight: bold;">;</span>
     <span style="color: #000000;">&#125;</span>
&nbsp;
     <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> copyData<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000066; font-weight: bold;">,</span> destination<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
&nbsp;
         <span style="color: #009900; font-style: italic;">//copies data from commonly named properties and getter/setter pairs</span>
         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;&amp;</span> <span style="color: #000000;">&#40;</span>destination<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
             <span style="color: #0033ff; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span>
                 <span style="color: #6699cc; font-weight: bold;">var</span> sourceInfo<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #004993;">describeType</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                 <span style="color: #6699cc; font-weight: bold;">var</span> prop<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">XML</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
                 <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span>prop <span style="color: #0033ff; font-weight: bold;">in</span> sourceInfo<span style="color: #000066; font-weight: bold;">.</span>variable<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
                     <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>destination<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                         destination<span style="color: #000000;">&#91;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span> = <span style="color: #004993;">source</span><span style="color: #000000;">&#91;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
                     <span style="color: #000000;">&#125;</span>
&nbsp;
                 <span style="color: #000000;">&#125;</span>
&nbsp;
                 <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span><span style="color: #000000;">&#40;</span>prop <span style="color: #0033ff; font-weight: bold;">in</span> sourceInfo<span style="color: #000066; font-weight: bold;">.</span>accessor<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                     <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@access == <span style="color: #990000;">&quot;readwrite&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                         <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>destination<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">hasOwnProperty</span><span style="color: #000000;">&#40;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                             destination<span style="color: #000000;">&#91;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span> = <span style="color: #004993;">source</span><span style="color: #000000;">&#91;</span>prop<span style="color: #000066; font-weight: bold;">.</span>@<span style="color: #004993;">name</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
                         <span style="color: #000000;">&#125;</span>
&nbsp;
                     <span style="color: #000000;">&#125;</span>
                 <span style="color: #000000;">&#125;</span>
             <span style="color: #000000;">&#125;</span>
             <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>err<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
                 <span style="color: #000066; font-weight: bold;">;</span>
             <span style="color: #000000;">&#125;</span>
         <span style="color: #000000;">&#125;</span>
     <span style="color: #000000;">&#125;</span>
 <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div><p><a
class="FlattrButton" style="display:none;" href="http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/"></a><br
/> <noscript><a
href="http://flattr.com/thing/183337/How-to-clone-duplicate-an-object-in-ActionScript-3" target="_blank"><br
/> <img
src="http://api.flattr.com/button/flattr-badge-large.png" alt="flattr badge large How to clone (duplicate) an object in ActionScript 3" title="Flattr this" border="0" /></a></noscript></p><p><script type="text/javascript">google_ad_client = "ca-pub-3771432957882119";
/* InsidePost */
google_ad_slot = "9112434755";
google_ad_width = 468;
google_ad_height = 60;</script><br
/> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-actionscript/serialize-javascript-object-to-json/' rel='bookmark' title='Permanent Link: Serialize JavaScript object to JSON'>Serialize JavaScript object to JSON</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-identify-at-runtime-if-swf-is-in-debug-or-release-mode-build/' rel='bookmark' title='Permanent Link: How to identify at runtime if the swf is in debug or release mode/build'>How to identify at runtime if the swf is in debug or release mode/build</a></li><li><a
href='http://blog.another-d-mention.ro/programming/javascript-object-oriented-programming-oop-jclass/' rel='bookmark' title='Permanent Link: JavaScript Object-Oriented Programming (OOP) &#8211; jClass'>JavaScript Object-Oriented Programming (OOP) &#8211; jClass</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/feed/</wfw:commentRss> <slash:comments>32</slash:comments> </item> <item><title>Flex and Visual Studio</title><link>http://blog.another-d-mention.ro/misc/flex-and-visual-studio/</link> <comments>http://blog.another-d-mention.ro/misc/flex-and-visual-studio/#comments</comments> <pubDate>Wed, 25 Mar 2009 19:09:47 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Misc]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[air]]></category> <category><![CDATA[amethyst]]></category> <category><![CDATA[flex]]></category> <category><![CDATA[ide]]></category> <category><![CDATA[mxml]]></category> <category><![CDATA[sapphiresteel]]></category> <category><![CDATA[visual studio]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=261</guid> <description><![CDATA[Visual Studio is really popular with developers and for good reasons. It's fast, has some of the best Intellisense and debuging there is and now you can also use it for Flex authoring. Amethyst is developed by SapphireSteel and it's currently in public Beta. One of the smartest moves Adobe ever did was to release [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li><li><a
href='http://blog.another-d-mention.ro/misc/visual-versioning-for-designers/' rel='bookmark' title='Permanent Link: Visual versioning for designers'>Visual versioning for designers</a></li><li><a
href='http://blog.another-d-mention.ro/misc/flex-vs-silverlight-vs-ajax/' rel='bookmark' title='Permanent Link: Flex vs Silverlight vs AJAX'>Flex vs Silverlight vs AJAX</a></li></ol>]]></description> <content:encoded><![CDATA[<p>Visual Studio is really popular with developers and for good reasons. It's fast, has some of the best Intellisense and debuging there is and now you can also use it for Flex authoring. Amethyst is developed by <a
href="http://www.sapphiresteel.com/">SapphireSteel</a> and it's currently in public Beta.</p><p>One of the smartest moves Adobe ever did was to release the Flex SDK and make it easy to integrate it with other code editors. We know of quite a few editors (commercial and open source) that use the SDK, so this is certainly extending the Flex echo-system. Amethyst is a free IDE that builds on Visual Studio. If you already have Visual Studio and the Flex SDK installed, you only need to run the Amethyst installer to get started.</p><p><a
href="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/03/ambeta3-debugger.gif"><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/03/ambeta3-debugger.gif" alt="ambeta3 debugger Flex and Visual Studio" title="ambeta3-debugger" width="650" height="509" class="aligncenter size-full wp-image-262" /></a></p><p>Amethyst offers code completion, formatting and intellisense for AS3 and MXML. There's class templates for AS3, AIR, MXML, MXML components and more. The code is color coded and collapsible and all the neat Visual Basic panels such as Object and Solution Explorer works. The Personal Edition of Amethyst will be a free download for always, but some IntelliSense features may be provided in the ‘Professional’ edition only. The latest version was released only days ago and the beta now has super-fast intellisense, so if the slow intellisense in Flex Builder is killing your productivity, this could be worth a shot.</p><p>Check out more and download from <a
href="http://www.sapphiresteel.com/Download-Amethyst-Adobe-Flex-IDE">here</a></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/create-flexas3-applications-for-mobile-devices/' rel='bookmark' title='Permanent Link: Create Flex/AS3 applications for Mobile Devices'>Create Flex/AS3 applications for Mobile Devices</a></li><li><a
href='http://blog.another-d-mention.ro/misc/visual-versioning-for-designers/' rel='bookmark' title='Permanent Link: Visual versioning for designers'>Visual versioning for designers</a></li><li><a
href='http://blog.another-d-mention.ro/misc/flex-vs-silverlight-vs-ajax/' rel='bookmark' title='Permanent Link: Flex vs Silverlight vs AJAX'>Flex vs Silverlight vs AJAX</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/misc/flex-and-visual-studio/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Communicate betwen C# and an embeded Flash application</title><link>http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/</link> <comments>http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/#comments</comments> <pubDate>Wed, 18 Mar 2009 09:13:01 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[C#]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[activex]]></category> <category><![CDATA[communication]]></category> <category><![CDATA[external interface]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=230</guid> <description><![CDATA[The External API allows an ActionScript developer to easily interact with the container program that is hosting Flash Player 8 and vice versa. The majority of the time, this will most likely be a Web browser, but this does not always have to be the case. As many C# developers know, it is easy to [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/' rel='bookmark' title='Permanent Link: Use clipboard (copy/paste) in C# console application'>Use clipboard (copy/paste) in C# console application</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li></ol>]]></description> <content:encoded><![CDATA[<p><script type="text/javascript">google_ad_client = "ca-pub-3771432957882119";
/* InsidePost */
google_ad_slot = "9112434755";
google_ad_width = 468;
google_ad_height = 60;</script><br
/> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></p><p>The External API allows an ActionScript developer to easily interact with the container program that is hosting Flash Player 8 and vice versa. The majority of the time, this will most likely be a Web browser, but this does not always have to be the case.</p><p>As many C# developers know, it is easy to house an ActiveX control (the IE version of Flash Player) in a .NET Windows application. This means we can now load an SWF in our Windows application and easily send data back and forth. Keep in mind that the keyword in this statement is "easily;" although possible before, it was not nearly as simple as the External API makes it now!</p><h3>C# to ActionScript Communication</h3><p>As I said before, communication between Flash Player and its container has been made extremely easy. The new class that makes this process so easy is the ExternalInterface. We will begin in the ActionScript. First, we need to import this new class so we can use it (as2 only, in as3 it will work without the import):</p><div
class="wp_syntax"><div
class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;</pre></div></div><p>Next, we have to register any function we want to make available externally:</p><div
class="wp_syntax"><div
class="code"><pre class="actionscript" style="font-family:monospace;">ExternalInterface.<span style="color: #006600;">addCallback</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;addText&quot;</span>, addText<span style="color: #66cc66;">&#41;</span>;</pre></div></div><p>Basically, the code above will allow us to call the addText function (which I will show in a minute) from the C# application.<br
/> The addText function is as below. Basically, it takes a string input and appends it to a text box</p><div
class="wp_syntax"><div
class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> addText<span style="color: #66cc66;">&#40;</span>val:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	inTxt.<span style="color: #006600;">appendText</span><span style="color: #66cc66;">&#40;</span>val + <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// append text recieved from c#</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div><p>That's it from the ActionScript side. Now all we need to do is call the function from C#. First, I add an instance of the Flash Player ActiveX control to my form and load the SWF we created in the form's constructor:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> AxShockwaveFlash player<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> DemoForm <span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
     <span style="color: #008000;">...</span>
     <span style="color: #0000FF;">player</span><span style="color: #008000;">.</span><span style="color: #0000FF;">LoadMovie</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, Application<span style="color: #008000;">.</span><span style="color: #0000FF;">StartupPath</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\\</span>EITest.swf&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
     player<span style="color: #008000;">.</span><span style="color: #0000FF;">Play</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">...</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>Next, all we have to do is call the externalized method when desired. In my case, it is in response to the user clicking the send button:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> sendBtn_Click<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    player<span style="color: #008000;">.</span><span style="color: #0000FF;">CallFunction</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&quot;</span> <span style="color: #008000;">+</span> outTxt<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><h3>ActionScript to C# Communication</h3><p>Again, you will need to use the ExternalInterface in the ActionScript:</p><div
class="wp_syntax"><div
class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">send</span><span style="color: #66cc66;">&#40;</span>evt : Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;sendText&quot;</span>, outTxt.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// function to call and it's parameters</span>
	outTxt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;&quot;</span>; <span style="color: #808080; font-style: italic;">// reset text box</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div><p>As you can see, I am calling a method sendText and passing the input string as a parameter. Now to receive the message in C#, we first have to subscribe to the FlashCall event. You can do this in the constructor or from the activex properties panel on events tab.</p><p>Now the call made in ActionScript will be received in the request property of the event argument. For my particular call, the XML will look like this:</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;invoke</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sendText&quot;</span> <span style="color: #000066;">returntype</span>=<span style="color: #ff0000;">&quot;xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>some text message here<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/invoke<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><p>So now all we have to do is parse the XML in the event handler and invoke the C# function locally:</p><div
class="wp_syntax"><div
class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> player_FlashCall<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, _IShockwaveFlashEvents_FlashCallEvent e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// message is in xml format so we need to parse it</span>
    XmlDocument document <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> XmlDocument<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    document<span style="color: #008000;">.</span><span style="color: #0000FF;">LoadXml</span><span style="color: #008000;">&#40;</span>e<span style="color: #008000;">.</span><span style="color: #0000FF;">request</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008080; font-style: italic;">// get attributes to see which command flash is trying to call</span>
    XmlAttributeCollection attributes <span style="color: #008000;">=</span> document<span style="color: #008000;">.</span><span style="color: #0000FF;">FirstChild</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Attributes</span><span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">String</span> command <span style="color: #008000;">=</span> attributes<span style="color: #008000;">.</span><span style="color: #0000FF;">Item</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InnerText</span><span style="color: #008000;">;</span>
    <span style="color: #008080; font-style: italic;">// get parameters</span>
    XmlNodeList list <span style="color: #008000;">=</span> document<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElementsByTagName</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;arguments&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008080; font-style: italic;">// Interpret command</span>
    <span style="color: #0600FF; font-weight: bold;">switch</span> <span style="color: #008000;">&#40;</span>command<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;sendText&quot;</span> <span style="color: #008000;">:</span> resultTxt<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> list<span style="color: #008000;">&#91;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InnerText</span><span style="color: #008000;">;</span> <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">case</span> <span style="color: #666666;">&quot;Some_Other_Command&quot;</span> <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></div></div><p>Viola!</p><p><a
href="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/03/untitled.png"><img
class="alignnone size-full wp-image-233" title="c# to flash activex demo" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/03/untitled.png" alt="untitled Communicate betwen C# and an embeded Flash application" width="565" height="285" /></a></p><p>I have made the simple example discussed available <a
href="http://cache.another-d-mention.ro/stuff/CFlashProject.zip">here</a>.</p><p><script type="text/javascript">google_ad_client = "ca-pub-3771432957882119";
/* InsidePost */
google_ad_slot = "9112434755";
google_ad_width = 468;
google_ad_height = 60;</script><br
/> <script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/' rel='bookmark' title='Permanent Link: Use clipboard (copy/paste) in C# console application'>Use clipboard (copy/paste) in C# console application</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/feed/</wfw:commentRss> <slash:comments>39</slash:comments> </item> <item><title>Code Formating for Flex</title><link>http://blog.another-d-mention.ro/programming/flex-actionscript/code-formating-for-flex/</link> <comments>http://blog.another-d-mention.ro/programming/flex-actionscript/code-formating-for-flex/#comments</comments> <pubDate>Fri, 20 Feb 2009 09:05:25 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[code]]></category> <category><![CDATA[flex]]></category> <category><![CDATA[formating]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=25</guid> <description><![CDATA[This is one thing flex and flash are missing. Code formating. I've tested few eclipse plugins but none of them worked like this one. You can download it from http://sourceforge.net/projects/flexformatter/ Just copy it in your ecplise/plugins folder and restart. You can also import/export your settings in a .properties file Ctrl-Shift-F is the default shortcut key [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/really-useful-firefox-keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Really useful firefox keyboard shortcuts'>Really useful firefox keyboard shortcuts</a></li><li><a
href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/' rel='bookmark' title='Permanent Link: How to run python code in Windows batch (bat) files'>How to run python code in Windows batch (bat) files</a></li></ol>]]></description> <content:encoded><![CDATA[<p>This is one thing flex and flash are missing. Code formating.<br
/> I've tested few eclipse plugins but none of them worked like this one. You can download it from <a
href="http://sourceforge.net/projects/flexformatter/">http://sourceforge.net/projects/flexformatter/</a></p><p>Just copy it in your ecplise/plugins folder and restart. You can also import/export your settings in a .properties file</p><p><img
class="alignnone size-medium wp-image-26" title="prettyformating" src="http://cache.another-d-mention.ro/images/wp-content/uploads/2009/02/prettyformating-300x246.jpg" alt="prettyformating 300x246 Code Formating for Flex" width="300" height="246" /></p><p><strong>Ctrl-Shift-F</strong> is the default shortcut key to format the selected code. Also it's possible to assign another shortcut combination or using the red circled button on the image above.</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/misc/really-useful-firefox-keyboard-shortcuts/' rel='bookmark' title='Permanent Link: Really useful firefox keyboard shortcuts'>Really useful firefox keyboard shortcuts</a></li><li><a
href='http://blog.another-d-mention.ro/programming/create-professional-flex-components/' rel='bookmark' title='Permanent Link: Create professional Flex components'>Create professional Flex components</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-run-python-code-in-windows-batch-bat-files/' rel='bookmark' title='Permanent Link: How to run python code in Windows batch (bat) files'>How to run python code in Windows batch (bat) files</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/flex-actionscript/code-formating-for-flex/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Blend Modes</title><link>http://blog.another-d-mention.ro/programming/flex-actionscript/blend-modes/</link> <comments>http://blog.another-d-mention.ro/programming/flex-actionscript/blend-modes/#comments</comments> <pubDate>Thu, 19 Feb 2009 21:31:18 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[actionscript]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[flex]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=22</guid> <description><![CDATA[If you wonder, what blendmodes are doing exactly, you can read this article about blendmodes in common. I tried to work with them in a accurate way to emulate complexer algorithms like animated water waves. Generically you can save a lot of performance, if you need to calculate every single pixel colorvalue from two bitmaps. [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-center-a-image-on-a-canvas-in-flex/' rel='bookmark' title='Permanent Link: How To &#8211; Center a image on a canvas in flex'>How To &#8211; Center a image on a canvas in flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li></ol>]]></description> <content:encoded><![CDATA[<p>If you wonder, what blendmodes are doing exactly, you can read <a
href="http://www.pegtop.net/delphi/blendmodes/" target="_blank">this</a> article about blendmodes in common. I tried to work with them in a accurate way to emulate complexer algorithms like animated water waves. Generically you can save a lot of performance, if you need to calculate every single pixel colorvalue from two bitmaps. In most cases, there is a simple solution using ColorTransform and Blendmodes. One problem is that the flash results are different in some cases, so here are my findings:</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
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// **BLENDMODES</span>
<span style="color: #009900; font-style: italic;">// based on: http://www.pegtop.net/delphi/blendmodes/</span>
<span style="color: #009900; font-style: italic;">// modified to fit flash output</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// ADD</span>
<span style="color: #004993;">c</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">min</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> c0 <span style="color: #000066; font-weight: bold;">+</span> c1 <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">// SUBTRACT</span>
<span style="color: #004993;">c</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">max</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> c0 <span style="color: #000066; font-weight: bold;">-</span> c1 <span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">// MULTIPLY</span>
<span style="color: #004993;">c</span> = <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> c1 <span style="color: #000066; font-weight: bold;">*</span> c0 <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> 0xff <span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">// SCREEN</span>
<span style="color: #004993;">c</span> = <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000066; font-weight: bold;">-</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000066; font-weight: bold;">-</span> c0 <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000066; font-weight: bold;">-</span> c1 <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">// LIGHTEN</span>
<span style="color: #004993;">c</span> = c0 <span style="color: #000066; font-weight: bold;">&gt;</span> c1 <span style="color: #000066; font-weight: bold;">?</span> c0 <span style="color: #000066; font-weight: bold;">:</span> c1
<span style="color: #009900; font-style: italic;">// DARKEN</span>
<span style="color: #004993;">c</span> = c0 <span style="color: #000066; font-weight: bold;">&lt;</span> c1 <span style="color: #000066; font-weight: bold;">?</span> c0 <span style="color: #000066; font-weight: bold;">:</span> c1
<span style="color: #009900; font-style: italic;">// DIFFERENCE</span>
<span style="color: #004993;">c</span> = c0 <span style="color: #000066; font-weight: bold;">&gt;</span> c1 <span style="color: #000066; font-weight: bold;">?</span> c0 <span style="color: #000066; font-weight: bold;">-</span> c1 <span style="color: #000066; font-weight: bold;">:</span> c1 <span style="color: #000066; font-weight: bold;">-</span> c0
<span style="color: #009900; font-style: italic;">// INVERT ( no influence from c1 )</span>
<span style="color: #004993;">c</span> = <span style="color: #000000; font-weight:bold;">255</span> <span style="color: #000066; font-weight: bold;">-</span> c0
<span style="color: #009900; font-style: italic;">// OVERLAY</span>
<span style="color: #004993;">c</span> = c0 <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">128</span> <span style="color: #000066; font-weight: bold;">?</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> c1 <span style="color: #000066; font-weight: bold;">*</span> c0 <span style="color: #000000;">&#41;</span> <span style="color: #009966; font-style: italic;">/ 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) /</span> <span style="color: #000000; font-weight:bold;">127</span> <span style="color: #000000;">&#41;</span>
<span style="color: #009900; font-style: italic;">// HARDLIGHT</span>
<span style="color: #004993;">c</span> = c1 <span style="color: #000066; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight:bold;">128</span> <span style="color: #000066; font-weight: bold;">?</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> c1 <span style="color: #000066; font-weight: bold;">*</span> c0 <span style="color: #000000;">&#41;</span> <span style="color: #009966; font-style: italic;">/ 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) /</span> <span style="color: #000000; font-weight:bold;">127</span> <span style="color: #000000;">&#41;</span></pre></td></tr></table></div><p>For example if you like to compute the average colors from 2 different bitmaps, you can follow like this: </pre><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
</pre></td><td
class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.*;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.geom</span><span style="color: #000066; font-weight: bold;">.*;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//-- test here 2 colorvalues</span>
<span style="color: #6699cc; font-weight: bold;">var</span> c0<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">234</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> c1<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">255</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//-- source bitmaps</span>
<span style="color: #6699cc; font-weight: bold;">var</span> b0<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> c0 <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> b1<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> c1 <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//-- resulting bitmap</span>
<span style="color: #6699cc; font-weight: bold;">var</span> be<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">BitmapData</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">256</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">256</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//-- compute average</span>
<span style="color: #6699cc; font-weight: bold;">var</span> half<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #004993;">ColorTransform</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ColorTransform</span><span style="color: #000000;">&#40;</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">.</span>5<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
be<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span> b0<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000066; font-weight: bold;">,</span> half <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
be<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span> b1<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Matrix</span><span style="color: #000066; font-weight: bold;">,</span> half<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">'add'</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> be<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getPixel</span><span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Math</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">floor</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> c0 <span style="color: #000066; font-weight: bold;">+</span> c1 <span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000; font-weight:bold;">2</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div><p>Of course this is a simple one, but you get the idea.</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/how-to-clone-duplicate-an-object-in-actionscript-3/' rel='bookmark' title='Permanent Link: How to clone (duplicate) an object in ActionScript 3'>How to clone (duplicate) an object in ActionScript 3</a></li><li><a
href='http://blog.another-d-mention.ro/programming/how-to-center-a-image-on-a-canvas-in-flex/' rel='bookmark' title='Permanent Link: How To &#8211; Center a image on a canvas in flex'>How To &#8211; Center a image on a canvas in flex</a></li><li><a
href='http://blog.another-d-mention.ro/programming/right-click-and-custom-context-menu-in-flash-flex/' rel='bookmark' title='Permanent Link: Right click and custom context menu in Flash/Flex'>Right click and custom context menu in Flash/Flex</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/flex-actionscript/blend-modes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
