﻿<?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>Armando Leopoldo Keller &#187; Actionscript 3</title>
	<atom:link href="http://armandokeller.com/blog/tag/actionscript-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://armandokeller.com/blog</link>
	<description>Actionscript, AIR, Python, Engenharia Elétrica....</description>
	<lastBuildDate>Tue, 24 Jan 2012 19:26:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>De Monster Debugger &#8211; como utilizar</title>
		<link>http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/</link>
		<comments>http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/#comments</comments>
		<pubDate>Sat, 02 May 2009 21:11:48 +0000</pubDate>
		<dc:creator>Armando Leopoldo Keller</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[flash player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Monster Debugger]]></category>
		<category><![CDATA[Trace]]></category>

		<guid isPermaLink="false">http://armandokeller.com/blog/?p=59</guid>
		<description><![CDATA[Exemplo rapido de como utilizar o MonsterDebugger.]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:left;"><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript">
			<!-- 
				tweetmeme_url = "http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/";
				tweetmeme_source = "tweetmeme";
				tweetmeme_style = "";
				
			//-->
			</script>
                        <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script>
			<!-- 
			var fbShare = {
				url: "http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/",
				size: "large",
				google_analytics: "true"
			}
			//-->
			</script>
                        <script src="http://widgets.fbshare.me/files/fbshare.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript"><!-- 
		(function() {
		var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
		s.type = 'text/javascript';
		s.async = true;
		s.src = 'http://widgets.digg.com/buttons.js';
		s1.parentNode.insertBefore(s, s1);
		})();
		//-->
		</script><a class="DiggThisButton " href="http://digg.com/submit?url=http%3A%2F%2Farmandokeller.com%2Fblog%2F2009%2F05%2Fde-monster-debugger-como-utilizar%2F"></a></div><div class="socialize-in-button socialize-in-button-vertical"><div class="delicious-button"><div class="del-top"><span id="59">0</span>saves</div><div class="del-bot"><a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;">Save</a></div></div>
		<script>
			<!-- 
			function displayURL(data) { var urlinfo = data[0]; if (!urlinfo.total_posts) return;document.getElementById('59').innerHTML = urlinfo.total_posts;}
			//-->
		</script>
		<script src = "http://badges.del.icio.us/feeds/json/url/data?url=http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/&amp;callback=displayURL"></script></div></div><p>Faz tempo que eu não posto nada, devido a falta de tempo , e de ideias sobre o que postar.<br />
Hoje, resolvi postar sobre como utilizar o MonsterDebugger, o melhor debugger que eu ja vi para actionscript.</p>
<p>Primeiro, o que é esse MonsterDebugger ?<br />
O <a href="http://demonsterdebugger.com/">MonsterDebugger ( http://demonsterdebugger.com/ )</a>  é um debugger Open Source feito em AIR, que permite debugar aplicaçoes Actionscript (flash, flex, air &#8230;), não só dando trace, mas podendo editar as propriedades dos objetos em tempo real, e podendo executar os metodos dos objetos quando quiser. Alem de claro, dar trace nas coisas (se for algum array, xml, objeto &#8230;  ele apresenta o conteudo em arvore, assim fica mais facil de debuggar).</p>
<p>Agora sim, vou mostrar como se usa ele.</p>
<p>1 &#8211; Instale o client:<br />
Va em <a href="http://demonsterdebugger.com/">http://demonsterdebugger.com/</a> , pegue a versão mais recente do MonsterDebugger e instale ele no seu computador. </p>
<p>2 &#8211; Gere as classes necessarias:<br />
Abra o client (instalado anteriormente) e va em File -> Export Client Class<br />
<img src="http://armandokeller.com/blog/imagens/exportar-classe-cliente.jpg" alt="Exportar Classe Cliente - MonsterDebugger" /></p>
<p>3 &#8211; Se quiser pode gerar um exemplo (File -> Export example), ou pode tentar usar direto sem o exemplo.</p>
<p>Como dar um simples Trace:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;">MonsterDebugger<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">,</span> o_que_é_para_ir_no_trace<span style="color: #000000;">&#41;</span></pre></td></tr></table></div>

<p>Como ativar o live application:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> _debugger<span style="color: #000066; font-weight: bold;">:</span>MonsterDebugger<span style="color: #000066; font-weight: bold;">;</span>
_debugger = <span style="color: #0033ff; font-weight: bold;">new</span> MonsterDebugger<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p>A parte de utilizar o Client é bem intuitiva, caso alguem tenha duvidas de como utilizar, favor me avisar que eu coloco aqui detalhadamente como utilizar.</p>
<p>Lembrando que aceito sugestoes de posts, é só entrar em contato.</p>
]]></content:encoded>
			<wfw:commentRss>http://armandokeller.com/blog/2009/05/de-monster-debugger-como-utilizar/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Conexão AS3 com python via socket (simplificado)</title>
		<link>http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/</link>
		<comments>http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 17:30:41 +0000</pubDate>
		<dc:creator>Armando Leopoldo Keller</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[conexao]]></category>
		<category><![CDATA[Flash geral]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Socket]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://alkeller.wordpress.com/2009/01/17/conexo-as3-com-python-via-socket-simplificado/</guid>
		<description><![CDATA[Algumas vezes me perguntei como fazer algumas coisas mais complexas em AIR de uma maneira rapida e segura, como por exemplo pegar informaçoes do usuario, conectar com um banco de dados (sem ser o nativo do AIR) como oracle,mssql… executar linha de comando, e outras coisas que só seriam possiveis utilizando alguma outra linguagem mais poderosa. Levando em conta que isto realmente era necessario para aumentar o “poder” do AIR e que o AMF fazia algo parecido, só que para a internet, resolvi criar uma classe em AS e uma função em Python que facilita a comunicação entre os dois (deixe o servidor python rodando de fundo e chame as funçoes dele :D )]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:left;"><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript">
			<!-- 
				tweetmeme_url = "http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/";
				tweetmeme_source = "tweetmeme";
				tweetmeme_style = "";
				
			//-->
			</script>
                        <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script>
			<!-- 
			var fbShare = {
				url: "http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/",
				size: "large",
				google_analytics: "true"
			}
			//-->
			</script>
                        <script src="http://widgets.fbshare.me/files/fbshare.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript"><!-- 
		(function() {
		var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
		s.type = 'text/javascript';
		s.async = true;
		s.src = 'http://widgets.digg.com/buttons.js';
		s1.parentNode.insertBefore(s, s1);
		})();
		//-->
		</script><a class="DiggThisButton " href="http://digg.com/submit?url=http%3A%2F%2Farmandokeller.com%2Fblog%2F2009%2F01%2Fconexo-as3-com-python-via-socket-simplificado%2F"></a></div><div class="socialize-in-button socialize-in-button-vertical"><div class="delicious-button"><div class="del-top"><span id="41">0</span>saves</div><div class="del-bot"><a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;">Save</a></div></div>
		<script>
			<!-- 
			function displayURL(data) { var urlinfo = data[0]; if (!urlinfo.total_posts) return;document.getElementById('41').innerHTML = urlinfo.total_posts;}
			//-->
		</script>
		<script src = "http://badges.del.icio.us/feeds/json/url/data?url=http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/&amp;callback=displayURL"></script></div></div><p>Algumas vezes me perguntei como fazer algumas coisas mais complexas em AIR de uma maneira rapida e segura, como por exemplo pegar informaçoes do usuario, conectar com um banco de dados (sem ser o nativo do AIR) como oracle,mssql… executar linha de comando, e outras coisas que só seriam possiveis utilizando alguma outra linguagem mais poderosa. Levando em conta que isto realmente era necessario para aumentar o “poder” do AIR e que o AMF fazia algo parecido, só que para a internet, resolvi criar uma classe em AS e uma função em Python que facilita a comunicação entre os dois (deixe o servidor python rodando de fundo e chame as funçoes dele <img src='http://armandokeller.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  )</p>
<p>Primeiro a classe Python.as que pode ser baixada <a href="http://cid-cd79b3b43841b5ae.skydrive.live.com/self.aspx/.Public/Python.as">aqui</a> :</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
</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> com<span style="color: #000066; font-weight: bold;">.</span>adobe<span style="color: #000066; font-weight: bold;">.</span>serialization<span style="color: #000066; font-weight: bold;">.</span>json<span style="color: #000066; font-weight: bold;">.</span>JSON<span style="color: #000066; font-weight: bold;">;</span>
    <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Socket</span><span style="color: #000066; font-weight: bold;">;</span>
   <span style="color: #3f5fbf;">/**
     * Classe para conexao com python utilizando socket
     * @author    Armando Leopoldo Keller - (http://alkeller.wordpress.com) - alkeller@live.de
     */</span>
    <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Python <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Socket</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #009900; font-style: italic;">// TODO: Implementar um metodo de retorno, verificando o tipo do retorno, e passando como parametro na funcao associada</span>
        <span style="color: #3f5fbf;">/**
         * Cria um novo Socket
         * @param host    Host onde esta o socket
         * @param port    Porta que esta o socket
         * @see flash.net.Socket
         * @usage    var p:Python = new Python(&quot;10.1.1.23&quot;,2727);
         */</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Python<span style="color: #000000;">&#40;</span>host<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">,</span> port<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">uint</span>=<span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#41;</span>        <span style="color: #000000;">&#123;</span>
            <span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span>host<span style="color: #000066; font-weight: bold;">,</span> port<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            host = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
            port = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #3f5fbf;">/**
         * Chama uma funcao do python se o socket estiver conectado 
         * @param func    Nome da funcao a ser chamada no python
         * @param args    Argumentos a serem chamados no python
         * @usage p.call(&quot;teste&quot;,{um:1,dois:2,tres:3});
         * @usage p.call(&quot;teste&quot;);
         */</span>
        <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span>func<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span><span style="color: #000066; font-weight: bold;">,</span>args<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span>=<span style="color: #0033ff; font-weight: bold;">null</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>
            <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connected</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">flush</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #6699cc; font-weight: bold;">var</span> obj<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Object</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Object</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                obj<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;funcao&quot;</span><span style="color: #000000;">&#93;</span> = func<span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">for</span><span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:*</span> <span style="color: #0033ff; font-weight: bold;">in</span> args<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>args<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> <span style="color: #0033ff; font-weight: bold;">is</span> <span style="color: #004993;">String</span><span style="color: #000000;">&#41;</span> args<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;'&quot;</span><span style="color: #000066; font-weight: bold;">+</span>args<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">+</span><span style="color: #990000;">&quot;'&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
                    obj<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>=args<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">writeUTFBytes</span><span style="color: #000000;">&#40;</span>JSON<span style="color: #000066; font-weight: bold;">.</span>encode<span style="color: #000000;">&#40;</span>obj<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                obj = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">else</span>
                <span style="color: #0033ff; font-weight: bold;">throw</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: #990000;">&quot;Voce deve estar conectado ao socket.&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">flush</span><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></td></tr></table></div>

<p>Depois é necessario a função em python que vai reconhecer o que está sendo chamado pelo flash, o arquivo pode ser baixado <a href="http://cid-cd79b3b43841b5ae.skydrive.live.com/self.aspx/.Public/JMF.py">aqui</a> :</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
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> json<span style="color: #66cc66;">;</span>
<span style="color: #ff7700;font-weight:bold;">def</span> executar<span style="color: black;">&#40;</span>objeto<span style="color: black;">&#41;</span>:
    __arr__ = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">;</span>
    <span style="color: #0000cd;">__str__</span> = <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #66cc66;">;</span>
    obj = json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>objeto<span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #0000cd;">__str__</span> = <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;funcao&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;(&quot;</span><span style="color: #66cc66;">;</span>
    obj.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;funcao&quot;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>obj.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;;</span>= <span style="color: #ff4500;">1</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> k <span style="color: #ff7700;font-weight:bold;">in</span> obj:
            __arr__.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>k<span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;=&quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#91;</span>k<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>__arr__<span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
            <span style="color: #0000cd;">__str__</span> = <span style="color: #0000cd;">__str__</span>+__arr__<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;,&quot;</span><span style="color: #66cc66;">;</span>
        <span style="color: #0000cd;">__str__</span> = <span style="color: #0000cd;">__str__</span> +__arr__<span style="color: black;">&#91;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>__arr__<span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>+<span style="color: #483d8b;">&quot;)&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #0000cd;">__str__</span> = <span style="color: #0000cd;">__str__</span>+<span style="color: #483d8b;">&quot;)&quot;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #0000cd;">__str__</span><span style="color: #66cc66;">;</span></pre></td></tr></table></div>

<p>Agora precisamos de um “servidor socket” rodando de fundo com as funçoes a serem chamadas, que pode ser baixado <a href="http://cid-cd79b3b43841b5ae.skydrive.live.com/self.aspx/.Public/ServidorPython.py">aqui</a> :</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
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">socket</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">threading</span>
<span style="color: #ff7700;font-weight:bold;">import</span> json
<span style="color: #ff7700;font-weight:bold;">from</span> JMF <span style="color: #ff7700;font-weight:bold;">import</span> executar
<span style="color: #ff7700;font-weight:bold;">class</span> ClientThread <span style="color: black;">&#40;</span> <span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span> <span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span> <span style="color: black;">&#40;</span> <span style="color: #008000;">self</span>, channel, details <span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span> = channel
        <span style="color: #008000;">self</span>.<span style="color: black;">details</span> = details
        <span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span>.<span style="color: #0000cd;">__init__</span> <span style="color: black;">&#40;</span> <span style="color: #008000;">self</span> <span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> run <span style="color: black;">&#40;</span> <span style="color: #008000;">self</span> <span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Conexao recebida: '</span>, <span style="color: #008000;">self</span>.<span style="color: black;">details</span> <span style="color: black;">&#91;</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#93;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">send</span> <span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;resposta vinda do python&quot;</span> <span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span> <span style="color: black;">&#40;</span> <span style="color: #ff4500;">10</span> <span style="color: black;">&#41;</span>:
            <span style="color: #dc143c;">string</span> = <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">recv</span> <span style="color: black;">&#40;</span> <span style="color: #ff4500;">1024</span> <span style="color: black;">&#41;</span>
            <span style="color: #008000;">self</span>.<span style="color: black;">interpretaComando</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Conexao fechada: '</span>, <span style="color: #008000;">self</span>.<span style="color: black;">details</span> <span style="color: black;">&#91;</span> <span style="color: #ff4500;">0</span> <span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> interpretaComando<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,<span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">eval</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;self.&quot;</span>+executar<span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">string</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> testar<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,arg1,arg2<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Chamou testar: &quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>arg1<span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;,&quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>arg2<span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Chamou testar: &quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>arg1<span style="color: black;">&#41;</span>+<span style="color: #483d8b;">&quot;,&quot;</span>+<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>arg2<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> pegaVariaveis<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;chamou pegaVariaveis&quot;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">send</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;chamou pegaVariaveis&quot;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> pegarArray<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Chamou pegar Array&quot;</span><span style="color: #66cc66;">;</span>
        arr = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'a'</span>,<span style="color: #483d8b;">'b'</span>,<span style="color: #483d8b;">'c'</span>,<span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">2</span>,<span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">;</span>
        txt = json.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>arr<span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">send</span><span style="color: black;">&#40;</span>txt<span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff7700;font-weight:bold;">def</span> pegarObj<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Chamou pegar Objeto&quot;</span><span style="color: #66cc66;">;</span>
        teste = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
        teste<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;item1&quot;</span><span style="color: black;">&#93;</span>   =   <span style="color: #483d8b;">&quot;Primeiro item&quot;</span><span style="color: #66cc66;">;</span>
        teste<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;item2&quot;</span><span style="color: black;">&#93;</span>   =   <span style="color: #483d8b;">&quot;Segundo item&quot;</span><span style="color: #66cc66;">;</span>
        teste<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;numero&quot;</span><span style="color: black;">&#93;</span>  =   <span style="color: #ff4500;">2</span><span style="color: #66cc66;">;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">channel</span>.<span style="color: black;">send</span><span style="color: black;">&#40;</span>json.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>teste<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;"># Inicia o servidor</span>
server = <span style="color: #dc143c;">socket</span>.<span style="color: #dc143c;">socket</span> <span style="color: black;">&#40;</span> <span style="color: #dc143c;">socket</span>.<span style="color: black;">AF_INET</span>, <span style="color: #dc143c;">socket</span>.<span style="color: black;">SOCK_STREAM</span> <span style="color: black;">&#41;</span>
server.<span style="color: black;">bind</span> <span style="color: black;">&#40;</span> <span style="color: black;">&#40;</span> <span style="color: #dc143c;">socket</span>.<span style="color: black;">gethostbyname</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">socket</span>.<span style="color: black;">gethostname</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, <span style="color: #ff4500;">2727</span> <span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
server.<span style="color: black;">listen</span> <span style="color: black;">&#40;</span> <span style="color: #ff4500;">5</span> <span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Iniciando servidor...&quot;</span>
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    channel, details = server.<span style="color: black;">accept</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    ClientThread <span style="color: black;">&#40;</span> channel, details<span style="color: black;">&#41;</span>.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Pronto, agora só falta uma aplicação de exemplo chamando estas funçoes, que pode ser baixada <a href="http://cid-cd79b3b43841b5ae.skydrive.live.com/self.aspx/.Public/PyFlex.mxml">aqui</a> :</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
74
75
76
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">&lt;?</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>WindowedApplication applicationComplete=<span style="color: #990000;">&quot;iniciar()&quot;</span> 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><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>Script<span style="color: #000066; font-weight: bold;">&gt;</span>
        <span style="color: #000066; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
            <span style="color: #0033ff; font-weight: bold;">import</span> com<span style="color: #000066; font-weight: bold;">.</span>adobe<span style="color: #000066; font-weight: bold;">.</span>serialization<span style="color: #000066; font-weight: bold;">.</span>json<span style="color: #000066; font-weight: bold;">.</span>JSON<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> py<span style="color: #000066; font-weight: bold;">:</span>Python
            <span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> texto<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;&quot;</span>
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> iniciar<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>
                py = <span style="color: #0033ff; font-weight: bold;">new</span> Python<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">ProgressEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">SOCKET_DATA</span><span style="color: #000066; font-weight: bold;">,</span>onRecebe<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CONNECT</span><span style="color: #000066; font-weight: bold;">,</span>onConecta<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">IOErrorEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">IO_ERROR</span><span style="color: #000066; font-weight: bold;">,</span>onErroIO<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;10.1.1.3&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">2727</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onRecebe<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">ProgressEvent</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>
                <span style="color: #6699cc; font-weight: bold;">var</span> str<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">String</span> = py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">readUTFBytes</span><span style="color: #000000;">&#40;</span>py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">bytesAvailable</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                texto = str<span style="color: #000066; font-weight: bold;">;</span>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">flush</span><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: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onConecta<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</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>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Conectou&quot;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> chamarTeste<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>
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connected</span><span style="color: #000000;">&#41;</span>
                    py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;testar&quot;</span><span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000;">&#123;</span>arg1<span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;Argumento 1&quot;</span><span style="color: #000066; font-weight: bold;">,</span>arg2<span style="color: #000066; font-weight: bold;">:</span><span style="color: #990000;">&quot;Argumento 2&quot;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                    texto = <span style="color: #990000;">&quot;O socket esta desconectado&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> chamarPegaVariaveis<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>
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connected</span><span style="color: #000000;">&#41;</span>
                    py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;pegaVariaveis&quot;</span><span style="color: #000000;">&#41;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                    texto = <span style="color: #990000;">&quot;O socket esta desconectado&quot;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> pegarArray<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>
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connected</span><span style="color: #000000;">&#41;</span>
                    py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;pegarArray&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                    texto = <span style="color: #990000;">&quot;O socket esta desconectado&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> pegarObj<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>
                <span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connected</span><span style="color: #000000;">&#41;</span>
                    py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;pegarObj&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                <span style="color: #0033ff; font-weight: bold;">else</span>
                    texto = <span style="color: #990000;">&quot;O socket esta desconectado&quot;</span><span style="color: #000066; font-weight: bold;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> matarServer<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>
                py<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
                texto = <span style="color: #990000;">&quot;Desconectado&quot;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> onErroIO<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">IOErrorEvent</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>
                <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Erro ao conectar com o socket&quot;</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;">&#93;</span><span style="color: #000000;">&#93;</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>Script<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>VBox<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>HBox<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>Button label = <span style="color: #990000;">&quot;Testar&quot;</span>         <span style="color: #004993;">click</span> = <span style="color: #990000;">&quot;chamarTeste()&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>Button label = <span style="color: #990000;">&quot;PegaVar&quot;</span>        <span style="color: #004993;">click</span> = <span style="color: #990000;">&quot;chamarPegaVariaveis()&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>Button label = <span style="color: #990000;">&quot;pegarArray&quot;</span>     <span style="color: #004993;">click</span> = <span style="color: #990000;">&quot;pegarArray()&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>Button label = <span style="color: #990000;">&quot;pegarObj&quot;</span>       <span style="color: #004993;">click</span> = <span style="color: #990000;">&quot;pegarObj()&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>Button label = <span style="color: #990000;">&quot;Kill Server&quot;</span>    <span style="color: #004993;">click</span> = <span style="color: #990000;">&quot;matarServer()&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>HBox<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>Text <span style="color: #004993;">text</span>=<span style="color: #990000;">&quot;{texto}&quot;</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;100%&quot;</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;115&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>VBox<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>WindowedApplication<span style="color: #000066; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>Claro que esta aplicação ainda está bastante simples, mas o objetivo é demonstrar como pode ser facil conectar o AS3 com Python utilizando socket, para quem não conhece python, vale a pena dar uma estudada, é uma linguagem muito util, poderosa, e simples, que é utilizada em diversos lugares, alguns exemplos bons são nasa e google (precisa mais ? ), agora mistura isso com AS3  (tem algo MUITO funcional e bonito).</p>
<p><strong>Explicação rapida</strong></p>
<p>A sintaxe é muito parecida com a Tweener (classe de tween) que ja é bastante conhecida, então creio que não deve ter muita dificuldade para utilizar esta classe. Sendo que para chamar uma função do python é só chamar     instancia.call(“nome_da_funcao”,{nome_do_argumento:valor_do_argumento…….});</p>
<p>Se alguem tiver alguma duvida, ou sugestão para esta classe ou para futuras classes, deixe um comentario ou envie por email mesmo.</p>
<p>A formatação dos codigos ainda  não está boa, mas esta melhorando (plugin do Windows Live Writer)  se alguem conhecer algum plugin para formatar codigos que tenha suporte a AS, Python, PHP,e C  me avisa.</p>
]]></content:encoded>
			<wfw:commentRss>http://armandokeller.com/blog/2009/01/conexo-as3-com-python-via-socket-simplificado/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>NativeMenu em AIR (flash)</title>
		<link>http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/</link>
		<comments>http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 21:04:42 +0000</pubDate>
		<dc:creator>Armando Leopoldo Keller</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Flash geral]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Apollo]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Menu]]></category>
		<category><![CDATA[NativeMenu]]></category>
		<category><![CDATA[NativeMenuItem]]></category>

		<guid isPermaLink="false">http://alkeller.wordpress.com/?p=11</guid>
		<description><![CDATA[0savesSave Olá, segue abaixo um exemplo comentado de como utilizar menus(como os da maioria dos softwares) em AIR, é um exemplo básico baseado em tutoriais da Adobe. 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 [...]]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:left;"><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript">
			<!-- 
				tweetmeme_url = "http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/";
				tweetmeme_source = "tweetmeme";
				tweetmeme_style = "";
				
			//-->
			</script>
                        <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script>
			<!-- 
			var fbShare = {
				url: "http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/",
				size: "large",
				google_analytics: "true"
			}
			//-->
			</script>
                        <script src="http://widgets.fbshare.me/files/fbshare.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript"><!-- 
		(function() {
		var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
		s.type = 'text/javascript';
		s.async = true;
		s.src = 'http://widgets.digg.com/buttons.js';
		s1.parentNode.insertBefore(s, s1);
		})();
		//-->
		</script><a class="DiggThisButton " href="http://digg.com/submit?url=http%3A%2F%2Farmandokeller.com%2Fblog%2F2008%2F03%2Fnativemenu-em-air-flash%2F"></a></div><div class="socialize-in-button socialize-in-button-vertical"><div class="delicious-button"><div class="del-top"><span id="11">0</span>saves</div><div class="del-bot"><a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;">Save</a></div></div>
		<script>
			<!-- 
			function displayURL(data) { var urlinfo = data[0]; if (!urlinfo.total_posts) return;document.getElementById('11').innerHTML = urlinfo.total_posts;}
			//-->
		</script>
		<script src = "http://badges.del.icio.us/feeds/json/url/data?url=http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/&amp;callback=displayURL"></script></div></div><p>Olá, segue abaixo um exemplo comentado de como utilizar menus(como os da maioria dos softwares) em AIR, é um exemplo básico baseado em tutoriais da Adobe.</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
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/*
Primeiro crie um arquivo novo(air)
crie um campo de texto com o tamanho que desejar
instancie o campo de texto como &quot;texto&quot; (sem as aspas)
cole o codigo a seguir no primeiro frame
*/</span>
&nbsp;
<span style="color: #009900; font-style: italic;">// importa	as classes necessarias</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span>NativeMenu<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span>NativeMenuItem<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span>NativeWindow<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #0033ff; font-weight: bold;">import</span> flash<span style="color: #000066; font-weight: bold;">.</span>desktop<span style="color: #000066; font-weight: bold;">.</span>NativeApplication<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #009900; font-style: italic;">//declara os 2 items do menu</span>
<span style="color: #6699cc; font-weight: bold;">var</span> Menu01<span style="color: #000066; font-weight: bold;">:</span>NativeMenuItem<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #6699cc; font-weight: bold;">var</span> Menu02<span style="color: #000066; font-weight: bold;">:</span>NativeMenuItem<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>NativeWindow<span style="color: #000066; font-weight: bold;">.</span>supportsMenu<span style="color: #000000;">&#41;</span><span style="color: #009900; font-style: italic;">// Se o sistema operacional for windows</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>menu = <span style="color: #0033ff; font-weight: bold;">new</span> NativeMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//cria o menu</span>
	<span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">SELECT</span><span style="color: #000066; font-weight: bold;">,</span> selecionouUmItem<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona um evento de seleção no menu</span>
	Menu01 = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Primeiro item&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o primeiro item no menu</span>
	Menu01<span style="color: #000066; font-weight: bold;">.</span>submenu = criaSubMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// adiciona o submenu(que vai ser criado logo abaixo) ao primeiro item</span>
	Menu02 = <span style="color: #004993;">stage</span><span style="color: #000066; font-weight: bold;">.</span>nativeWindow<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Segundo item&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o segundo item no menu</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>NativeApplication<span style="color: #000066; font-weight: bold;">.</span>supportsMenu<span style="color: #000000;">&#41;</span><span style="color: #009900; font-style: italic;">// se o sistema operacionall for mac</span>
<span style="color: #000000;">&#123;</span>
	Menu01 = NativeApplication<span style="color: #000066; font-weight: bold;">.</span>nativeApplication<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Primeiro item&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o primeiro item no menu</span>
	NativeApplication<span style="color: #000066; font-weight: bold;">.</span>nativeApplication<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">SELECT</span><span style="color: #000066; font-weight: bold;">,</span> selecionouUmItem<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona um evento de seleção no menu</span>
	Menu01<span style="color: #000066; font-weight: bold;">.</span>submenu = criaSubMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// adiciona o submenu(que vai ser criado logo abaixo) ao primeiro item</span>
	Menu02 = NativeApplication<span style="color: #000066; font-weight: bold;">.</span>nativeApplication<span style="color: #000066; font-weight: bold;">.</span>menu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Segundo item&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o segundo item no menu</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> criaSubMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span>NativeMenu
<span style="color: #000000;">&#123;</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> tmpMenu<span style="color: #000066; font-weight: bold;">:</span>NativeMenu = <span style="color: #0033ff; font-weight: bold;">new</span> NativeMenu<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// cria o submenu do primeiro item</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> MenuNovo<span style="color: #000066; font-weight: bold;">:</span>NativeMenuItem = tmpMenu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Novo&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o item &quot;Novo&quot; ao submenu</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> MenuSalva<span style="color: #000066; font-weight: bold;">:</span>NativeMenuItem = tmpMenu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Salva&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o item &quot;Salva&quot; ao submenu</span>
	<span style="color: #6699cc; font-weight: bold;">var</span> MenuSair<span style="color: #000066; font-weight: bold;">:</span>NativeMenuItem = tmpMenu<span style="color: #000066; font-weight: bold;">.</span>addItem<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> NativeMenuItem<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Sair&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><span style="color: #009900; font-style: italic;">//adiciona o item &quot;Sair&quot; ao submenu</span>
	<span style="color: #0033ff; font-weight: bold;">return</span> tmpMenu<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339966; font-weight: bold;">function</span> selecionouUmItem<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	texto<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = e<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span>label <span style="color: #009900; font-style: italic;">// escreve o nome do item selecionado no campo de texto</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p>Qualquer duvida é só postar que eu respondo.</p>
<p>Assim que sobrar algum tempo por aqui eu postarei um tutorial (bem detalhado) e com os exemplos, de como utilizar um banco de dados local com o AIR.</p>
]]></content:encoded>
			<wfw:commentRss>http://armandokeller.com/blog/2008/03/nativemenu-em-air-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Classe de validação de formularios</title>
		<link>http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/</link>
		<comments>http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 19:34:37 +0000</pubDate>
		<dc:creator>Armando Leopoldo Keller</dc:creator>
				<category><![CDATA[AS 3.0]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[campos]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[formularios]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[validação]]></category>

		<guid isPermaLink="false">http://alkeller.wordpress.com/?p=8</guid>
		<description><![CDATA[0savesSave Oi, eu fiquei um tempo sem postar devido a falta de tempo ( muito trabalho) . Mas ai vai uma classe que poupa muito tempo na validação de formularios // Teste.as package alkeller &#123; public class Teste &#123; private var campos:Array &#160; public function Teste&#40;&#41; &#123; this.campos = new Array&#40;&#41;; &#125; public function adiciona&#40;Campo, [...]]]></description>
			<content:encoded><![CDATA[<div class="socialize-in-content" style="float:left;"><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript">
			<!-- 
				tweetmeme_url = "http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/";
				tweetmeme_source = "tweetmeme";
				tweetmeme_style = "";
				
			//-->
			</script>
                        <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script>
			<!-- 
			var fbShare = {
				url: "http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/",
				size: "large",
				google_analytics: "true"
			}
			//-->
			</script>
                        <script src="http://widgets.fbshare.me/files/fbshare.js"></script></div><div class="socialize-in-button socialize-in-button-vertical"><script type="text/javascript"><!-- 
		(function() {
		var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];
		s.type = 'text/javascript';
		s.async = true;
		s.src = 'http://widgets.digg.com/buttons.js';
		s1.parentNode.insertBefore(s, s1);
		})();
		//-->
		</script><a class="DiggThisButton " href="http://digg.com/submit?url=http%3A%2F%2Farmandokeller.com%2Fblog%2F2008%2F02%2Fclasse-de-validacao-de-formularios%2F"></a></div><div class="socialize-in-button socialize-in-button-vertical"><div class="delicious-button"><div class="del-top"><span id="8">0</span>saves</div><div class="del-bot"><a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;">Save</a></div></div>
		<script>
			<!-- 
			function displayURL(data) { var urlinfo = data[0]; if (!urlinfo.total_posts) return;document.getElementById('8').innerHTML = urlinfo.total_posts;}
			//-->
		</script>
		<script src = "http://badges.del.icio.us/feeds/json/url/data?url=http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/&amp;callback=displayURL"></script></div></div><p>Oi, eu fiquei um tempo sem postar devido a falta de tempo ( muito trabalho) .</p>
<p>Mas ai vai uma classe que poupa muito tempo na validação de formularios</p>
<p>// Teste.as</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> alkeller
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Teste
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> campos<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Array</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Teste<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><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: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> adiciona<span style="color: #000000;">&#40;</span>Campo<span style="color: #000066; font-weight: bold;">,</span> Nome<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#123;</span> campo<span style="color: #000066; font-weight: bold;">:</span>Campo<span style="color: #000066; font-weight: bold;">,</span> nome<span style="color: #000066; font-weight: bold;">:</span>Nome <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Verifica<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> i<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">0</span> <span style="color: #000066; font-weight: bold;">;</span> i <span style="color: #000066; font-weight: bold;">&amp;</span>lt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</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>
<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>campo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #0033ff; font-weight: bold;">undefined</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">||</span>
<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>campo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #990000;">&quot;undefined&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">||</span>
<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>campo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #990000;">&quot;&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">||</span>
<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>campo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">||</span>
<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>campo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> == <span style="color: #990000;">&quot; &quot;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #990000;">&quot;Preencha o campo &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000066; font-weight: bold;">.</span>campos<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>nome<span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</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>E para utilizar é simples:<br />
1º &#8211; Crie um movieClip e instancie ele como &#8220;bt&#8221;(sem as aspas).<br />
2º &#8211; Crie 5 campos de texto tipo input e instancie eles como(&#8220;cp1&#8243;,&#8221;cp2&#8243; &#8230;&#8230;) obs: isso é só um exemplo, pode ser quantos campos você quiser e com o nome que você quiser.<br />
3º &#8211; Crie um campo  de texto dinamico e instancie ele de resultado<br />
4º &#8211; Cole o codigo abaixo no frame<br />
5º &#8211; Teste<br />
// Teste.fla   1º frame</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"> <span style="color: #0033ff; font-weight: bold;">import</span> alkeller<span style="color: #000066; font-weight: bold;">.</span>Teste
<span style="color: #6699cc; font-weight: bold;">var</span> ve<span style="color: #000066; font-weight: bold;">:</span>Teste = <span style="color: #0033ff; font-weight: bold;">new</span> Teste<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ve<span style="color: #000066; font-weight: bold;">.</span>adiciona<span style="color: #000000;">&#40;</span>cp1<span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Campo 1&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ve<span style="color: #000066; font-weight: bold;">.</span>adiciona<span style="color: #000000;">&#40;</span>cp2<span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Campo 2&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ve<span style="color: #000066; font-weight: bold;">.</span>adiciona<span style="color: #000000;">&#40;</span>cp3<span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Campo 3&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ve<span style="color: #000066; font-weight: bold;">.</span>adiciona<span style="color: #000000;">&#40;</span>cp4<span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Campo 4&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
ve<span style="color: #000066; font-weight: bold;">.</span>adiciona<span style="color: #000000;">&#40;</span>cp5<span style="color: #000066; font-weight: bold;">,</span><span style="color: #990000;">&quot;Campo 5&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
bt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">MouseEvent</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">CLICK</span><span style="color: #000066; font-weight: bold;">,</span>clicou<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #339966; font-weight: bold;">function</span> clicou<span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">MouseEvent</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>
<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>ve<span style="color: #000066; font-weight: bold;">.</span>Verifica<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;">true</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
resultado<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = ve<span style="color: #000066; font-weight: bold;">.</span>Verifica<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: #0033ff; font-weight: bold;">else</span>
<span style="color: #000000;">&#123;</span>
resultado<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Tudo preenchido&quot;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Qualquer duvida é só falar.</p>
]]></content:encoded>
			<wfw:commentRss>http://armandokeller.com/blog/2008/02/classe-de-validacao-de-formularios/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

