<?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>Bruno Soares &#187; ActionScript 3.0</title>
	<atom:link href="http://blog.bsoares.com.br/category/as3/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bsoares.com.br</link>
	<description></description>
	<lastBuildDate>Sun, 11 Jul 2010 02:16:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Operações binárias</title>
		<link>http://blog.bsoares.com.br/aspnet/operacoes-binarias</link>
		<comments>http://blog.bsoares.com.br/aspnet/operacoes-binarias#comments</comments>
		<pubDate>Tue, 26 May 2009 02:28:09 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Matemática]]></category>
		<category><![CDATA[Open Hardware]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=340</guid>
		<description><![CDATA[Ultimamente tenho me deparado com muitos trechos de códigos que utilizam operações binárias, como chaveamento de multiplexador, extração de RGB a partir de um inteiro ou hexadecimal, bitshift para controlar LED Matrix, etc&#8230; E finalmente dei aquela estuda, agora vai ai um post sobre o que resultou o estudo.
Obs.: Os trechos de códigos deste post [...]]]></description>
			<content:encoded><![CDATA[<p>Ultimamente tenho me deparado com muitos trechos de códigos que utilizam <a href="http://en.wikipedia.org/wiki/Bitwise_operation" target="_blank">operações binárias</a>, como chaveamento de <a href="http://pt.wikipedia.org/wiki/Multiplexador" target="_blank">multiplexador</a>, extração de <a href="http://pt.wikipedia.org/wiki/RGB" target="_blank">RGB</a> a partir de um inteiro ou <a href="http://pt.wikipedia.org/wiki/Sistema_hexadecimal" target="_blank">hexadecimal</a>, bitshift para controlar <a href="http://blog.bsoares.com.br/tag/8x8-led-matrix">LED Matrix</a>, etc&#8230; E finalmente dei aquela estuda, agora vai ai um post sobre o que resultou o estudo.</p>
<p>Obs.: Os trechos de códigos deste post foram escritos em <a href="http://blog.bsoares.com.br/tag/as3">ActionScript</a>, mas pode ser aplicado a C, <a href="http://blog.bsoares.com.br/tag/cpp">C++</a>, Java, <a href="http://blog.bsoares.com.br/tag/processing">Processing</a>, <a href="http://blog.bsoares.com.br/tag/php">PHP</a>, entre outras linguagens.</p>
<hr />
• <a href="#introducao">Introdução</a><br />
• Bit Shift<br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-right-shift">Operador >> (bitwise right shift)</a><br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-left-shift">Operador << (bitwise left shift)</a><br />
• Operações Bitwise<br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-and">Operador &#038; (bitwise AND)</a><br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-or">Operador | (bitwise OR)</a><br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-xor">Operador ^ (bitwise XOR)</a><br />
&nbsp;&nbsp;&nbsp;• <a href="#bitwise-not">Operador ~ (bitwise NOT)</a><br />
• Exemplos<br />
&nbsp;&nbsp;&nbsp;• <a href="#extract-rgb">Extraindo o RGB de uma cor</a><br />
&nbsp;&nbsp;&nbsp;• <a href="#multiplexer-4051">Chaveando multiplexador 4051</a><br />
&nbsp;</p>
<hr /><a name="introducao"><strong>Introdução</strong></a><br />
Um operador binário, como o nome sugere, é um operador que trabalha com a representação binária do número, e como normalmente não sabemos a representação binária dos números de cabeça, vamos utilizar a tabela abaixo:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;"> -----------------------
|      BIN |  DEC | HEX |
|-----------------------|
|        1 |    1 |   1 |
|       10 |    2 |   2 |
|       11 |    3 |   3 |
|      100 |    4 |   4 |
|      101 |    5 |   5 |
|      110 |    6 |   6 |
|      111 |    7 |   7 |
|     1000 |    8 |   8 |
|     1001 |    9 |   9 |
|     1010 |   10 |   A |
|     1011 |   11 |   B |
|     1100 |   12 |   C |
|     1101 |   13 |   D |
|     1110 |   14 |   E |
|     1111 |   15 |   F |
|    10000 |   16 |  10 |
|    10001 |   17 |  11 |
|    10010 |   18 |  12 |
|    10011 |   19 |  13 |
|    10100 |   20 |  14 |
|-----------------------|
| 11111111 |  255 |  FF |
 ----------------------- </pre>
<p>A tabela lista os números de 1 à 20 e 255 em três bases diferentes:<br />
• <a href="http://pt.wikipedia.org/wiki/Sistema_bin%C3%A1rio_%28matem%C3%A1tica%29" target="_blank">Binário (BIN)</a><br />
• Decimal (DEC)<br />
• <a href="http://pt.wikipedia.org/wiki/Sistema_hexadecimal" target="_blank">Hexadecimal (HEX)</a></p>
<p>Analisando a tabela podemos concluir que 3d = 11b, 19d = 10011b (as letras d e b significam decimal e binário respectivamente). Lembrando que pode ser utilizada uma calculadora que opere em binário (como a do windows) ou uma alternativa de conversão de bases on-line como está: <a href="http://calculadoraonline.com.br/view/conversao-binario.php" target="_blank">&#8220;Conversão de número binário&#8221;</a>.</p>
<p>Então vamos <strong>deslocar</strong>, <strong>escorregar</strong>, <strong>escovar</strong> alguns bits para entender melhor.</p>
<p>
<hr /><a name="bitwise-right-shift"><strong>Operador >></strong></a><br />
Deslocamento de bits para a direita (bitwise right shift)</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>8 <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 4</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>8 <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 2</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>8 <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 3<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 1</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>8 <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 4<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 0</span></div></td></tr></tbody></table></div>
<p>Olhando os números na base decimal faz pouco sentido, ou talvez nenhum sentido, então passamos os números corretos para a base binária e tudo fica mais claro:<br />
8d = 1000b (8 decimal é igual a 1000 em binário), então:<br />
1000b >> 1 (deslocando uma casa para direita) temos o número:<br />
100b que em decimal é 4(dê uma olhada na tabela).</p>
<p>Agora ficou fácil não? Vamos deslocar o número 13:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>13 <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 6</span></div></td></tr></tbody></table></div>
<p>13 em binário é 1101, deslocando uma casa para a direita (ou removendo 1 bit), fica 110, e 110 é igual a 6 em decimal.</p>
<p>
<hr /><a name="bitwise-left-shift"><strong>Operador <<</strong></a><br />
Deslocamento de bits para a esquerda (bitwise left shift)</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>2 <span style="color: #000066; font-weight: bold;">&lt;&lt;</span> 1<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 4</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>2 <span style="color: #000066; font-weight: bold;">&lt;&lt;</span> 2<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 8</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>2 <span style="color: #000066; font-weight: bold;">&lt;&lt;</span> 3<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// 16</span></div></td></tr></tbody></table></div>
<p>Agora é só seguir o mesmo raciocino já utilizando anteriormente.<br />
Se 2 em base binária é igual a 10 e deslocarmos um bit para esquerda, vamos ganhar mais um zero, ficando com 100 que é igual a 4 em decimal.</p>
<p>
<hr /><a name="bitwise-and"><strong>Operador &#038;</strong></a><br />
AND binário (bitwise AND)<br />
O operador &#038; compara bit a bit os números a sua direita e esquerda, por exemplo o resultado de 10 &#038; 11 é 10:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1010
&#038; 1011
------
  1010</pre>
<p>A comparação bit-a-bit somente retorna True (1) quando os bits comparados são iguais a 1, caso contrário retorna False (0). Formando assim um novo número.<br />
Mais alguns exemplos para fortalecer:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
|14 &#038;  9|13 &#038; 11|20 &#038;  9|14 &#038; 10|89 &#038;  112|45  &#038;  77|255  &#038;  13|112 &#038;  255|
|       |       |       |       |         |         |          |          |
|  1110 |  1101 |  10100|  1110 |  1011001|   101101|  11111111|   1110000|
|&#038; 1001 |&#038; 1011 |&#038;  1001|&#038; 1010 |&#038; 1110000|&#038; 1001101|&#038;     1101|&#038; 11111111|
|  ---- |  ---- |  -----|  ---- |  -------|  -------|  --------|  --------|
|  1000 |  1001 |      0|  1010 |  1010000|     1101|      1101|   1110000|
|    8d |    9d |     0d|   10d |      80d|      13d|       13d|      112d|</pre>
<p>
<hr /><a name="bitwise-or"><strong>Operador |</strong></a><br />
OR binário (bitwise OR)<br />
O operador | tem a mesma função do operador OR comum (||) só que atua bit-a-bit, assim como os outros operadores binários. Vejamos um exemplo:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1010
| 1011
------
  1011</pre>
<p>Se um dos bits comparados forem iguais a 1 a expressão retornará 1, caso os dois bits comparados forem iguais a 0, a expressão retorna 0. Agora vamos refazer o exemplo anterior trocando apenas o operador &#038; (and binário) por | (or binário):</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
|14 |  9|13 | 11|20 |  9|14 | 10|89 |  112|45  |  77|255  |  13|112 |  255|
|       |       |       |       |         |         |          |          |
|  1110 |  1101 |  10100|  1110 |  1011001|   101101|  11111111|   1110000|
|| 1001 || 1011 ||  1001|| 1010 || 1110000|| 1001101||     1101|| 11111111|
|  ---- |  ---- |  -----|  ---- |  -------|  -------|  --------|  --------|
|  1111 |  1111 |  11101|  1110 |  1111001|  1101101|  11111111|  11111111|
|   15d |   15d |    29d|   14d |     121d|     109d|      255d|      255d|</pre>
<p>
<hr /><a name="bitwise-xor"><strong>Operador ^</strong></a><br />
OU exclusivo (bitwise XOR)<br />
A letra X na frente do OR significa Exclusive (Exclusive OR). Isso quer dizer que este operador faz a comparação binária de dois números e resulta os bits que são diferentes. Por exemplos, quais são os bits diferentes entre os números 10 e 11?</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1010
^ 1011
------
     1</pre>
<p>Vamos novamente trocar o operador do exemplo anterior para analisar os resultados:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
|14 ^  9|13 ^ 11|20 ^  9|14 ^ 10|89 ^  112|45  ^  77|255  ^  13|112 ^  255|
|       |       |       |       |         |         |          |          |
|  1110 |  1101 |  10100|  1110 |  1011001|   101101|  11111111|   1110000|
|^ 1001 |^ 1011 |^  1001|^ 1010 |^ 1110000|^ 1001101|^     1101|^ 11111111|
|  ---- |  ---- |  -----|  ---- |  -------|  -------|  --------|  --------|
|   111 |   110 |  11101|   100 |   101001|  1100000|  11110010|  10001111|
|    7d |    6d |    29d|    4d |      41d|      96d|      242d|      143d|</pre>
<p>
<hr /><a name="bitwise-not"><strong>Operador ~</strong></a><br />
Negação (bitwise NOT)<br />
O operador NOT inverte o sinal e complementa em um.<br />
Negando o número 168 (~168) teremos -169.</p>
<p>Alguns exemplos:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~</span>7<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp; <span style="color: #009900; font-style: italic;">// -8</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~-</span>7<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #009900; font-style: italic;">// 6</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~</span>14<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #009900; font-style: italic;">// -15</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~</span>13<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> &nbsp;<span style="color: #009900; font-style: italic;">// -14</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~</span>255<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// -256</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">~</span>112<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">// -113</span></div></td></tr></tbody></table></div>
</p>
<p>&nbsp;</p>
<hr /><a name="extract-rgb"><strong>Extraindo o RGB de uma cor</strong></a><br />
Sabendo que uma cor no formato RGB utiliza dois dígitos hexadecimais para definir quanto existe de Vermelho, Verde e Azul (respectivamente), formando cores como: Vermelho (FF0000), Cinza (C0C0C0), Laranja (FF9900), etc. Temos ai a possibilidade de gerar 16.581.375 de cores com este código, é só fazer a conta para conferir: 255 * 255 * 255 ou FF * FF * FF.<br />
Vamos desmembrar um tom de azul (<strong><font color="#347BB7">#347BB7</font></strong>) para saber quanto esta cor tem de Vermelho, Verde e Azul (o valor dos canais RGB).</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// DEC: 3439543</span><br />
<span style="color: #009900; font-style: italic;">// BIN: 1101000111101110110111</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = 0x347BB7<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span> <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> 16<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> g<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span> <span style="color: #000066; font-weight: bold;">&gt;&gt;</span> &nbsp;8<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = &nbsp;<span style="color: #004993;">color</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">&amp;</span> 0xFF<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Red:&quot;</span><span style="color: #000066; font-weight: bold;">,</span> r<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Green:&quot;</span><span style="color: #000066; font-weight: bold;">,</span> g<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Blue:&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">b</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// Red: 52 Green: 123 Blue: 183</span></div></td></tr></tbody></table></div>
<p>Linha 5) Deslocando 16 bits para a direita temos:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1101000111101110110111 >> 16
=                 110100 (DEC: 52)</pre>
<p>Para o caso do vermelho não precisamos continuar a expressão (&#038; 0xFF),<br />
pois deslocando 16 bits para a direita já temos o resultado do vermelho,<br />
mas se a cor estivesse no formato ARGB (Alpha Red Green Blue), seria necessário.</p>
<p>Linha 6) Deslocando 8 bits para conseguir o verde:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1101000111101110110111 >> 8
=         11010001111011 (DEC: 13435)</pre>
<p>Só com o valor do deslocamentos não vamos conseguir a cor verde, então utilizamos o<br />
operador &#038; (AND) com o valor 255 (0xFF) para extrair a parte binária que nos interessa:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  11010001111011 (DEC: 13435)
&#038;       11111111 (DEC: 255, HEX: 0xFF)
  --------------
        01111011 (DEC: 123)</pre>
<p>Linha 7) Para extrair o azul não precisamos deslocar bits e sim pegar os últimos 8 bits:</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1101000111101110110111
&#038;               11111111 (DEC: 255, HEX: 0xFF)
  ----------------------
                10110111 (DEC: 183)</pre>
<p>Agora voltando para o hexadecimal:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> r<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">52</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> g<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">123</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000; font-weight:bold;">183</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <span style="color: #000000;">&#40;</span>r <span style="color: #000066; font-weight: bold;">&lt;&lt;</span> 16<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">|</span> <span style="color: #000000;">&#40;</span>g <span style="color: #000066; font-weight: bold;">&lt;&lt;</span> 8<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">|</span> <span style="color: #004993;">b</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">color</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span>16<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// 347bb7</span></div></td></tr></tbody></table></div>
<p>Linha 4) Deslocando 16 bits para a esquerda do número 52 (Vermelho):</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  110100 << 16
= 1101000000000000000000</pre>
<p>Deslocando 8 bits para a esquerda do número 123 (Verde):</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1111011 << 8
= 111101100000000</pre>
<p>Efetuando o OR (|) com o resultado das duas operações ((r << 16) | (g << 8)):</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1101000000000000000000
|        111101100000000
  ----------------------
  1101000111101100000000</pre>
<p>Efetuando a última operação, o OR com o Azul (183)</p>
<pre style="font-family: 'Lucida Console', 'Courier New', 'Courier'; font-size: 10px; line-height: 10px;">
  1101000111101100000000
| 0000000000000010110111
  ----------------------
  1101000111101110110111</pre>
<p>O resultado agora ficou claro. O número 1101000111101110110111 (binário) é igual a 3439543 (decimal) e 347BB7 (hexadecimal).</p>
<p>&nbsp;</p>
<hr /><a name="multiplexer-4051"><strong>Chaveando multiplexador 4051</strong></a><br />
A tarefa de chavear um Multiplexador / Demultiplexador (MUX / DEMUX) 4051 é muito parecida com a extração dos canais RGB de uma cor. Você só precisa Ligar ou Desligar três pinos de seleção (select pins) para que o circuito interprete o valor gerado e transmita a voltagem da entrada desejada.<br />
Existe um gif animado do <a href="http://www.rogercom.com" target="_blank">RogerCom</a> muito didático que demonstra o funcionamento do CI 4051, <a href="http://blog.bsoares.com.br/wp-content/uploads/2009/05/animacd4051b.gif" rel="shadowbox[post-340];player=img;" target="_blank">gif animado CI 4051 aqui</a>.<br />
Por exemplo, para ler a entrada 3, precisamos desligar o pino de seleção 0, ligar o 1 e o 2, formando assim o número 011 (binário) que é igual a 3 em decimal. Veja no código (Escrito em Arduino / C++):</p>
<div class="codecolorer-container cpp mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">// Entrada desejada</span><br />
<span style="color: #0000ff;">int</span> count <span style="color: #000080;">=</span> <span style="color: #0000dd;">3</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// Extração dos bits ativos</span><br />
byte s0 <span style="color: #000080;">=</span> &nbsp;count &nbsp; &nbsp; &nbsp; <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x1</span><span style="color: #008080;">;</span><br />
byte s1 <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>count <span style="color: #000080;">&gt;&gt;</span> 1<span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x1</span><span style="color: #008080;">;</span><br />
byte s2 <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span>count <span style="color: #000080;">&gt;&gt;</span> 2<span style="color: #008000;">&#41;</span> <span style="color: #000040;">&amp;</span> <span style="color: #208080;">0x1</span><span style="color: #008080;">;</span><br />
<br />
<span style="color: #666666;">// Ligando ou desligando os pinos de seleção</span><br />
digitalWrite<span style="color: #008000;">&#40;</span>2, s0<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
digitalWrite<span style="color: #008000;">&#40;</span>3, s1<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
digitalWrite<span style="color: #008000;">&#40;</span>4, s2<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span></div></td></tr></tbody></table></div>
<hr /><strong>Conteúdo relacionado:</strong><br />
• <a href="http://en.wikipedia.org/wiki/Bitwise_operation" target="_blank">Bitwise operation on Wikipedia</a><br />
&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/aspnet/operacoes-binarias/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Vector em AS3 para Flash Player 10</title>
		<link>http://blog.bsoares.com.br/flash/as3-vector-for-flashplayer-10</link>
		<comments>http://blog.bsoares.com.br/flash/as3-vector-for-flashplayer-10#comments</comments>
		<pubDate>Tue, 26 May 2009 02:21:35 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=377</guid>
		<description><![CDATA[Para aqueles que já estão usando Flash Player 10, trocar o Array por Vector é uma boa opção, pois você ganha em performance e organização de código (Vector é um array tipado ou seja, mais organizado).
O que mudou mais é a forma de construir o objeto, a sintaxe funciona como o Generics do C# ou [...]]]></description>
			<content:encoded><![CDATA[<p>Para aqueles que já estão usando Flash Player 10, trocar o Array por <a href="http://livedocs.adobe.com/flex/gumbo/langref/Vector.html" target="_blank">Vector</a> é uma boa opção, pois você ganha em performance e organização de código (Vector é um array tipado ou seja, mais organizado).<br />
O que mudou mais é a forma de construir o objeto, a sintaxe funciona como o <a href="http://msdn.microsoft.com/en-us/library/ms379564.aspx" target="_blank">Generics do C#</a> ou Java. Ressaltando que não existe generics em AS3, somente o Vector que implementa uma sintaxe parecida com a sintaxe de um generics.</p>
<p>Muitos blogueiros já comentaram sobre o Vector logo quando saiu a versão beta do Flash Player 10. Por este motivo não vou falar muito sobre, vou apenas exemplificar e dar links para os outros blog.</p>
<p><strong>Criando um Vector:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> vetor<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>T<span style="color: #000066; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>T<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>(Substitua o T pelo tipo desejado)</p>
<p><strong>Veja como é parecido com um Array:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #9900cc; font-weight: bold;">package</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> __AS3__<span style="color: #000066; font-weight: bold;">.</span>vec<span style="color: #000066; font-weight: bold;">.</span>Vector<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getTimer</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span>framerate=<span style="color: #990000;">&quot;30&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;500&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;500&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Main <span style="color: #0033ff; font-weight: bold;">extends</span> <a href="http://www.google.com/search?q=sprite%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:sprite.html"><span style="color: #004993;">Sprite</span></a><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _vector<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>String<span style="color: #000066; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>String<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _timer<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Main<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;a&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;b&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>_vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">push</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;c&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>_vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _vector<span style="color: #000000;">&#91;</span>_vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;d&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>_vector<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> s<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> <span style="color: #0033ff; font-weight: bold;">in</span> _vector<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;FOR: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> s<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Timer Vector:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testVector<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Timer Array:&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; testArray<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> testArray<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _timer = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> array<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=array%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:array.html"><span style="color: #004993;">Array</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&lt;</span> <span style="color: #000000; font-weight:bold;">1000000</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = i<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> _timer<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> testVector<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _timer = <span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> vector<span style="color: #000066; font-weight: bold;">:</span>Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>uint<span style="color: #000066; font-weight: bold;">&gt;</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Vector<span style="color: #000066; font-weight: bold;">.&lt;</span>uint<span style="color: #000066; font-weight: bold;">&gt;</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&lt;</span> <span style="color: #000000; font-weight:bold;">1000000</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vector<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = i<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">getTimer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">-</span> _timer<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>(O código acima é a Main Class de um projeto Flex / ActionScript)</p>
<p>Teste de performance entre arrays, vector e outros:<br />
<a href="http://businessintelligence.me/projects/performance_tester/performanceTester.html" target="_blank">http://businessintelligence.me/projects/performance_tester/performanceTester.html</a></p>
<p>Veja na imagem abaixo como é &#8220;gritante&#8221; a diferença de performance entre um Array comum e um Vector:<br />
<a href="http://blog.bsoares.com.br/wp-content/uploads/2009/05/as3-vector-array-performance-tester.png" rel="shadowbox[post-377];player=img;"><img src="http://blog.bsoares.com.br/wp-content/uploads/2009/05/as3-vector-array-performance-tester-300x300.png" alt="as3-vector-array-performance-tester" title="as3-vector-array-performance-tester" width="300" height="300" class="alignnone size-thumbnail wp-image-410" /></a></p>
<p><strong>Conteúdo relacionado:</strong><br />
<a href="http://livedocs.adobe.com/flex/gumbo/langref/Vector.html" target="_blank">Documentação do Vector</a><br />
<a href="http://businessintelligence.me/projects/performance_tester/performanceTester.html" target="_blank">Teste de performance</a><br />
<a href="http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/" target="_blank">Post sobre Vector por: Mike Chambers</a><br />
<a href="http://www.daveoncode.com/2009/04/06/actionscript-vector-class-initialization-with-a-source-array/" target="_blank">Post sobre Vector por: DaveOnCode</a><br />
<a href="http://thebackbutton.com/blog/65/new-vector-actionscript-3s-typed-array/" target="_blank">Post sobre Vector por: The Back Button</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/flash/as3-vector-for-flashplayer-10/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPGEncoder (AS3) com AMFPHP</title>
		<link>http://blog.bsoares.com.br/remoting/jpgencoder-as3-with-amfphp</link>
		<comments>http://blog.bsoares.com.br/remoting/jpgencoder-as3-with-amfphp#comments</comments>
		<pubDate>Wed, 08 Apr 2009 02:21:54 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[JPGEncoder]]></category>
		<category><![CDATA[PNGEncoder]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=160</guid>
		<description><![CDATA[Tenho notado pelo Google Analytics que pessoas chegam ao blog procurando por AMFPHP, encode de imagens criadas no flash, salvar imagem com Flash + AMFPHP e outros critérios de busca. E por isso me sinto na obrigação de escrever algo sobre isto.
Exemplo:









Vou demonstrar exatamente o que o título do post propõe (Criar imagens no Flash [...]]]></description>
			<content:encoded><![CDATA[<p>Tenho notado pelo Google Analytics que pessoas chegam ao blog procurando por <a href="http://www.amfphp.org/" target="_blank">AMFPHP</a>, encode de imagens criadas no flash, salvar imagem com Flash + AMFPHP e outros critérios de busca. E por isso me sinto na obrigação de escrever algo sobre isto.</p>
<p><strong>Exemplo:</strong>
<object width="550" height="450">
<param name="movie" value="http://blog.bsoares.com.br/articles/jpgencoder_amfphp/swf/Main.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="550" height="450" src="http://blog.bsoares.com.br/articles/jpgencoder_amfphp/swf/Main.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Vou demonstrar exatamente o que o título do post propõe (Criar imagens no Flash com ActionScript 3, encodar essas imagens com a classe JPGEncoder presente na biblioteca <a href="http://code.google.com/p/as3corelib/">as3corelib</a> e salvar como um arquivo .jpg utilizando o AMFPHP). Já escrevi aqui como fazer isso em <a href="http://blog.bsoares.com.br/remoting/jpeg-encoder-as3-fluorinefx-net-flash-remoting-gateway" target="_blank">FluorineFx (ASP.NET Flash Remoting Gateway)</a>.</p>
<p>Suponho que quem esteja interessado em rodar o que está descrito neste tutorial tenha o Apache com PHP instalado, ou algum servidor com suporte. Caso você não tenha recomendo a instalação do <a href="http://www.apachefriends.org/pt_br/xampp.html" target="_blank">XAMPP</a> (é de fácil instalação e tem tudo que um programador precisa).</p>
<p><strong>Configuração do AMFPHP:</strong><br />
A versão que utilizo neste tutorial é a <strong>1.9 beta</strong>, mas versões posteriores devem funcionar perfeitamente.<br />
• Baixe o AMFPHP do seguinte link: <a href="http://www.amfphp.org/" target="_blank">http://www.amfphp.org/</a><br />
• Copie o conteúdo do ZIP para o diretório onde você está criando o projeto, recomendo a estrutura de diretórios como mostrada na imagem abaixo:<br />
<img class="alignnone size-full wp-image-174" title="folders" src="http://blog.bsoares.com.br/wp-content/uploads/2009/04/folders.png" alt="folders" width="186" height="209" /></p>
<p>• Para testar o funcionamento é só acessar o diretório browser do navegador (http://127.0.0.1/www/amf/browser/).</p>
<p>Fique entendido que <strong>a responsabilidade de gerar a imagem é do Flash</strong>, e o <strong>servidor deve apenas receber os binários para gravar em disco</strong>. Para gerarmos o código da imagem (binário), vamos utilizar a classe JPGEncoder.<br />
<strong>Exemplo:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<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>images<span style="color: #000066; font-weight: bold;">.</span>JPGEncoder<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> bmpData<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
bmpData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>MEU_MOVIECLIP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> objJPGEncoder<span style="color: #000066; font-weight: bold;">:</span>JPGEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPGEncoder<span style="color: #000000;">&#40;</span>QUALIDADE<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> dadosEncode<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = objJPGEncoder<span style="color: #000066; font-weight: bold;">.</span>encode<span style="color: #000000;">&#40;</span>bmpData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Muito simples não? O método draw da classe BitmapData obtém a imagem atual do clip, criamos uma instância da JPGEncoder já passando a qualidade (0 à 100) e por fim “encodamos” o BitmapData utilizando o método encode da nossa instância da JPGEncoder, ele nos retorna um <strong>Array de Bytes (flash.utils.ByteArray)</strong>.</p>
<p><strong>Vamos a parte do actionscript que interessa:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> encode<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><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; lblMessage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Codificando dados (JPGEncoder.encode)&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> bmpData<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>hit<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> hit<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; bmpData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">target</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> objJPGEncoder<span style="color: #000066; font-weight: bold;">:</span>JPGEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPGEncoder<span style="color: #000000;">&#40;</span>sliderQuality<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> dadosEncode<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = objJPGEncoder<span style="color: #000066; font-weight: bold;">.</span>encode<span style="color: #000000;">&#40;</span>bmpData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; sendToAmf<span style="color: #000000;">&#40;</span>dadosEncode<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> sendToAmf<span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; lblMessage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Enviando dados para o AMF...&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; _objService = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; _objResponder = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=responder%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:responder.html"><span style="color: #004993;">Responder</span></a><span style="color: #000000;">&#40;</span>onResultEvent<span style="color: #000066; font-weight: bold;">,</span> onStatusEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; _objService<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span>_amfGateway<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; _objService<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;br.com.bsoares.Image.saveDataToFile&quot;</span><span style="color: #000066; font-weight: bold;">,</span> _objResponder<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onResultEvent<span style="color: #000000;">&#40;</span>result<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; lblMessage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Abrindo imagem&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #004993;">navigateToURL</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;http://blog.bsoares.com.br/articles/jpgencoder_amfphp/generated_images/image.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onStatusEvent<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; lblMessage<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">text</span> = <span style="color: #990000;">&quot;Erro&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Agora a classe Image do PHP:</strong></p>
<div class="codecolorer-container php mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Image<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$imagePath</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imagePath</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;../../../../../generated_images/image.jpg&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> saveDataToFile<span style="color: #009900;">&#40;</span><span style="color: #000088;">$byteArray</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/file_put_contents"><span style="color: #990000;">file_put_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imagePath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$byteArray</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">imagePath</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>O PHP só precisa pegar o ByteArray e salvar em um arquivo.</p>
<p>Dica: Para verificar os request usem o <a href="http://www.charlesproxy.com/" target="_blank">Charles Web Debugging Proxy</a>.</p>
<p>É isso ai, qualquer dúvida só postar um comentário.</p>
<p><strong>Conteúdo relacionado:</strong><br />
Código fonte do exemplo: <a href="http://blog.bsoares.com.br/articles/jpgencoder_amfphp/jpgencoder-amfphp.zip" target="_blank">http://blog.bsoares.com.br/articles/jpgencoder_amfphp/jpgencoder-amfphp.zip</a><br />
AMFPHP: <a href="http://www.amfphp.org/" target="_blank">http://www.amfphp.org/</a><br />
AS3CoreLib: <a href="http://code.google.com/p/as3corelib/" target="_blank">http://code.google.com/p/as3corelib/</a><br />
Charles: <a href="http://www.charlesproxy.com/" target="_blank">http://www.charlesproxy.com/</a></p>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/remoting/jpgencoder-as3-with-amfphp/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flickr &#8211; Buscar fotos por Tag com ActionScript</title>
		<link>http://blog.bsoares.com.br/flash/flickr-search-photos-by-tag-with-actionscript</link>
		<comments>http://blog.bsoares.com.br/flash/flickr-search-photos-by-tag-with-actionscript#comments</comments>
		<pubDate>Sat, 04 Apr 2009 23:10:54 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flickr API]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=111</guid>
		<description><![CDATA[Vamos a um exemplo de uso da API do Flickr, bem simples pois a API do Flickr é realmente simples (isso não quer dizer que ela não é poderoza).
Aqui está o resultado de pouco código:










Em primeiro lugar você vai precisar de uma api_key e pode conseguir neste link &#8220;Solicitar uma nova chave API&#8220;. Com sua [...]]]></description>
			<content:encoded><![CDATA[<p>Vamos a um exemplo de uso da <a href="http://www.flickr.com/services/api/" target="_blank">API do Flickr</a>, bem simples pois a API do Flickr é realmente simples (isso não quer dizer que ela não é poderoza).</p>
<p><strong>Aqui está o resultado de pouco código:</strong><br />

<object width="455" height="430">
<param name="movie" value="http://blog.bsoares.com.br/wp-content/uploads/2009/04/main.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="455" height="430" src="http://blog.bsoares.com.br/wp-content/uploads/2009/04/main.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<p>Em primeiro lugar você vai precisar de uma api_key e pode conseguir neste link &#8220;<a href="http://www.flickr.com/services/api/keys/apply/" target="_blank">Solicitar uma nova chave API</a>&#8220;. Com sua KEY em mão vamos chamar a api buscando uma tag:<br />
<em> <span style="color: #339966;">http://api.flickr.com/services/<strong>rest</strong>/?<strong>api_key</strong>=[SUA-API-KEY]&amp;<strong>method</strong>=flickr.photos.search&amp;<strong>tags</strong>=[TAG]</span></em></p>
<p><strong>O resultado esperado é este:</strong></p>
<div class="codecolorer-container xml mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rsp</span> <span style="color: #000066;">stat</span>=<span style="color: #ff0000;">&quot;ok&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photos</span> <span style="color: #000066;">page</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">pages</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #000066;">perpage</span>=<span style="color: #ff0000;">&quot;100&quot;</span> <span style="color: #000066;">total</span>=<span style="color: #ff0000;">&quot;1000&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3411384625&quot;</span> <span style="color: #000066;">owner</span>=<span style="color: #ff0000;">&quot;23534352@N07&quot;</span> <span style="color: #000066;">secret</span>=<span style="color: #ff0000;">&quot;74167a8895&quot;</span> <span style="color: #000066;">server</span>=<span style="color: #ff0000;">&quot;3374&quot;</span> <span style="color: #000066;">farm</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;_MG_0611&quot;</span> <span style="color: #000066;">ispublic</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">isfriend</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">isfamily</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;photo</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;3411401933&quot;</span> <span style="color: #000066;">owner</span>=<span style="color: #ff0000;">&quot;23534352@N07&quot;</span> <span style="color: #000066;">secret</span>=<span style="color: #ff0000;">&quot;46c095f827&quot;</span> <span style="color: #000066;">server</span>=<span style="color: #ff0000;">&quot;3585&quot;</span> <span style="color: #000066;">farm</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;_MG_0641&quot;</span> <span style="color: #000066;">ispublic</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">isfriend</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">isfamily</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; ...<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/photos<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rsp<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p>Vamos entender o link, rest é o formato que você deseja receber a resposta, atualmente o Flickr suporta 5 formatos (REST, XML-RPC, SOAP, JSON e PHP), usamos o rest porque o ActionScript trabalha muito bem com ele (XML). api_key é a chave que você solicitou acima. method, é o método de busca (você pode encontrar muitos no link da API, <a href="http://www.flickr.com/services/api/" target="_blank">http://www.flickr.com/services/api/</a>). E por fim tags que é um parâmetro pelo qual você busca.</p>
<p>Agora que temos o XML de resposta podemos construir links para as fotos, para a página de galeria do usuário encontrado, para o perfil do usuário entro outros. O link que eu acho mais importante é o da imagem e para consegui-lo basta concatenar alguns dados presentes no XML dessa forma:</p>
<p><span style="color: #339966;">http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}.jpg</p>
<p>http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{secret}_[mstb].jpg</p>
<p>http://farm{farm-id}.static.flickr.com/{server-id}/{id}_{o-secret}_o.(jpg|gif|png)</span></p>
<p>O que é mstb?<br />
s) quadrado pequeno 75&#215;75.<br />
t) miniatura, 100 no lado mais longo.<br />
m) pequeno, 240 no lado mais longo.<br />
-) médio, 500 no lado mais longo.<br />
b) grande, 1.024 no lado mais longo (existe apenas para imagens originais muito grandes).<br />
o) imagem original, jpg, gif ou png, dependendo do formato de origem.<br />
Na página <a href="http://www.flickr.com/services/api/misc.urls.html" target="_blank">URLs da origem da foto</a> você encontra tudo bem explicado.</p>
<p>Veja no exemplo abaixo o link (do primeio nó &#8216;photo&#8217;)  para a imagem:<br />
<a href="http://farm4.static.flickr.com/3374/3411384625_74167a8895.jpg" rel="shadowbox[post-111];player=img;" target="_blank">http://farm4.static.flickr.com/3374/3411384625_74167a8895.jpg</a></p>
<p><strong>Agora tudo isso com ActionScript (Load do XML e parse para gerar o link):</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6699cc; font-weight: bold;">var</span> apiKey<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;[SUA-API-KEY]&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> tag<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;arduino&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> xmlLoader<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlloader%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlloader.html"><span style="color: #004993;">URLLoader</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
xmlLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">COMPLETE</span><span style="color: #000066; font-weight: bold;">,</span> onComplete<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> <span style="color: #004993;">url</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=string%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:string.html"><span style="color: #004993;">String</span></a> = <span style="color: #990000;">&quot;http://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> apiKey <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;&amp;tags=&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> tag<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;URL: &quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
xmlLoader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=urlrequest%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:urlrequest.html"><span style="color: #004993;">URLRequest</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> onComplete<span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=event%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:event.html"><span style="color: #004993;">Event</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> xmlData<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=xml%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:xml.html"><span style="color: #004993;">XML</span></a><span style="color: #000000;">&#40;</span>event<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">target</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>@stat <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #990000;">&quot;ok&quot;</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ERROR: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> xmlData<span style="color: #000066; font-weight: bold;">.</span>err<span style="color: #000066; font-weight: bold;">.</span>@msg<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <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><a href="http://www.google.com/search?q=uint%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:uint.html"><span style="color: #004993;">uint</span></a> = <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;">&lt;</span> xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">length</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> i<span style="color: #000066; font-weight: bold;">++</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #6699cc; font-weight: bold;">var</span> photo<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> = <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; id<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@id<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; owner<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@owner<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; secret<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@secret<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; server<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@server<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; farm<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@farm<span style="color: #000066; font-weight: bold;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title<span style="color: #000066; font-weight: bold;">:</span>xmlData<span style="color: #000066; font-weight: bold;">.</span>photos<span style="color: #000066; font-weight: bold;">.</span>photo<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">.</span>@title<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; photo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span> = <span style="color: #990000;">&quot;http://farm&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> photo<span style="color: #000066; font-weight: bold;">.</span>farm <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;.static.flickr.com/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> photo<span style="color: #000066; font-weight: bold;">.</span>server <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> photo<span style="color: #000066; font-weight: bold;">.</span>id <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;_&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> photo<span style="color: #000066; font-weight: bold;">.</span>secret <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;.jpg&quot;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Imagem: &quot;</span><span style="color: #000066; font-weight: bold;">,</span> photo<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">url</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Repare que você pode adicionar dois parâmetros no link para controlar a paginação das fotos (page e perpage).</p>
<p><strong>Conteúdo relacionado:</strong><br />
Flickr API: <a href="http://www.flickr.com/services/api/" target="_blank">http://www.flickr.com/services/api/</a><br />
XML ActionScript 3.0: <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/XML.html" target="_blank">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/XML.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/flash/flickr-search-photos-by-tag-with-actionscript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AIR Install Badge com Google Analytics</title>
		<link>http://blog.bsoares.com.br/as3/air-install-badge-with-google-analytics</link>
		<comments>http://blog.bsoares.com.br/as3/air-install-badge-with-google-analytics#comments</comments>
		<pubDate>Thu, 02 Apr 2009 04:32:17 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=83</guid>
		<description><![CDATA[Já a algum tempo procurei um Air Install Badge com o Google Analytics integrado e acabei encontrando o do Marc&#8217;s Musings, mas me pareceu meio &#8220;travado&#8221; uma vez que é necessário compilar o flash com as informações do seu aplicativo AIR. Sendo assim modifiquei o original para receber via FlashVars o nome da aplicação, versão, [...]]]></description>
			<content:encoded><![CDATA[<p>Já a algum tempo procurei um <a href="http://www.adobe.com/devnet/air/articles/badge_for_air.html" target="_blank">Air Install Badge</a> com o <a href="http://www.google.com/analytics/" target="_self">Google Analytics</a> integrado e acabei encontrando o do <a href="http://www.rogue-development.com/blog2/2008/02/air-install-badge-google-analytics/" target="_blank">Marc&#8217;s Musings</a>, mas me pareceu meio &#8220;travado&#8221; uma vez que é necessário compilar o flash com as informações do seu aplicativo AIR. Sendo assim modifiquei o original para receber via FlashVars o nome da aplicação, versão, endereço do .air, e é claro o código AnalyticsTracker.</p>
<p>O <a href="http://googletranslation.bsoares.com.br/" target="_blank">Google Translation Plus</a> (uma aplicação que estou desenvolvendo) já está utilizando o Install Badge modificado, verifique.<strong></strong></p>
<p><strong>Como é mostrado o relatório no Google Analytics:</strong><br />
<a href="http://blog.bsoares.com.br/wp-content/uploads/2009/04/googleanalytics.gif" rel="shadowbox[post-83];player=img;"><img class="alignnone size-full wp-image-86" title="googleanalytics" src="http://blog.bsoares.com.br/wp-content/uploads/2009/04/googleanalytics.gif" alt="googleanalytics" width="468" height="169" /></a></p>
<p><strong><br />
Principal trecho de código do Install Badge alterado:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900; font-style: italic;">// Google Analytics Tracking</span><br />
<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>tracker <span style="color: #000066; font-weight: bold;">!</span>= <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; tracker<span style="color: #000066; font-weight: bold;">.</span>trackPageview<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> appName <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;/&quot;</span> <span style="color: #000066; font-weight: bold;">+</span> action<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p><span style="color: #800000;"><strong>Atenção:</strong></span><br />
Existem muitas variáreis para serem alteradas no arquivo AirAppPage.html, como por exemplo: analyticstracker, airversion, appname, appurl, appid, appversion, etc&#8230;</p>
<p>Download do <a href="http://blog.bsoares.com.br/wp-content/uploads/2009/04/airinstallbadgeanalytics.zip" target="_blank">AIR Install Badge com Google Analytics</a>.</p>
<p><strong>Conteúdo relacionado:</strong><br />
AIR Install Badge: <a href="http://www.adobe.com/devnet/air/articles/badge_for_air.html" target="_blank">http://www.adobe.com/devnet/air/articles/badge_for_air.html</a><br />
gaforflash: <a href="http://code.google.com/p/gaforflash/" target="_blank">Google Analytics Tracking For Adobe Flash</a><br />
swfobject: <a href="http://code.google.com/p/swfobject/" target="_blank">http://code.google.com/p/swfobject/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/as3/air-install-badge-with-google-analytics/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regra de três simplificada (Map do Processing)</title>
		<link>http://blog.bsoares.com.br/flash/regra-de-tres-simplificada-map-do-processing</link>
		<comments>http://blog.bsoares.com.br/flash/regra-de-tres-simplificada-map-do-processing#comments</comments>
		<pubDate>Mon, 30 Mar 2009 18:52:51 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Matemática]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=57</guid>
		<description><![CDATA[Se tem uma coisa que programador Flash faz muito é regra de três, esta pequena formula matemática é executada diversas vezes dentro de um projeto, e ela é usada para transferir um valor dentro de um intervalo de números para o valor equivalente em um outro intervalo de números. Pro exemplo, no loading de uma [...]]]></description>
			<content:encoded><![CDATA[<p>Se tem uma coisa que programador Flash faz muito é <a href="http://www.somatematica.com.br/fundam/regra3s.php" target="_blank">regra de três</a>, esta pequena formula matemática é executada diversas vezes dentro de um projeto, e ela é usada para <em><strong>transferir um valor dentro de um intervalo de números para o valor equivalente em um outro intervalo de números</strong></em>. Pro exemplo, no loading de uma imagem você sabe quantos bytes tem a imagem e quantos bytes já foram carregados, agora como calcular o percentual de carregamento? Vamos supor que a imagem tenha 300 bytes e já foram carregados 150 então temos 50% carregado, para chegar a este resultado de uma forma fácil e padronizada:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>NumberUtils<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>150<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 300<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 100<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Converti o script escrito originalmente em <a href="http://processing.org/reference/map_.html" target="_blank">Processing</a> e <a href="http://arduino.cc/en/Reference/Map" target="_blank">Arduino</a> para ActionScript 3.0, agora é só usar.</p>
<p><strong>Mais exemplos de uso:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> br<span style="color: #000066; font-weight: bold;">.</span>com<span style="color: #000066; font-weight: bold;">.</span>bsoares<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>NumberUtils<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>NumberUtils<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>50<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 100<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 10<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// 5</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>NumberUtils<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>90<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 100<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 10<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// 9</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>NumberUtils<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span>90<span style="color: #000066; font-weight: bold;">,</span> 100<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 10<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// 1</span><br />
<br />
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>NumberUtils<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">-</span>90<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000066; font-weight: bold;">-</span>100<span style="color: #000066; font-weight: bold;">,</span> 100<span style="color: #000066; font-weight: bold;">,</span> 0<span style="color: #000066; font-weight: bold;">,</span> 10<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #009900; font-style: italic;">// 0.5</span></div></td></tr></tbody></table></div>
<p><strong>Classe completa:</strong></p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #3f5fbf;">/**<br />
&nbsp;* NumberUtils<br />
&nbsp;*<br />
&nbsp;* @author Bruno Soares<br />
&nbsp;* @link http://www.bsoares.com.br<br />
&nbsp;*/</span><br />
<br />
<span style="color: #9900cc; font-weight: bold;">package</span> br<span style="color: #000066; font-weight: bold;">.</span>com<span style="color: #000066; font-weight: bold;">.</span>bsoares<span style="color: #000066; font-weight: bold;">.</span>utils<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> NumberUtils<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> NumberUtils<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3f5fbf;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Transfere um valor de um intervalo para outro.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Versão original escrita em Processing (http://processing.org/reference/map_.html).<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param value Valor a ser transferido<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param inMin Menor valor do primeiro intervalo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param inMax Maior valor do primeiro intervalo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param outMin Menor valor do segundo intervalo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param outMax Maior valor do segundo intervalo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @return Valor calculado<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">map</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> inMin<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> inMax<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> outMin<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000066; font-weight: bold;">,</span> outMax<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=number%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:number.html"><span style="color: #004993;">Number</span></a><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">value</span> <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">*</span> <span style="color: #000000;">&#40;</span>outMax <span style="color: #000066; font-weight: bold;">-</span> outMin<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">/</span> <span style="color: #000000;">&#40;</span>inMax <span style="color: #000066; font-weight: bold;">-</span> inMin<span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">+</span> outMin<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Links relacionados:</strong><br />
Processing: <a href="http://processing.org/reference/map_.html" target="_blank">http://processing.org/reference/map_.html</a><br />
Arduino: <a href="http://arduino.cc/en/Reference/Map" target="_blank">http://arduino.cc/en/Reference/Map</a><br />
Regra de Três: <a href="http://pt.wikipedia.org/wiki/Regra_de_tr%C3%AAs" target="_blank">http://pt.wikipedia.org/wiki/Regra_de_tr%C3%AAs</a>, <a href="http://www.somatematica.com.br/fundam/regra3s.php" target="_blank">http://www.somatematica.com.br/fundam/regra3s.php</a></p>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/flash/regra-de-tres-simplificada-map-do-processing/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JPEG Encoder (AS3) + FluorineFx .NET Flash Remoting Gateway</title>
		<link>http://blog.bsoares.com.br/remoting/jpeg-encoder-as3-fluorinefx-net-flash-remoting-gateway</link>
		<comments>http://blog.bsoares.com.br/remoting/jpeg-encoder-as3-fluorinefx-net-flash-remoting-gateway#comments</comments>
		<pubDate>Mon, 18 Feb 2008 05:14:48 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[FluorineFx]]></category>
		<category><![CDATA[JPGEncoder]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=27</guid>
		<description><![CDATA[
Vamos entender neste post como o flash cria um jpeg e o envia através do FluorineFx para o servidor para que o servidor possa trabalhar o dado binário e salvar como um arquivo .JPG.
Não vamos entrar em detalhes da instalação e nem da configuração básica de um site com FluorineFx, pois no próprio site do [...]]]></description>
			<content:encoded><![CDATA[<div>
<div>Vamos entender neste post como o flash cria um jpeg e o envia através do <a href="http://www.fluorinefx.com/" target="_blank">FluorineFx</a> para o servidor para que o servidor possa trabalhar o dado binário e salvar como um arquivo .JPG.</p>
<p>Não vamos entrar em detalhes da instalação e nem da configuração básica de um site com FluorineFx, pois no próprio site do FluorineFx existe um ótimo tutorial para esta configuração inicial (<a href="http://www.fluorinefx.com/docs/fluorine/vswizardnet20.html" target="_blank">FluorineFx Visual Studio 2005 Wizard</a>).</p>
<p>Em primeiro lugar, que fique entendido que a responsabilidade de gerar a imagem é do Flash, e o servidor deve apenas receber os binários para gravar em disco. Para gerarmos o código da imagem (<span style="font-weight: bold;">binário</span>), vamos utilizar a classe <span style="font-weight: bold;">JPEGEncoder</span>.<br />
Exemplo:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #0033ff; font-weight: bold;">import</span> JPEGEncoder<span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> bmpData <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
bmpData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>MEU_MOVIECLIP<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> objJPEGEncoder <span style="color: #000066; font-weight: bold;">:</span> JPEGEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPEGEncoder<span style="color: #000000;">&#40;</span>QUALIDADE<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #6699cc; font-weight: bold;">var</span> dadosEncode <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = objJPEGEncoder<span style="color: #000066; font-weight: bold;">.</span>encode<span style="color: #000000;">&#40;</span>bmpData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Muito simples não? O método draw da classe <span style="font-weight: bold;">BitmapData</span> obtém a imagem atual do clip, criamos uma instância da JPEGEncoder já passando a qualidade (0 à 100) e por fim “encodamos” o BitmapData utilizando o método encode da nossa instância da JPEGEncoder, ele nos retorna um Array de Bytes (<span style="font-weight: bold;">flash.utils.ByteArray</span>).</p>
<p>Agora ficou simples, temos em mãos o array de bytes, podemos enviar ele para o servidor para que o mesmo possa fazer sua parte, que nada mais é que salvar estes bytes em um arquivo. Utilizando o FluorineFx fica fácil, veja o código abaixo:</p>
<div class="codecolorer-container csharp mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Drawing</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">FluorineFx</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">FluorineFx.AMF3</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">namespace</span> ServiceLibrary.<span style="color: #0000FF;">Imagem</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#91;</span>RemotingService<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Comentário da classe&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> JpegEncoder<br />
&nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> Salvar<span style="color: #000000;">&#40;</span>ByteArray byteArray<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Transfere de ByteArray para MemoryStream</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF0000;">uint</span> length <span style="color: #008000;">=</span> byteArray.<span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> bytes <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span>length<span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byteArray.<span style="color: #0000FF;">ReadBytes</span><span style="color: #000000;">&#40;</span>bytes, 0, length<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MemoryStream stream <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MemoryStream<span style="color: #000000;">&#40;</span>bytes<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Cria a imagem</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Image image <span style="color: #008000;">=</span> Bitmap.<span style="color: #0000FF;">FromStream</span><span style="color: #000000;">&#40;</span>stream<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Salva a imagem</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;image.<span style="color: #0000FF;">Save</span><span style="color: #000000;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Server</span>.<span style="color: #0000FF;">MapPath</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;_upload/JpegEncoder.jpg&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// Libera o espaço na memória</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;stream.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;image.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Este código deve ser inserido dentro da ServiceLibrary que você criou para a sua Solution.</p>
<p>Repare na classe ByteArray, é uma implementação do ByteArray do Flash no servidor, provida pelo FluorineFx.AMF3.</p>
<p>Sua Solution Explorer deve se parecer um pouco com esta:</p>
<p><a href="http://4.bp.blogspot.com/_qLU3RxFHN9w/R7rKlsBl3WI/AAAAAAAAAF4/Kv8k9BKPfAs/s1600-h/SolutionExplorer.gif" rel="shadowbox[post-27];player=img;"><img id="BLOGGER_PHOTO_ID_5168666271182871906" src="http://4.bp.blogspot.com/_qLU3RxFHN9w/R7rKlsBl3WI/AAAAAAAAAF4/Kv8k9BKPfAs/s320/SolutionExplorer.gif" border="0" alt="" /></a></p>
<p>Deixei selecionadas as referências para System.Drawing e Web propositalmente, pois são referências necessárias para o funcionamento da nossa classe.</p>
<p>Agora vamos a parte do envio do ByteArray criado no Flash apartir da JPEGEncoder para a nossa classe la no FluorineFx, a ServiceLibrary.Imagem.JpegEncoder. No exemplo anexo ao post (mais ao fim do post tem um link para download) utilizei uma classe que criei a pouco tempo para trabalhar com AMF no geral (br.com.bsoares.net.Amf), ela vai tomar muito espaço no post, portanto vou demonstrar somente a utilização dela:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #3f5fbf;">/**<br />
* Função de callback para JpegEncoder.Salvar<br />
* @param resposta<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> baixarSusseco <span style="color: #000000;">&#40;</span>resposta <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><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><br />
&nbsp; &nbsp;UtilNet<span style="color: #000066; font-weight: bold;">.</span>navegar<span style="color: #000000;">&#40;</span>Config<span style="color: #000066; font-weight: bold;">.</span>URL_UPLOAD <span style="color: #000066; font-weight: bold;">+</span> <span style="color: #990000;">&quot;JpegEncoder.jpg&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;_blank&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Função de callback para JpegEncoder.Salvar<br />
* @param resposta<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> baixarErro <span style="color: #000000;">&#40;</span>resposta <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><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><br />
&nbsp; &nbsp;<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;--&amp;amp;lt; ERRO &amp;amp;gt;----------------------&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">for</span> <span style="color: #0033ff; font-weight: bold;">each</span> <span style="color: #000000;">&#40;</span><span style="color: #6699cc; font-weight: bold;">var</span> o <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a> <span style="color: #0033ff; font-weight: bold;">in</span> resposta<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>o<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;--------------------------------&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Retorna o ByteArray gerado pela JPEGEncoder<br />
* @return Byte Array<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> obterByteArray <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> bmpData <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=bitmapdata%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bitmapdata.html"><span style="color: #004993;">BitmapData</span></a><span style="color: #000000;">&#40;</span>_flvPlayer<span style="color: #000066; font-weight: bold;">.</span>msk<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">width</span><span style="color: #000066; font-weight: bold;">,</span> _flvPlayer<span style="color: #000066; font-weight: bold;">.</span>msk<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">height</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;bmpData<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>_alvoCaptura<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> objJPEGEncoder <span style="color: #000066; font-weight: bold;">:</span> JPEGEncoder = <span style="color: #0033ff; font-weight: bold;">new</span> JPEGEncoder<span style="color: #000000;">&#40;</span>_qualidade<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">value</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> dadosEncode <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=bytearray%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:bytearray.html"><span style="color: #004993;">ByteArray</span></a> = objJPEGEncoder<span style="color: #000066; font-weight: bold;">.</span>encode<span style="color: #000000;">&#40;</span>bmpData<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;<span style="color: #0033ff; font-weight: bold;">return</span> dadosEncode<span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #3f5fbf;">/**<br />
* Chama o método Salvar da Classe JpegEncoder utilizando o FluorineFx.<br />
* Neste exemplo, criei uma classe chamada AMF para tratar a comunicação<br />
* com o FluorineFx (serve também para AMFPHP)<br />
* @param Evento<br />
*/</span><br />
<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onBaixarClick <span style="color: #000000;">&#40;</span>e <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=mouseevent%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:mouseevent.html"><span style="color: #004993;">MouseEvent</span></a><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><br />
&nbsp; &nbsp;<span style="color: #6699cc; font-weight: bold;">var</span> objAmf <span style="color: #000066; font-weight: bold;">:</span> Amf = <span style="color: #0033ff; font-weight: bold;">new</span> Amf<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;objAmf<span style="color: #000066; font-weight: bold;">.</span>URL = Config<span style="color: #000066; font-weight: bold;">.</span>URL_AMF_GATEWAY<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;objAmf<span style="color: #000066; font-weight: bold;">.</span>onSusseco = baixarSusseco<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;objAmf<span style="color: #000066; font-weight: bold;">.</span>onErro = baixarErro<span style="color: #000066; font-weight: bold;">;</span><br />
&nbsp; &nbsp;objAmf<span style="color: #000066; font-weight: bold;">.</span>executar<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;ServiceLibrary.Imagem.JpegEncoder.Salvar&quot;</span><span style="color: #000066; font-weight: bold;">,</span> obterByteArray<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Pelo comentário de cada método já podemos perceber como funciona o envio do Array de bytes.</p>
<p><span style="font-weight: bold;">Dicas:</span><br />
• Neste projeto utilizei o <a href="http://osflash.org/flashdevelop" target="_blank">FlashDevelop</a>, que na minha opinião é um ótimo editor de Action Script.<br />
• Observe a estrutura de classes, para quem ainda não entende muito de POO (Programação Orientada a Objetos) este post é um bom exemplo de organização de Packages e Nomenclatura de Variáveis, Classes e Métodos. Vou tentar em um próximo post escrever mais sobre Programação Orientada a Objetos (POO) de uma forma mais avançada abrangendo Encapsulamento, Herança e Polimorfismo, o qual não é o objetivo deste post).</p>
<p><span style="font-weight: bold;">Observações de Configuração:</span><br />
Observe na imagem abaixo o projeto aberto no FlashDevelop:</p>
<p><a href="http://1.bp.blogspot.com/_qLU3RxFHN9w/R7pOa8Bl3UI/AAAAAAAAAFo/3KL2o4pvLv0/s1600-h/FlashDevelop_Project.gif" rel="shadowbox[post-27];player=img;" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5168529747057433922" style="cursor: pointer;" src="http://1.bp.blogspot.com/_qLU3RxFHN9w/R7pOa8Bl3UI/AAAAAAAAAFo/3KL2o4pvLv0/s320/FlashDevelop_Project.gif" border="0" alt="" /></a></p>
<p>Clique com o botão direito do mouse sobre <span style="font-weight: bold;">JPEG_Encoder (AS3)</span>, vá em Properties, repare que na área <span style="font-weight: bold;">Project Classpaths</span> deve ser adicionado os dois diretórios (_Biblioteca_ e Classes).</p>
<p><span style="font-weight: bold;">Conclusão:</span><br />
Vimos como é possível o Flash gerar uma imagem (JPEG) utilizando a classe JPEGEncoder, como enviamos os binários do JPEG para o ASP.NET utilizando o FluorineFx e como o FluorineFx salva os binários em disco.</p>
<p>Por hoje é isso pessoal.<br />
Vocês podem fazer o <a href="http://fluorinefx-jpegencoder.bsoares.com.br/download.zip" target="_blank">download do projeto aqui</a>.</p>
<p><span style="font-weight: bold;">Links relacionados:</span><br />
• Exemplo: <a href="http://fluorinefx-jpegencoder.bsoares.com.br/" target="_blank">http://fluorinefx-jpegencoder.bsoares.com.br/</a><br />
• FluorineFx: <a href="http://www.fluorinefx.com/" target="_blank">http://www.fluorinefx.com/</a><br />
• FluorineFx download: <a href="http://www.fluorinefx.com/download.html" target="_blank">http://www.fluorinefx.com/download.html</a><br />
• FluorineFx Visual Studio: <a href="http://www.fluorinefx.com/docs/fluorine/vswizardnet20.html" target="_blank">http://www.fluorinefx.com/docs/fluorine/vswizardnet20.html</a><br />
• Live JPEG Encoder: <a href="http://www.bytearray.org/?p=26" target="_blank">http://www.bytearray.org/?p=26</a><br />
• PNG Encoder in AS3: <a href="http://www.kaourantin.net/2005/10/png-encoder-in-as3.html" target="_blank">http://www.kaourantin.net/2005/10/png-encoder-in-as3.html</a><br />
• FlashDevelop: <a href="http://osflash.org/flashdevelop" target="_blank">http://osflash.org/flashdevelop</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/remoting/jpeg-encoder-as3-fluorinefx-net-flash-remoting-gateway/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluorine, uma alternativa de Flash Remoting com ASP.NET</title>
		<link>http://blog.bsoares.com.br/remoting/fluorine-uma-alternativa-de-flash-remoting-com-aspnet</link>
		<comments>http://blog.bsoares.com.br/remoting/fluorine-uma-alternativa-de-flash-remoting-com-aspnet#comments</comments>
		<pubDate>Sat, 02 Feb 2008 05:01:31 +0000</pubDate>
		<dc:creator>Bruno Soares</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ActionScript 3.0]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[AMF]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[FluorineFx]]></category>
		<category><![CDATA[JPGEncoder]]></category>
		<category><![CDATA[Techology]]></category>

		<guid isPermaLink="false">http://blog.bsoares.com.br/?p=20</guid>
		<description><![CDATA[Nos tempos em que o Flash ainda era da Macromedia, foi criada a especificação AMF (ActionScript Message Format), para facilitar a comunicação entre o ActionScript e as demais linguagens Server-side (Gateway, mais a diante vamos ver que o que controla a comunicação entre o ActionScript e o ASP.NET é com.TheSilentGroup.Fluorine.FluorineGateway). Temos hoje várias linguagem com [...]]]></description>
			<content:encoded><![CDATA[<p>Nos tempos em que o Flash ainda era da Macromedia, foi criada a especificação AMF (ActionScript Message Format), para facilitar a comunicação entre o ActionScript e as demais linguagens <a href="http://pt.wikipedia.org/wiki/Server-side">Server-side</a> (<a href="http://pt.wikipedia.org/wiki/Gateway">Gateway</a>, mais a diante vamos ver que o que controla a comunicação entre o ActionScript e o ASP.NET é com.TheSilentGroup.Fluorine.FluorineGateway). Temos hoje várias linguagem com alguma biblioteca que implemente AMF como por exemplo o PHP, Java, ColdFusion e também o ASP.NET. Existe uma alternativa de remoting muito boa para quem trabalha com PHP que é o <a href="http://www.amfphp.org/">AMFPHP</a>, para quem o conhece será fácil entender o funcionamento do <a href="http://fluorine.thesilentgroup.com/fluorine/download.html">Fluorine</a>. E para quem não o conhece tenho certeza de que vão encontrar muito material sobre ele na Internet.</p>
<p>Hoje em dia já estamos na versão 3 da AMF e a Fluorine também implementa bibliotecas para uso desta versão de AMF.</p>
<p>Vamos ao tutorial.</p>
<p>Nosso primeiro passo será o download do Fluorine no link a seguir: <a href="http://fluorine.thesilentgroup.com/fluorine/download.html">http://fluorine.thesilentgroup.com/fluorine/download.html</a><br />
Não vou dar detalhes da instalação porque é sempre a mesma coisa de Next, Next e Finish.</p>
<p>Após realizada a instalação do Fluorine, vamos abrir o Visual Studio e criar uma nova aplicação web<span id="0" class="transl_class" title="Click to correct">।</span> File -&gt; New -&gt; Web Site, selecione <span style="font-weight: bold;">Fluorine ASP.NET Web Application</span>, como mostrado na figura seguinte:</p>
<p><a rel="lightbox[roadtrip]" href="http://4.bp.blogspot.com/_qLU3RxFHN9w/R6PtUskUCAI/AAAAAAAAAEg/S-za1SwkKfk/s1600-h/Fluorine_01_new_web_site.gif"><img id="BLOGGER_PHOTO_ID_5162230537713354754" style="cursor: pointer;" src="http://4.bp.blogspot.com/_qLU3RxFHN9w/R6PtUskUCAI/AAAAAAAAAEg/S-za1SwkKfk/s320/Fluorine_01_new_web_site.gif" border="0" alt="" /></a></p>
<p>Sua <span style="font-weight: bold;">Solution Explorer</span> deve se parecer com esta imagem:</p>
<p><a rel="lightbox[roadtrip]" href="http://1.bp.blogspot.com/_qLU3RxFHN9w/R6PuK8kUCBI/AAAAAAAAAEo/H9K4iwXoCfo/s1600-h/Fluorine_02_solution_explorer.gif"><img id="BLOGGER_PHOTO_ID_5162231469721258002" style="cursor: pointer;" src="http://1.bp.blogspot.com/_qLU3RxFHN9w/R6PuK8kUCBI/AAAAAAAAAEo/H9K4iwXoCfo/s320/Fluorine_02_solution_explorer.gif" border="0" alt="" /></a></p>
<p>Abra o arquivo Sample.cs (dentro de App_Code), vamos utiliza-lo em nosso primeiro teste do Fluorine.<br />
Observe que a classe Sample está dentro do namespace www e que possui um método chamado Echo que retorna uma string e precisa de um parâmetro. O método pega a string do parâmetro (text), concatena com &#8220;Gateway echo: &#8221; e retorna.</p>
<div class="codecolorer-container csharp mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span><br />
<span style="color: #0600FF;">using</span> <span style="color: #008080;">com.TheSilentGroup.Fluorine</span><span style="color: #008000;">;</span><br />
<br />
<span style="color: #0600FF;">namespace</span> www<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#91;</span>RemotingService<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Fluorine sample service&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span><br />
&nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Sample<br />
&nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> Sample<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Echo<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> text<span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">return</span> <span style="color: #666666;">&quot;Gateway echo: &quot;</span> <span style="color: #008000;">+</span> text<span style="color: #008000;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>
<p>Pressione F5 para rodar a aplicação, clique sob o arquivo Console.aspx, note que você foi redirecionado para Fluorine.aspx, o Service Browser do Fluorine, deve se parecer com a imagem seguinte:</p>
<p><a rel="lightbox[roadtrip]" href="http://3.bp.blogspot.com/_qLU3RxFHN9w/R6PuqckUCCI/AAAAAAAAAEw/50bC8AlRmS8/s1600-h/Fluorine_03_service_browser.gif"><img id="BLOGGER_PHOTO_ID_5162232010887137314" style="cursor: pointer;" src="http://3.bp.blogspot.com/_qLU3RxFHN9w/R6PuqckUCCI/AAAAAAAAAEw/50bC8AlRmS8/s320/Fluorine_03_service_browser.gif" border="0" alt="" /></a></p>
<p>Você pode clicar no link “<span style="font-weight: bold;">• www.Sample</span>” para ver a especificação dos métodos e também obter um exemplo de código em ActionScript 1 e 2 que já roda os métodos da classes Sample.</p>
<p>Para dizer ao Fluorine que você quer que determinada classe seja acessada por Flash é só você importar “com.TheSilentGroup.Fluorine” (using com.TheSilentGroup.Fluorine;), e colocar o atributo “[RemotingService("Descrição")]” na classe. Fique atento que feito isso, o Fluorine só vai mostrar no Service Browser os métodos <span style="font-weight: bold;">publicos </span>da classe, é claro que sem contar o construtor.<br />
Veja como o Service Browser detalha os métodos das classes e já deixa um exemplo de Script para utilizarmos no Flash:</p>
<p><a rel="lightbox[roadtrip]" href="http://1.bp.blogspot.com/_qLU3RxFHN9w/R6PwD8kUCDI/AAAAAAAAAE4/XRd9aTQi5RQ/s1600-h/Fluorine_04_service_browser_sample.gif"><img id="BLOGGER_PHOTO_ID_5162233548485429298" style="cursor: pointer;" src="http://1.bp.blogspot.com/_qLU3RxFHN9w/R6PwD8kUCDI/AAAAAAAAAE4/XRd9aTQi5RQ/s320/Fluorine_04_service_browser_sample.gif" border="0" alt="" /></a></p>
<p>Visto que o Service Browser já gera o código correspondente em ActionScript 1 e 2, vamos deixar o nosso tutorial mais interessante e mostrar uma forma de fazer as devidas chamadas em ActionScript 3.0. Abra o Flash, e cria um arquivo novo, no primeiro frame do Flash insira o código a seguir:</p>
<div class="codecolorer-container actionscript3 mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="actionscript3 codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span><span style="color: #000066; font-weight: bold;">.*;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> onResult<span style="color: #000000;">&#40;</span>responds<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><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><br />
&nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onResult: &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> responds<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #339966; font-weight: bold;">function</span> onFault<span style="color: #000000;">&#40;</span>responds<span style="color: #000066; font-weight: bold;">:</span><a href="http://www.google.com/search?q=object%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:object.html"><span style="color: #004993;">Object</span></a><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><br />
&nbsp; &nbsp; <span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;fault &quot;</span> <span style="color: #000066; font-weight: bold;">+</span> responds<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">toString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<span style="color: #000000;">&#125;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> responder <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=responder%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:responder.html"><span style="color: #004993;">Responder</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=responder%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:responder.html"><span style="color: #004993;">Responder</span></a><span style="color: #000000;">&#40;</span>onResult<span style="color: #000066; font-weight: bold;">,</span> onFault<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
<br />
<span style="color: #6699cc; font-weight: bold;">var</span> gateway <span style="color: #000066; font-weight: bold;">:</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a> = <span style="color: #0033ff; font-weight: bold;">new</span> <a href="http://www.google.com/search?q=netconnection%20inurl:http://livedocs.adobe.com/flex/201/langref/%20inurl:netconnection.html"><span style="color: #004993;">NetConnection</span></a><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
gateway<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;http://localhost:2471/www/Gateway.aspx&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span><br />
gateway<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;www.Sample.Echo&quot;</span><span style="color: #000066; font-weight: bold;">,</span> responder<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Primeiro teste do Fluorine!&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></div></td></tr></tbody></table></div>
<p>Fique atento quanto ao endereço do Gateway.aspx, pois no nosso exemplo estou utilizando o endereço que o próprio Visual Studio cria quando rodamos a aplicação, por isto que temos esta portar “maluca” (http://localhost:<span style="font-weight: bold;">2471</span>).</p>
<p>Depois que você rodar a aplicação no Visual Studio, pegar o endereço gerado por ele, colar o endereço dentro de ‘gateway.connect(&#8220;<span style="font-weight: bold;">ENDEREÇO</span>&#8220;);’ e exportar o flash, você deve receber a mensagem “onResult: Gateway echo: Primeiro teste do Fluorine!”. Se foi exatamente isso que aconteceu, uueebá! Você acabou de fazer o seu primeiro teste de Flash Remoting com ASP.NET utilizando Fluorine!!! Fácil não?</p>
<p><span style="font-weight: bold;">Agora vamos entender cada linha de código desse nosso ActionScript 3.0:</span><br />
<span style="font-weight: bold;">1ª – </span>Importamos todas as classes que nos ajudam a efetuar conexões do Flash com o “Mundo Externo”.<br />
<span style="font-weight: bold;">3ª à 9ª – </span>Criamos as funções de callback que vão receber as respostas da nossa requisição.<br />
<span style="font-weight: bold;">11ª – </span>Criamos um Responder para armazenar as nossas funções de respostas (onResult e onFault).<br />
<span style="font-weight: bold;">13ª – </span>Criamos o nosso gateway, responsável pela comunicação com o Fluorine.<br />
<span style="font-weight: bold;">14ª – </span>Conectamos o nosso gateway ao Serviço do Fluorine.<br />
<span style="font-weight: bold;">15ª – </span>Efetuamos a chamada para o método <span style="font-weight: bold;">Echo</span> da classe <span style="font-weight: bold;">Sample</span> que se encontra no namespace <span style="font-weight: bold;">www</span>, passamos como segundo parâmetro o Responder (criado na linha 11) e como 3º parâmetro passamos o uma string, pois o método Echo precisa de uma string para funcionar.</p>
<p>É isso ai pessoal, espero ter ajudado aqueles que precisam da combinação Flash + ASP.NET, como foi o meu caso, pois já conhecia o AMFPHP mas no meu trabalho atual utilizamos ASP.NET.</p>
<p>No próximo post vou mostrar como transferir um bitmap do Flash para o Fluorine, agora a coisa vai ficar boa :)</p>
<p>Link para download do projeto:<br />
<a href="http://blog.bsoares.com.br/wp-content/uploads/2009/03/20080202_projeto.zip" target="_self">http://blog.bsoares.com.br/wp-content/uploads/2009/03/20080202_projeto.zip</a></p>
<p><span style="font-weight: bold;">Links relacionados:</span><br />
• Fluorine: <a href="http://fluorine.thesilentgroup.com/fluorine">http://fluorine.thesilentgroup.com/fluorine</a><br />
• Fluorine download: <a href="http://fluorine.thesilentgroup.com/fluorine/download.html">http://fluorine.thesilentgroup.com/fluorine/download.html</a><br />
• Flash Remoting: <a href="http://www.adobe.com/devnet/flashremoting/">http://www.adobe.com/devnet/flashremoting/</a><br />
• AMF3: <a href="http://osflash.org/documentation/amf3">http://osflash.org/documentation/amf3</a><br />
• AMFPHP: <a href="http://www.amfphp.org/">http://www.amfphp.org</a><br />
• Gateway: <a href="http://pt.wikipedia.org/wiki/Gateway">http://pt.wikipedia.org/wiki/Gateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bsoares.com.br/remoting/fluorine-uma-alternativa-de-flash-remoting-com-aspnet/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
