<?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; C#</title> <atom:link href="http://blog.another-d-mention.ro/tag/c/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>Use clipboard (copy/paste) in C# console application</title><link>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/</link> <comments>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/#comments</comments> <pubDate>Mon, 01 Mar 2010 20:04:23 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[C#]]></category> <category><![CDATA[.net]]></category> <category><![CDATA[clipboard]]></category> <category><![CDATA[copy]]></category> <category><![CDATA[paste]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=805</guid> <description><![CDATA[This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&#62; Add reference, select System.Windows.Forms from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main() function. Then [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash 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><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></ol>]]></description> <content:encoded><![CDATA[<p><img
src="http://cache.another-d-mention.ro/images/wp-content/uploads/2010/03/net_logo.jpg-150x150.png" alt="net logo.jpg 150x150 Use clipboard (copy/paste) in C# console application" title="net_logo.jpg" width="150" height="150" class="alignleft size-thumbnail wp-image-806" />This took me few minutes to figure out and was quite annoying. First you must add a reference to System.Windows.Forms in your application. Go to Project -&gt; Add reference, select <strong>System.Windows.Forms</strong> from .NET tab in the window that just opened.  You must avoid the ThreadStateException by applying the STAThread attribute to your Main()  function. Then you can use the Clipboard functions without any problems.</p><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="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Windows.Forms</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #6666cc; font-weight: bold;">class</span> Program <span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#91;</span>STAThread<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
         Clipboard<span style="color: #008000;">.</span><span style="color: #0000FF;">SetText</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;this is in clipboard now&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/communicate-betwen-c-and-an-embeded-flash-application/' rel='bookmark' title='Permanent Link: Communicate betwen C# and an embeded Flash application'>Communicate betwen C# and an embeded Flash 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><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></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/c/use-clipboard-copypaste-in-c-console-application/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Ho-To: Install Alchemy</title><link>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/</link> <comments>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/#comments</comments> <pubDate>Wed, 24 Jun 2009 06:51:53 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Flex / ActionScript]]></category> <category><![CDATA[How To's]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[actionscript3]]></category> <category><![CDATA[alchemy]]></category> <category><![CDATA[as3]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[flash]]></category> <category><![CDATA[flex]]></category> <category><![CDATA[library]]></category> <guid
isPermaLink="false">http://blog.another-d-mention.ro/?p=493</guid> <description><![CDATA[For those of you who tried but didn't succed, I found some straigthforward instructions for this. Setup Hell: Install cygwin to "c:\cygwin" - make sure to check boxes to install Perl, "Archive" (ZIP), and Devel/gcc:g++ (3.4.4.3 presumably) (is Perl necessary?) Copy the alchemy directory to: c:\cygwin\home\Lee Copy the flex sdk bin dir from c:\program files\etc [...]
Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</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/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li></ol>]]></description> <content:encoded><![CDATA[<p>For those of you who tried but didn't succed, I found some straigthforward instructions for this.</p><h4 class="vspace">Setup Hell:</h4><p>Install cygwin to "c:\cygwin" - make sure to check boxes to install Perl, "Archive" (ZIP), and Devel/gcc:g++ (3.4.4.3 presumably) (is Perl necessary?)<br
/> Copy the alchemy directory to: c:\cygwin\home\Lee<br
/> Copy the flex sdk bin dir from c:\program files\etc to "c:\flex" (to avoid paths with spaces in it!)<br
/> Run the alchemy config script once:</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">   run cygwin
   <span style="color: #7a0874; font-weight: bold;">cd</span> alchemy
   .<span style="color: #000000; font-weight: bold;">/</span>config</pre></div></div><p>Edit the textfile "C:\cygwin\home\Lee\alchemy\alchemy-setup" and uncomment and edit line 22 to: add "export ADL=c:\flex\adl.exe"</p><p>Edit .bashrc (in C:\cygwin\home\Lee)</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;LEE PROFILE&quot;</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">FLEX_HOME</span>=~<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">flex</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">ALCHEMY_HOME</span>=~<span style="color: #000000; font-weight: bold;">/</span>alchemy
&nbsp;
   <span style="color: #666666; font-style: italic;"># &quot;This should be added before your PATH is modified&quot; !!</span>
   <span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>Lee<span style="color: #000000; font-weight: bold;">/</span>alchemy<span style="color: #000000; font-weight: bold;">/</span>alchemy-setup
&nbsp;
   <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$ALCHEMY_HOME</span><span style="color: #000000; font-weight: bold;">/</span>achacks:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>Lee<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">flex</span>:<span style="color: #007800;">$PATH</span>
   <span style="color: #7a0874; font-weight: bold;">export</span> PATH
&nbsp;
   alc-on</pre></div></div><p>Do this (just once, I think):</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">   <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$ALCHEMY_HOME</span><span style="color: #000000; font-weight: bold;">/</span>bin
   <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> llvm-stub llvm-stub.exe</pre></div></div><h4 class="vspace">Compiling a SW:</h4><p>CD to the directory with the source<br
/> Always do "alc-on" before compiling, cuz it doesn't work without it even though i added it to the startup (dunno)</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">    <span style="color: #c20cb9; font-weight: bold;">gcc</span> stringecho.c <span style="color: #660033;">-O3</span> <span style="color: #660033;">-Wall</span> <span style="color: #660033;">-swc</span> <span style="color: #660033;">-o</span> stringecho.swc
    <span style="color: #660033;">--</span> should give you a swc.</pre></div></div><p>Import the swc into your flex builder 4 project and make sure compiler targets SDK v4</p><h4 class="vspace">Shortcuts</h4><p><strong>alc-home</strong> - takes you to the Alchemy install folder.<br
/> <strong>alc-on</strong> - puts Alchemy gcc toolchain replacements at the front of your path.<br
/> <strong>alc-off</strong> - restores original path.<br
/> <strong>alc-util</strong> - shows you various Alchemy-related environment vars</p><p
class="vspace">USEFUL TO KNOW</p><p><strong>which gcc</strong> - tells you which gcc it will use (should be the one in the achacks dir)<br
/> <strong>ln</strong> - links shit<br
/> <strong>rm</strong> - deletes links as well as files</p><p
class="vspace">Ugh: Make sure to do "alc-on" and "alchemy-setup" even though you put it in the startup script <img
src='http://blog.another-d-mention.ro/wp-includes/images/smilies/icon_sad.gif' alt="icon sad Ho To: Install Alchemy" class='wp-smiley' title="Ho To: Install Alchemy" /> (?)</p><p
class="vspace">...</p><p>Objects:<br
/> <span
class="wikiword">AS3</span>_Val<br
/> <span
class="wikiword">AS3</span>_ArrayValue</p><p>Methods:<br
/> <span
class="wikiword">AS3</span>_Release<br
/> <span
class="wikiword">AS3</span>_LibInit</p><p>Related posts:<ol><li><a
href='http://blog.another-d-mention.ro/programming/flex-components-pack/' rel='bookmark' title='Permanent Link: Flex Components Pack'>Flex Components Pack</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/misc/eee-pc/install-windows-xp-on-your-asus-eee-pc-using-a-usb-flash-drive/' rel='bookmark' title='Permanent Link: Install Windows XP on your Asus Eee PC using a USB flash drive'>Install Windows XP on your Asus Eee PC using a USB flash drive</a></li></ol></p>]]></content:encoded> <wfw:commentRss>http://blog.another-d-mention.ro/programming/ho-to-install-alchemy/feed/</wfw:commentRss> <slash:comments>3</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> </channel> </rss>
