<?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>unijimpe &#187; ActionScript</title> <atom:link href="http://blog.unijimpe.net/category/actionscript/feed/" rel="self" type="application/rss+xml" /><link>http://blog.unijimpe.net</link> <description>Desarrollo Web, SEO, Adsense</description> <lastBuildDate>Mon, 28 Nov 2011 03:18:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Depurar Flash con Firebug</title><link>http://blog.unijimpe.net/depurar-flash-con-firebug/</link> <comments>http://blog.unijimpe.net/depurar-flash-con-firebug/#comments</comments> <pubDate>Mon, 16 May 2011 04:57:20 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Firefox]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[AS2]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[firebug]]></category> <category><![CDATA[Safari]]></category> <category><![CDATA[trace]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1268</guid> <description><![CDATA[<p>Depurar flash en el ambiente de desarrollo es sencillo a través del método <em>trace</em> que muestra un texto de forma semejante a la función <em>alert</em> de javascript. El problema radica cuando tenemos que depurar los SWFs &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Depurar flash en el ambiente de desarrollo es sencillo a través del método <em>trace</em> que muestra un texto de forma semejante a la función <em>alert</em> de javascript. El problema radica cuando tenemos que depurar los SWFs ya publicados en una pagina pues trace solo funciona en el <em>Flash IDE</em>.</p><p><img src="http://blog.unijimpe.net/wp-content/uploads/2011/05/tracer.gif" alt="" title="tracer" width="398" height="299" class="alignnone size-full wp-image-1269" /></p><p><strong>Creando un trace personalizado</strong></p><p>La solución es sencilla, para ello vamos a crear una función en flash llamada <em>tracer</em> que además de hacer el trace normal utilice la función <em>console.log</em> de Firebug con lo cual podemos imprimir el resultado de cualquier parámetro en el navegador.</p><div class="syntax_hilite"><div id="actionscript-4"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">external</span>.<span style="color: #006600;">ExternalInterface</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> tracer<span style="color: #66cc66;">&#40;</span>msg:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>msg<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; ExternalInterface.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">"console.log"</span> , msg<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Utilizar esta función es sencilla, tiene la misma sintaxis de la función trace. Por ejemplo si deseamos imprimir un texto tendríamos:</p><div class="syntax_hilite"><div id="actionscript-5"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">tracer<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Start..."</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>También se puede utilizar dentro de bucles o estructuras condicionales:</p><div class="syntax_hilite"><div id="actionscript-6"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i=<span style="color: #cc66cc;color:#800000;">0</span>; i&lt;<span style="color: #cc66cc;color:#800000;">10</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; tracer<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"-&gt; "</span> + i<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Otra forma de depurar Flash en el navegador es utilizando la extensión para Firefox llamada <a href="http://blog.coursevector.com/flashbug">Flashbug</a> pero necesita tener instalado la versión Debug de Flash Player, mientras que la versión que hemos presentado es mucho mas sencilla y no requiere instalar extensiones ni otra versión del player. También funciona en Safari pues este soporta el comando console.log().</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/tracer.zip" title="Tracer"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/depurar-flash-con-firebug/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Youtube Video Player: tubePlayer 1.0 (beta)</title><link>http://blog.unijimpe.net/tubeplayer-1-0-beta/</link> <comments>http://blog.unijimpe.net/tubeplayer-1-0-beta/#comments</comments> <pubDate>Mon, 25 Oct 2010 05:25:41 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Tools]]></category> <category><![CDATA[Youtube]]></category> <category><![CDATA[AS2]]></category> <category><![CDATA[autoplay]]></category> <category><![CDATA[fullscreen]]></category> <category><![CDATA[player]]></category> <category><![CDATA[videos]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1238</guid> <description><![CDATA[<p>Después de algún tiempo tenemos el agrado de presentar la nueva versión de <strong>tubePlayer</strong> el reproductor de vídeos de Youtube personalizado. Todo esto gracias a los comentarios y sugerencias de los visitantes a este blog, con &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Después de algún tiempo tenemos el agrado de presentar la nueva versión de <strong>tubePlayer</strong> el reproductor de vídeos de Youtube personalizado. Todo esto gracias a los comentarios y sugerencias de los visitantes a este blog, con lo cual hemos logrado un mejor rendimiento del player.</p><p> <object width="510" height="320"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2010/11/tubeplayer.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param><param name="flashvars" value=" videoId=pa14VNsdSYM"></param> <embed type="application/x-shockwave-flash" width="510" height="320" src="http://blog.unijimpe.net/wp-content/uploads/2010/11/tubeplayer.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" flashvars=" videoId=pa14VNsdSYM" ></embed> </object></p><h3>Características</h3><p>En esta nueva versión se ha reescrito completamente el reproductor utilizando <a href="http://code.google.com/apis/youtube/flash_api_reference_as2.html">YouTube ActionScript 2.0 Player API</a> el cual corrige algunos problemas de la versión anterior y mejora características solicitadas por nuestros visitantes.</p><ul><li>Reescrito completamente en ActionScript 2.0 con OOP.</li><li>Opción para autoplay de vídeos.</li><li>Opción para el volumen por defecto.</li><li>Se puede desplazar al cualquier parte del vídeo.</li><li>Imagen de previsualización del vídeo.</li><li>Mensaje de error si el vídeo esta bloqueado o eliminado.</li><li>No se muestra publicidad en los vídeos.</li><li>No se muestran las anotaciones en los vídeos.</li><li>Corregido el autoescalado del vídeo de acuerdo al tamaño del player.</li><li>Reproducción en pantalla completa.</li></ul><p>ActionScript 3.0 es muy potente pero el API es AS3 tiene el problema que muestra la publicidad en los vídeos, por lo cual decidimos trabajar con AS2 para mostrar los vídeos sin publicidad. Además de ello estamos trabajando para integrar <em>tubePlayer</em> a un plugin para WordPress que permita utilizar este player de forma sencilla en los blogs.</p><h3>Como utilizar tubePlayer</h3><p>Primero debes descargar la ultima versión del player y subir el archivo <em>tubeplayer.swf</em> a tu servidor web. Luego lo incluyes en tu página como cualquier SWF pero con tres parámetros por medio de <em>flashVars</em>:</p><ul><li><strong>videoId</strong> <em>(Requerido)</em><br />Identificador del vídeo de Youtube a reproducir.</li><li><strong>autoPlay</strong> <em>(Opcional)</em><br />Define si el vídeo se reproducirá automáticamente. Acepta valores <em>true</em> o <em>false</em>.</li><li><strong>volume</strong> <em>(Opcional)</em><br />Volumen inicial del vídeo. Acepta valores enteros de 0 a 100.</ul><p>Podemos embeber el video utilizando el tag de HTML <em><embed></em>:</p><div class="syntax_hilite"><div id="html-9"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/object.html"><span style="color: #000000;">&lt;object</span></a> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"510"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"320"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/param.html"><span style="color: #000000;">&lt;param</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"movie"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"http://domain/path/tubeplayer.swf"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/param.html"><span style="color: #000000;">&lt;param</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"flashVars"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"videoId=6hzrDeceEKc&amp;autoPlay=true"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/param.html"><span style="color: #000000;">&lt;param</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"allowFullscreen"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"true"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"tubeplayer.swf"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"510"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"320"</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;flashVars=<span style="color: #ff0000;">"videoId=pa14VNsdSYM"</span> allowFullscreen=<span style="color: #ff0000;">"true"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/object&gt;</span></span></div></li></ol></div></div></div><p></p><p>También podemos utilizar SWFObject para incluir el player:</p><div class="syntax_hilite"><div id="html-10"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"divmovie"</span><span style="color: #000000;">&gt;</span></a></span>tubePlayer<span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;swfobject.embedSWF(&quot;http://domain/path/tubeplayer.swf&quot;, &quot;divmovie&quot;, &quot;510&quot;, &quot;320&quot;, &quot;9&quot;, &quot;&quot;,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;{videoId: &quot;6hzrDeceEKc&quot;}, {allowFullscreen: &quot;true&quot;});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>Pueden ver el player funcionando en <a href="http://samples.unijimpe.net/tubeplayer-1.0-beta/">tubePlayer 1.0 (beta) demo</a>, donde pueden ingresar rl identificador del vídeo que desean visualizar.</p><h3>Sugerencias</h3><p>Este player esta en versión beta y esperamos nos hagan llegar su observaciones y sugerencias para de esta forma lograr un buen player que nos beneficie a todos.</p><p>Pueden dejar sus sugerencias en nuestro formulario de comentarios. En el transcurso de esta semana estaremos trabajando en la mejora del player y la otra semana estaremos lanzando la versión final que incluye un plugin para WordPress.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/tubeplayer-1.0.zip" title="tubeplayer 1.0"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/tubeplayer-1-0-beta/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Publicar Videos de Youtube en Flash</title><link>http://blog.unijimpe.net/publicar-videos-de-youtube-en-flash/</link> <comments>http://blog.unijimpe.net/publicar-videos-de-youtube-en-flash/#comments</comments> <pubDate>Fri, 04 Dec 2009 04:53:58 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Youtube]]></category> <category><![CDATA[player]]></category> <category><![CDATA[videos]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1126</guid> <description><![CDATA[<p>Compartir vídeos de <em>Youtube</em> es una tarea común y sencilla en HTML con el código que ofrece Youtube el cual se coloca en el código html. Veamos como publicar vídeos de Youtube en páginas hechas en &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Compartir vídeos de <em>Youtube</em> es una tarea común y sencilla en HTML con el código que ofrece Youtube el cual se coloca en el código html. Veamos como publicar vídeos de Youtube en páginas hechas en Flash, para ello utilizaremos el API <a href="http://code.google.com/apis/youtube/flash_api_reference_as2.html">YouTube ActionScript 2.0 Player API Reference</a> el cual brinda métodos para embeber los vídeos en Flash.</p><p> <object width="500" height="350"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2009/12/youtube.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="500" height="350" src="http://blog.unijimpe.net/wp-content/uploads/2009/12/youtube.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p><strong>Cargando Videos de Youtube</strong><br /> Para cargar un vídeo de Youtube se debe cargar como si fuera un MovieClip normal, para ello se puede utilizar los métodos de la clase <em>MovieClipLoader</em>. Para la ruta de los vídeos se puede utilizar el URL: <code>http://www.youtube.com/v/ID</code> Donde ID es el identificador del vídeo que se desea visualizar. Entonces si tenemos un MovieClip llamado clip donde deseamos mostrar el vídeo tendríamos el siguiente código:</p><div class="syntax_hilite"><div id="actionscript-14"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tload:<span style="color: #0066CC;">MovieClipLoader</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClipLoader</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">tload.<span style="color: #0066CC;">loadClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"http://www.youtube.com/v/Jmhpy8c8hbw"</span>, clip<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>El vídeo se carga correctamente pero con dimensiones de 480 x 385 pixels. Si deseamos cargar los vídeos con un tamaño especifico sin deformar el vídeo es necesario crear un detector de eventos para ejecutarlo cuando el player del video se ha cargado completamente.</p><div class="syntax_hilite"><div id="actionscript-15"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tinte:<span style="color: #0066CC;">Number</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tlist:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">tlist.<span style="color: #0066CC;">onLoadInit</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; tinte = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>checkVideo, <span style="color: #cc66cc;color:#800000;">250</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tload:<span style="color: #0066CC;">MovieClipLoader</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClipLoader</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">tload.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span>tlist<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">tload.<span style="color: #0066CC;">loadClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"http://www.youtube.com/v/Jmhpy8c8hbw"</span>, clip<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Una vez que se ha cargado player de Youtube, utilizamos la función <em>checkVideo</em> que se encarga de verificar que el player, una ver cargado el player asignamos las dimensiones con el método <em>setSize</em>. Notar que al inicio hemos ocultado el player asignándole transparencia 0, al final después de haber redimensionado el player volvemos a mostrar el video cambiando la transparencia a 100.</p><div class="syntax_hilite"><div id="actionscript-16"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">clip.<span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;color:#800000;">0</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tinte:<span style="color: #0066CC;">Number</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tlist:<span style="color: #0066CC;">Object</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">tlist.<span style="color: #0066CC;">onLoadInit</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; tinte = <span style="color: #0066CC;">setInterval</span><span style="color: #66cc66;">&#40;</span>checkVideo, <span style="color: #cc66cc;color:#800000;">250</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tload:<span style="color: #0066CC;">MovieClipLoader</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">MovieClipLoader</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">tload.<span style="color: #0066CC;">addListener</span><span style="color: #66cc66;">&#40;</span>tlist<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">tload.<span style="color: #0066CC;">loadClip</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"http://www.youtube.com/v/Jmhpy8c8hbw"</span>, clip<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> checkVideo<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>clip.<span style="color: #006600;">isPlayerLoaded</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; clip.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">348</span>, <span style="color: #cc66cc;color:#800000;">278</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; clip.<span style="color: #0066CC;">_alpha</span> = <span style="color: #cc66cc;color:#800000;">100</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">clearInterval</span><span style="color: #66cc66;">&#40;</span>tinte<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Listo, tenemos nuestro vídeo cargado y con las dimensiones deseadas en Flash. Les dejo los archivos fuentes para que lo descarguen y hagan sus pruebas.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/youtube-flash.zip" title="Youtube en Flash"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/publicar-videos-de-youtube-en-flash/feed/</wfw:commentRss> <slash:comments>40</slash:comments> </item> <item><title>Insertar Google Maps en Flash</title><link>http://blog.unijimpe.net/insertar-google-maps-en-flash/</link> <comments>http://blog.unijimpe.net/insertar-google-maps-en-flash/#comments</comments> <pubDate>Mon, 05 Oct 2009 06:18:41 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[adobe]]></category> <category><![CDATA[API]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[click]]></category> <category><![CDATA[editor]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[maps]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[ZIP]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1092</guid> <description><![CDATA[<p><a href="http://maps.google.com">Google Maps</a> permite incluir cualquier mapa en tu web utilizando algunas sentencias de Javascript, también ofrece <a href="http://code.google.com/apis/maps/documentation/flash/">Google Maps API for Flash</a> para incluir los mapas en Flash utilizando ActionScript.</p><p>Para hacer uso de este API lo &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://maps.google.com">Google Maps</a> permite incluir cualquier mapa en tu web utilizando algunas sentencias de Javascript, también ofrece <a href="http://code.google.com/apis/maps/documentation/flash/">Google Maps API for Flash</a> para incluir los mapas en Flash utilizando ActionScript.</p><p>Para hacer uso de este API lo primero es registrarse gratuitamente un obtener <a href="http://code.google.com/apis/maps/signup.html">Google Maps API Key</a> el cual nos permitirá mostrar los mapas en nuestra web. Además es necesario instalar el componente map.swc en el editor de Flash.</p><p><strong>Instalando el Componente</strong><br /> Para instalar la librería es necesario descargar los archivos desde <a href="http://maps.googleapis.com/maps/flash/release/sdk.zip">http://maps.googleapis.com/maps/flash/release/sdk.zip</a>. Luego de extraer el archivo ubicamos el archivo <em>map_x_y.swc</em> en la carpeta <em>lib</em>, donde <em>x</em> e <em>y</em> indican la versión actual del componente. Creamos una carpeta llamada Google y copiamos el archivo .swc:</p><p>Windows:<br /> <code>C:\Program Files\Adobe\Adobe Flash CS3\language\Configuration\Components</code><br /> MAC:<br /> <code>Macintosh HD/Applications/Adobe Flash CS3/Configuration/Components</code></p><p><strong>Utilizando el componente</strong><br /> Una vez instalado el componente, en el <em>Panel de Componentes</em> de Flash se puede ver un nuevo item llamado <em>GoogleMapsLibrary</em>. Para poder utilizarlo podemos jalar el componente al escenario o podemos jalarlo directamente a la librería de nuestro archivo flash.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/10/flash-gmap.jpg" alt="flash-gmap" title="flash-gmap" width="283" height="146" /></p><p><strong>Creando nuestro primer Mapa</strong><br /> Lo primero es incluir las clases necesarias (<em>com.google.maps.*</em>) para incluir y manejar los mapas, definimos la latitud, longitud y zoom que vamos a utilizar. Luego de ello creamos una instancia de la clase <em>Map</em>, asignamos nuestro KEY. Definimos el ancho y alto de nuestro mapa con el método <em>setSize</em>.</p><div class="syntax_hilite"><div id="actionscript-20"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.*;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lat:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">12</span>.<span style="color: #cc66cc;color:#800000;">04144</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lon:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">77</span>.<span style="color: #cc66cc;color:#800000;">023188</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> zoom:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">17</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> map:Map = <span style="color: #000000; font-weight: bold;">new</span> Map<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">map.<span style="color: #0066CC;">key</span> = <span style="color: #ff0000;">"tu_api_key"</span>;</div></li><li style="color:#3A6A8B;"><div style="">map.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">500</span>, <span style="color: #cc66cc;color:#800000;">350</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">map.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapEvent.<span style="color: #006600;">MAP_READY</span>, onMapReady<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onMapReady<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LatLng<span style="color: #66cc66;">&#40;</span>lat,lon<span style="color: #66cc66;">&#41;</span>, zoom, MapType.<span style="color: #006600;">NORMAL_MAP_TYPE</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>En el ejemplo hemos creado un mapa de 500x350 pixels con un zoom de 17 y estamos mostrando el mapa normal.</p><p> <object width="500" height="350"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-basic.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="500" height="350" src="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-basic.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p>Respecto a los tipos de mapas disponibles tenemos los siguientes:</p><ul><li><strong>HYBRID_MAP_TYPE</strong>: Mapa con fotografías satelitales y nombres las vías.</li><li><strong>NORMAL_MAP_TYPE</strong>: Mapa normal con nombre de las vías.</li><li><strong>PHYSICAL_MAP_TYPE</strong>: muestra el mapa físico.</li><li><strong>SATELLITE_MAP_TYPE</strong>: mapa con las fotografías satelitales.</li></ul><p><strong>Agregando controles a nuestros Mapas</strong><br /> Para incluir los controles es necesario incluir las clases <em>com.google.maps.controls.*</em>, luego de ello podemos agregar los controles de Zoom y de posición a nuestros mapas de la siguiente forma:</p><div class="syntax_hilite"><div id="actionscript-21"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.*;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.<span style="color: #006600;">controls</span>.*;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lat:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">12</span>.<span style="color: #cc66cc;color:#800000;">04144</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lon:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">77</span>.<span style="color: #cc66cc;color:#800000;">023188</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> zoom:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">17</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> map:Map = <span style="color: #000000; font-weight: bold;">new</span> Map<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">map.<span style="color: #0066CC;">key</span> = <span style="color: #ff0000;">"tu_api_key"</span>;</div></li><li style="color:#26536A;"><div style="">map.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">500</span>, <span style="color: #cc66cc;color:#800000;">350</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">map.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapEvent.<span style="color: #006600;">MAP_READY</span>, onMapReady<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onMapReady<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LatLng<span style="color: #66cc66;">&#40;</span>lat,lon<span style="color: #66cc66;">&#41;</span>, zoom, MapType.<span style="color: #006600;">HYBRID_MAP_TYPE</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">addControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PositionControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">addControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ZoomControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p> Con este ejemplo tenemos un zoom inicial de 17 pero ya podemos hacer zoom a nuestro gusto y además tenemos los controles para mover el mapa.</p><p> <object width="500" height="350"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-controls.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="500" height="350" src="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-controls.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p><strong>Agregando Marcadores</strong><br /> Si queremos personalizar nuestros mapas podemos hacer uso de los marcadores para indicar una posición determinada e incluso sus descripciones. Para ello incluimos las clases com.google.maps.overlays.* con lo cual podemos utilizar los métodos para mostrar los marcadores.</p><div class="syntax_hilite"><div id="actionscript-22"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.*;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.<span style="color: #006600;">controls</span>.*;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">maps</span>.<span style="color: #006600;">overlays</span>.*;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lat:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">12</span>.<span style="color: #cc66cc;color:#800000;">04144</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> lon:<span style="color: #0066CC;">Number</span> = -<span style="color: #cc66cc;color:#800000;">77</span>.<span style="color: #cc66cc;color:#800000;">023188</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> zoom:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">17</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> map:Map = <span style="color: #000000; font-weight: bold;">new</span> Map<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">map.<span style="color: #0066CC;">key</span> = <span style="color: #ff0000;">"your_api_key"</span>;</div></li><li style="color:#3A6A8B;"><div style="">map.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">500</span>, <span style="color: #cc66cc;color:#800000;">350</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">map.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapEvent.<span style="color: #006600;">MAP_READY</span>, onMapReady<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">this</span>.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>map<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onMapReady<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">setCenter</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LatLng<span style="color: #66cc66;">&#40;</span>lat,lon<span style="color: #66cc66;">&#41;</span>, zoom, MapType.<span style="color: #006600;">SATELLITE_MAP_TYPE</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">addControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PositionControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">addControl</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ZoomControl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> marker:Marker = <span style="color: #000000; font-weight: bold;">new</span> Marker<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LatLng<span style="color: #66cc66;">&#40;</span>lat, lon<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; marker.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MapMouseEvent.<span style="color: #006600;">CLICK</span>, <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; marker.<span style="color: #006600;">openInfoWindow</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> InfoWindowOptions<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>title: <span style="color: #ff0000;">"Plaza de Toros de Acho"</span>, content:<span style="color: #ff0000;">"Lima, Perú"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; map.<span style="color: #006600;">addOverlay</span><span style="color: #66cc66;">&#40;</span>marker<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Ahora tenemos un marcador en nuestro mapa y al hacerle click mostramos un mensaje personalizado que puede indicar el lugar que estamos visualizando.</p><p> <object width="500" height="350"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-markers.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="500" height="350" src="http://blog.unijimpe.net/wp-content/uploads/2009/10/gmaps-markers.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p><strong>Más Información</strong><br /> Hemos visto con con sentencias sencillas podemos incluir los mapas de Google Maps en nuestros archivos Flash sin ningún problema, obviamente hay muchas mas opciones para personalizar estos mapas las cuales por cuestion de tiempo no podemos discutir aca, pero les dejo los enlaces para que puedan ampliar este tema.</p><ul><li><a href="http://code.google.com/apis/maps/documentation/flash/tutorial-flash.html">Google Maps API for Flash - Flash CS3 Tutorial</a></li><li><a href="http://code.google.com/apis/maps/documentation/flash/reference.html">Google Maps API ActionScript Reference</a></li><li><a href="http://code.google.com/apis/maps/documentation/flash/articles.html">Google Maps for Flash - Articles</a></li></ul><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/gmaps-flash.zip" title="Google Maps en Flash"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/insertar-google-maps-en-flash/feed/</wfw:commentRss> <slash:comments>36</slash:comments> </item> <item><title>Google Analytics para Flash</title><link>http://blog.unijimpe.net/google-analytics-para-flash/</link> <comments>http://blog.unijimpe.net/google-analytics-para-flash/#comments</comments> <pubDate>Sat, 22 Nov 2008 16:44:55 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[adobe]]></category> <category><![CDATA[analytics]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[click]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[swf]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=969</guid> <description><![CDATA[<p>Acaban de lanzar una versión del código de seguimiento de Google Analytics, llamado <a href="http://code.google.com/p/gaforflash/">gaforflash</a> escrito en AS3 especialmente preparado para facilitar el seguimiento de páginas Flash. Este componente contiene toda la funcionalidad del código Javascript de &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Acaban de lanzar una versión del código de seguimiento de Google Analytics, llamado <a href="http://code.google.com/p/gaforflash/">gaforflash</a> escrito en AS3 especialmente preparado para facilitar el seguimiento de páginas Flash. Este componente contiene toda la funcionalidad del código Javascript de <em>Google Analytics</em> y es 100% compatible con las últimas versiones del código de seguimiento <em>ga.js</em>.</p><p>En anterior oportunidad habíamos comentado sobre <a href="http://blog.unijimpe.net/google-analytics-y-flash/">Google Analytics y Flash</a>, una técnica que utiliza <em>getURL</em> para comunicar Flash con Javascript y por ello comunicar Flash con las funciones contenidas en <em>ga.js</em>. Pero esta nueva versión no requiere el uso de la librería <em>ga.js</em> y el uso <em>Google Analytics</em> es mucho mas sencillo pues se provee de funciones que se pueden llamar directamente con AS3.</p><p><strong>Instalar el Componente</strong><br /> Para hacer uso del código de seguimiento en Flash, hace falta instalar un componente, para ello es necesario descargar los archivos desde <a href="http://code.google.com/p/gaforflash/downloads/list">gaforflash downloads</a>. El siguiente paso es crear una carpeta llamada Google en el directorio de componentes de Flash.</p><div class="syntax_hilite"><div id="code-27"><div class="code"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#FF9933; font-style:italic;">// For Windows: </span></div></li><li style="color:#26536A;"><div style="">C:\Program Files\Adobe\Adobe Flash CS3\en\Configuration\Components</div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#FF9933; font-style:italic;">// For Mac OS X:</span></div></li><li style="color:#26536A;"><div style="">Macintosh HD/Applications/Adobe Flash CS3/Configuration/Components</div></li></ol></div></div></div><p></p><p>Luego, extraemos el archivo recién descargado y copiamos el archivo <strong>analytics.swc</strong> a la carpeta recién creada, con esto ya esta instalado el componente y ya estamos listo para hacer uso de sus propiedades y métodos.</p><p><strong>Utilizando el Componente</strong><br /> Lo primero es importar las clases necesarias para hacer el seguimiento, esto lo hacemos al inicio de todo el código:</p><div class="syntax_hilite"><div id="actionscript-28"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">analytics</span>.<span style="color: #006600;">AnalyticsTracker</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">analytics</span>.<span style="color: #006600;">GATracker</span>;</div></li></ol></div></div></div><p></p><p>El siguiente paso es crear una instancia del objeto <em>GATracker</em>, este objeto permite definir como se comportará el seguimiento de eventos en nuestro flash y cuya sintaxis es la siguiente.</p><div class="syntax_hilite"><div id="actionscript-29"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">new</span> GATracker<span style="color: #66cc66;">&#40;</span> display, <span style="color: #ff0000;">"gaID"</span>, <span style="color: #ff0000;">"mode"</span>, debug <span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Donde se tienen los siguiente parámetros.</p><ul><li><strong>display</strong>: Referencia al actual objeto display.</li><li><strong>gaID</strong>: es tu código de Google Analytics para registrar las visitas.</li><li><strong>mode</strong>: es el modo de tracking (Bridge o AS3)</li><li><strong>debug</strong>: modo de depuración (true o false).</li></ul><p>Luego de ello creamos una variable del tipo <em>GATracker</em> y posteriormente lo utilizamos para hacer el seguimiento cada vez que se hace click a un botón.</p><div class="syntax_hilite"><div id="actionscript-30"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">analytics</span>.<span style="color: #006600;">AnalyticsTracker</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">google</span>.<span style="color: #006600;">analytics</span>.<span style="color: #006600;">GATracker</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> tracker:AnalyticsTracker;</div></li><li style="color:#26536A;"><div style="">tracker = <span style="color: #000000; font-weight: bold;">new</span> GATracker<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">this</span>, <span style="color: #ff0000;">"UA-XXXXXX-X"</span>, <span style="color: #ff0000;">"AS3"</span>, <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style="">playGame.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MouseEvent.<span style="color: #006600;">CLICK</span>, onButtonClick <span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onButtonClick <span style="color: #66cc66;">&#40;</span> event:Event <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;tracker.<span style="color: #006600;">trackPageview</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"/section"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Esta es una nueva opción que no solo sirve para hacer el seguimiento de visitas de páginas Flash si que también permitirá hacer el seguimiento de eventos en archivos SWFs individuales sin necesidad que estén incluidas en un HTML.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/google-analytics-para-flash/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>trim en ActionScript</title><link>http://blog.unijimpe.net/trim-en-actionscript/</link> <comments>http://blog.unijimpe.net/trim-en-actionscript/#comments</comments> <pubDate>Tue, 14 Oct 2008 04:41:31 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[trim]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=929</guid> <description><![CDATA[<p>La función <strong>trim</strong> es una función muy común utilizada en la mayoría de lenguajes de programación la cual se encarga de eliminar los espacios en blanco al inicio y al final de una cadena. <em>ActionScript</em> por &#8230;</p>]]></description> <content:encoded><![CDATA[<p>La función <strong>trim</strong> es una función muy común utilizada en la mayoría de lenguajes de programación la cual se encarga de eliminar los espacios en blanco al inicio y al final de una cadena. <em>ActionScript</em> por defecto no incluye esta función por lo cual tendremos que construirla manualmente.</p><p>La forma mas común de implementar esta función es crear dos funciones una para eliminar los espacios en blanco al inicio y otra al final de la cadena y luego unirlas, en esta ocasión les presento dos funciones preparadas para ser rápidas y eficientes.</p><p><strong>trim en ActionScript 2.0</strong></p><p>Es función fue creada por <a href="http://www.frogstyle.ch/p.cfm?s=18">frog style web engineering</a> con una serie de funciones adicionales. La función recorre los elementos desde el inicio y desde el fin eliminando los espacios en blanco, saltos de linea, tabuladores obteniéndose de esa forma la función <strong>trim</strong>.</p><div class="syntax_hilite"><div id="actionscript-34"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> trim<span style="color: #66cc66;">&#40;</span>str:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i=<span style="color: #cc66cc;color:#800000;">0</span>; str.<span style="color: #0066CC;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>&lt;<span style="color: #cc66cc;color:#800000;">33</span>; i++<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j=str.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;color:#800000;">1</span>; str.<span style="color: #0066CC;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>j<span style="color: #66cc66;">&#41;</span>&lt;<span style="color: #cc66cc;color:#800000;">33</span>; j--<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> str.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span>i, j+<span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Luego de ello podemos utilizar la función de forma sencilla, como se muestra a continuación.</p><div class="syntax_hilite"><div id="actionscript-35"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> txt:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"&nbsp; &nbsp; Hola trim!!&nbsp; "</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>trim<span style="color: #66cc66;">&#40;</span>txt<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>trim en ActionScript 3</strong><br /> Ahora en el caso de <em>ActionScript 3</em> se puede hacer uso de las expresiones regulares, esta función publicada en <a href="http://www.astorm.ch/blog/index.php?post/2008/08/07/trim-en-AS3">AStorm - Devblog</a> busca como en el caso anterior los espacios en blanco y los elimina pero con una expresión regular.</p><div class="syntax_hilite"><div id="actionscript-36"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> trim<span style="color: #66cc66;">&#40;</span>str:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> str.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>/^\s*<span style="color: #66cc66;">&#40;</span>.*?<span style="color: #66cc66;">&#41;</span>\s*$/g, <span style="color: #ff0000;">"$1"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Nuevamente podemos hacer las pruebas y verificar que efectivamente tenemos nuestra función <strong>trim</strong> que elimina los espacios en blanco al inicio y al final de una cadena.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/trim-en-actionscript/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>JSON con Flash</title><link>http://blog.unijimpe.net/json-con-flash/</link> <comments>http://blog.unijimpe.net/json-con-flash/#comments</comments> <pubDate>Tue, 05 Aug 2008 05:40:21 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[adobe]]></category> <category><![CDATA[AJAX]]></category> <category><![CDATA[API]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[click]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[parser]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[proxy]]></category> <category><![CDATA[scroll]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=874</guid> <description><![CDATA[<p>Como comentabamos hace poco en <a href="http://blog.unijimpe.net/json-con-mootools/">JSON con Mootools</a>, JSON es un formato para intercambio de datos que a diferencia de XML es mucho mas ligero pues se transmite la información como un objeto Javascript. En &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Como comentabamos hace poco en <a href="http://blog.unijimpe.net/json-con-mootools/">JSON con Mootools</a>, JSON es un formato para intercambio de datos que a diferencia de XML es mucho mas ligero pues se transmite la información como un objeto Javascript. En esta oportunidad veremos como utilizar JSON con Flash.</p><p> <object width="450" height="400"><param name="movie" value="http://blog.unijimpe.net/wp-content/uploads/2008/08/json-final.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="450" height="400" src="http://blog.unijimpe.net/wp-content/uploads/2008/08/json-final.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p><strong>Obteniendo los Datos</strong><br /> Los datos en formato <strong>JSON</strong> para nuestro ejemplo lo obtendremos del servicio <em>Google Ajax Search API</em> del cual hemos comentado en un post anterior, para ello creamos un <strong>proxy</strong> el cual se encargará de hacer el cambio de dominio para poder acceder a esta información.</p><div class="syntax_hilite"><div id="php-42"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiQue</span> = <span style="color:#FF0000;">"Google"</span>; <span style="color:#FF9933; font-style:italic;">// variable a consultar</span></div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$apiKey</span> = <span style="color:#FF0000;">"tu_key_google"</span>; <span style="color:#FF9933; font-style:italic;">// key para acceder al servicio</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiUrl</span> = <span style="color:#FF0000;">"http://ajax.googleapis.com/ajax/services/search/web"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">if</span> <span style="color:#006600;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color:#0000FF;">$apiQue</span> = <a href="http://www.php.net/urlencode"><span style="color:#000066;">urlencode</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/readfile"><span style="color:#000066;">readfile</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$apiUrl</span>.<span style="color:#FF0000;">"?v=1.0&amp;key="</span>.<span style="color:#0000FF;">$apiKey</span>.<span style="color:#FF0000;">"&amp;q="</span>.<span style="color:#0000FF;">$apiQue</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>Utilizando JSON con ActionScript 3</strong><br /> Por defecto Flash no puede interpretar JSON, pero para ello utilizaremos la librería <a href="http://code.google.com/p/as3corelib/">as3corelib</a> el cual contiene una gran variedad de clases para extender la funcionalidades del <em>AS3</em> entre ellas un parser de JSON. Entonces descargamos los archivos y utilizamos las clase ubicadas en la carpeta <em>com</em>.</p><p>En nuestro archivo fla lo primero que hacemos es importar las clases necesarias para el funcionamiento de nuestro script.</p><div class="syntax_hilite"><div id="actionscript-43"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">adobe</span>.<span style="color: #006600;">serialization</span>.<span style="color: #006600;">json</span>.*;</div></li></ol></div></div></div><p></p><p>Lo siguiente es leer el archivo que contiene la respuesta en JSON del servidor, esto lo hacemos con la clase <em>URLLoader</em>, luego agregamos un listener para detectar que se ha completado la carga para luego ejecutar la función <em>decodeJSON</em>.</p><div class="syntax_hilite"><div id="actionscript-44"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> loader:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> ;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> request:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> ;</div></li><li style="color:#3A6A8B;"><div style="">request.<span style="color: #0066CC;">url</span> = <span style="color: #ff0000;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>request<span style="color: #66cc66;">&#41;</span> ;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, decodeJSON<span style="color: #66cc66;">&#41;</span> ;</div></li></ol></div></div></div><p></p><p>Luego definimos al función decodeJSON, la cual se ejecutará inmediatamente después de completarse la carga de los datos, aquí utilizamos el método <em>JSON.decode</em> el cual se encarga de convertir el texto en formato JSON a un objeto que sera fácilmente manipulable con <em>ActionScript</em>.</p><div class="syntax_hilite"><div id="actionscript-45"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> decodeJSON<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> loader:URLLoader = URLLoader<span style="color: #66cc66;">&#40;</span>event.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;&nbsp;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span> = JSON.<span style="color: #006600;">decode</span><span style="color: #66cc66;">&#40;</span>loader.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> results = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i=<span style="color: #cc66cc;color:#800000;">0</span>; i&lt;results.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>i + <span style="color: #ff0000;">" --&gt; "</span> + tmp.<span style="color: #006600;">title</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span> + tmp.<span style="color: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Unimos estos elementos y tenemos un parser de JSON de manera sencilla, como podemos ver lo que se hace es convertir el texto cargado en un objeto que es muy fácil de manipular en Flash.</p><p><strong>Completando nuestra aplicación</strong><br /> En el ejemplo anterior, solo hemos trazado los resultados, es momento de agregar un campo de texto para ingresar el criterio de búsqueda y otro campo de texto para mostrar los resultados, con lo cual obtenemos el siguiente código.</p><div class="syntax_hilite"><div id="actionscript-46"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">adobe</span>.<span style="color: #006600;">serialization</span>.<span style="color: #006600;">json</span>.*;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> vPath:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"proxy.php?query="</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> vRequ:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> vLoad:URLLoader = <span style="color: #000000; font-weight: bold;">new</span> URLLoader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">vRequ.<span style="color: #0066CC;">url</span> = vPath+<span style="color: #ff0000;">"unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">vLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>vRequ<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">vLoad.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> rpta:URLLoader = URLLoader<span style="color: #66cc66;">&#40;</span>event.<span style="color: #0066CC;">target</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> json:<span style="color: #0066CC;">Object</span> = JSON.<span style="color: #006600;">decode</span><span style="color: #66cc66;">&#40;</span>rpta.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Array</span> = json.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> vcon:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">Number</span>=<span style="color: #cc66cc;color:#800000;">0</span>; i&lt;data.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tmp = <span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; vcon+= <span style="color: #ff0000;">"&lt;a href='"</span>+tmp.<span style="color: #0066CC;">url</span>+<span style="color: #ff0000;">"'&gt;"</span>+tmp.<span style="color: #006600;">title</span>+<span style="color: #ff0000;">"&lt;/a&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; vcon+= <span style="color: #ff0000;">"&lt;br&gt;"</span>+tmp.<span style="color: #006600;">content</span>+<span style="color: #ff0000;">"&lt;br&gt;&lt;br&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;txtcontent.<span style="color: #0066CC;">htmlText</span> = vcon;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;scroller.<span style="color: #006600;">scrollTarget</span> = txtcontent;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style="">btsearch.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, onClick<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">btsearch.<span style="color: #006600;">buttonMode</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onClick<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;txtcontent.<span style="color: #0066CC;">htmlText</span> = <span style="color: #ff0000;">"Loading..."</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;vRequ.<span style="color: #0066CC;">url</span> = vPath+escape<span style="color: #66cc66;">&#40;</span>txtQuery.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;vLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>vRequ<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>El resultado de este ejemplo lo pueden ver al inicio de este post, como se observa ingresamos el criterio de búsqueda y obtenemos el resultado deseado. Finalmente les dejo los archivos fuente de este ejemplo para que lo descarguen y puedan realizar sus pruebas.</p><p style="text-align:center;"><a href="http://www.box.net/shared/v77ub7e04c"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/json-con-flash/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Precarga multiple en AS3</title><link>http://blog.unijimpe.net/precarga-multiple-en-as3/</link> <comments>http://blog.unijimpe.net/precarga-multiple-en-as3/#comments</comments> <pubDate>Tue, 03 Jun 2008 04:49:05 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[General]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[FLV]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[menu]]></category> <category><![CDATA[MP3]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[precarga]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=855</guid> <description><![CDATA[<p><a href="http://code.google.com/p/bulk-loader/">BulkLoader</a> es una clase escrita en AS3 que te permitirá cargar y manejar múltiples archivos de manera sencilla. Esta clase te permitirá cargar múltiples archivos de diferente tipo en una interface unificada, accediendo a los eventos &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://code.google.com/p/bulk-loader/">BulkLoader</a> es una clase escrita en AS3 que te permitirá cargar y manejar múltiples archivos de manera sencilla. Esta clase te permitirá cargar múltiples archivos de diferente tipo en una interface unificada, accediendo a los eventos de carga en la misma instancia.</p><p><strong>Utilizando BulkLoader</strong><br /> Lo primero es <a href="http://code.google.com/p/bulk-loader/downloads/list">descargar</a> la ultima versión de BulkLoader, extraen los archivos y en la carpeta <strong>src</strong> se encuentran las clases necesarias para el uso de esta librería.</p><p>Lo primero es importar las clases <em>BulkLoader</em> y <em>BulkProgressEvent</em> y posteriormente creamos una instancia de la clase BulkLoader, al cual le asignamos un nombre, en este caso <em>mainLoader</em>:</p><div class="syntax_hilite"><div id="actionscript-53"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> br.<span style="color: #006600;">com</span>.<span style="color: #006600;">stimuli</span>.<span style="color: #006600;">loading</span>.<span style="color: #006600;">BulkLoader</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> br.<span style="color: #006600;">com</span>.<span style="color: #006600;">stimuli</span>.<span style="color: #006600;">loading</span>.<span style="color: #006600;">BulkProgressEvent</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> loader:BulkLoader = <span style="color: #000000; font-weight: bold;">new</span> BulkLoader<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"mainLoader"</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>A continuación agregamos los items o elementos que deseamos cargar, pueden ser archivos jpg, gif, png, xml, mp3, flv, etc. Para ello utilizamos el método <strong>add</strong> donde asignamos la ruta a cargar y un nombre de id para recuperar los datos cargados posteriormente.</p><div class="syntax_hilite"><div id="actionscript-54"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"background.jpg"</span>, <span style="color: #66cc66;">&#123;</span>id: <span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"menu.xml"</span>, <span style="color: #66cc66;">&#123;</span>id:<span style="color: #ff0000;">"menu"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sound.mp3"</span>, <span style="color: #66cc66;">&#123;</span>id: <span style="color: #ff0000;">"sound"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>El siguiente paso es agregar los detectores de eventos o listeners (<em>COMPLETE</em>, <em>PROGRESS</em>, <em>ERROR</em>)  con los cuales podemos detectar el progreso de la carga y el termino de la misma.</p><div class="syntax_hilite"><div id="actionscript-55"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #808080; font-style: italic;">// para la carga de todos los archivos</span></div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>BulkLoader.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>BulkLoader.<span style="color: #006600;">PROGRESS</span>, onProgress<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>BulkLoader.<span style="color: #0066CC;">ERROR</span>, onError<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #808080; font-style: italic;">// para la carga de uno de los elementos</span></div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #0066CC;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>,onBgLoaded<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">PROGRESS</span>,onBgProgress<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #0066CC;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #0066CC;">ERROR</span>,onBgError<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Luego iniciamos la carga utilizando el método <em>start</em>.</p><div class="syntax_hilite"><div id="actionscript-56"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Finalmente implementamos las funciones asociadas a los detectores de eventos y obtenemos los archivos cargados, para ello podemos utilizar <em>getBitmap</em>, <em>getSound</em>, <em>getXML</em>, <em>getText</em>, <em>getNetStream</em>, <em>getSound</em>, <em>getMovieClip</em> de acuerdo al archivo que estemos cargando.</p><div class="syntax_hilite"><div id="actionscript-57"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos la imagen </span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> mcBg:Bitmap = loader.<span style="color: #006600;">getBitmap</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;addChild<span style="color: #66cc66;">&#40;</span>mcBg<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos el sonido</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> sonido:<span style="color: #0066CC;">Sound</span> = loader.<span style="color: #006600;">getSound</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sound"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;sonido.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos el XML</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> xmlMenu:<span style="color: #0066CC;">XML</span> = loader.<span style="color: #006600;">getXML</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"menu"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>xmlMenu<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Luego uniendo todos los elementos, obtenemos nuestro precargador de múltiples archivos.</p><div class="syntax_hilite"><div id="actionscript-58"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">import</span> br.<span style="color: #006600;">com</span>.<span style="color: #006600;">stimuli</span>.<span style="color: #006600;">loading</span>.<span style="color: #006600;">BulkLoader</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">import</span> br.<span style="color: #006600;">com</span>.<span style="color: #006600;">stimuli</span>.<span style="color: #006600;">loading</span>.<span style="color: #006600;">BulkProgressEvent</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> loader:BulkLoader = <span style="color: #000000; font-weight: bold;">new</span> BulkLoader<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"mainLoader"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"background.jpg"</span>, <span style="color: #66cc66;">&#123;</span>id: <span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"menu.xml"</span>, <span style="color: #66cc66;">&#123;</span>id:<span style="color: #ff0000;">"menu"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #0066CC;">add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sound.mp3"</span>, <span style="color: #66cc66;">&#123;</span>id: <span style="color: #ff0000;">"sound"</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>BulkLoader.<span style="color: #006600;">COMPLETE</span>, onLoaded<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>BulkLoader.<span style="color: #006600;">PROGRESS</span>, onProgress<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onLoaded<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos la imagen </span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> mcBg:Bitmap = loader.<span style="color: #006600;">getBitmap</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"bg"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;addChild<span style="color: #66cc66;">&#40;</span>mcBg<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos el sonido</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> sonido:<span style="color: #0066CC;">Sound</span> = loader.<span style="color: #006600;">getSound</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"sound"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;sonido.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// extraemos el XML</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> xmlMenu:<span style="color: #0066CC;">XML</span> = loader.<span style="color: #006600;">getXML</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"menu"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>xmlMenu<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> onAllItemsProgress<span style="color: #66cc66;">&#40;</span>evt:BulkProgressEvent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>evt.<span style="color: #0066CC;">bytesLoaded</span> + <span style="color: #ff0000;">" - "</span> + evt.<span style="color: #0066CC;">bytesTotal</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Como pueden ver es muy sencillo el uso de esta clase y puede facilitar y ahorrar tiempo en la implementación de sitios con acceso a múltiples tipo de datos.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/precarga-multiple-en-as3/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Precargar archivos en AS3</title><link>http://blog.unijimpe.net/precargar-archivos-en-as3/</link> <comments>http://blog.unijimpe.net/precargar-archivos-en-as3/#comments</comments> <pubDate>Tue, 27 May 2008 05:19:51 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[General]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[precarga]]></category> <category><![CDATA[swf]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=845</guid> <description><![CDATA[<p><strong>ActionScript 3</strong> trae nuevos métodos, propiedades y eventos para implementar nuestras aplicaciones, en esta ocasión crearemos un precargador de archivos en AS3, para ello ahora estan disponibles nuevas clases: <strong>URLRequest</strong> y <strong>Loader</strong>.</p><p></p><p>La clase <strong>URLRequest</strong>&#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>ActionScript 3</strong> trae nuevos métodos, propiedades y eventos para implementar nuestras aplicaciones, en esta ocasión crearemos un precargador de archivos en AS3, para ello ahora estan disponibles nuevas clases: <strong>URLRequest</strong> y <strong>Loader</strong>.</p><p> <object width="400" height="134"><param name="movie" value="/wp-content/uploads/2008/05/preloadas3.swf"></param><param name="quality" value="high"></param><param name="wmode" value="transparent"></param><param name="menu" value="false"></param><param name="bgcolor" value="#FFFFFF"></param><param name="allowScriptAccess" value="always"></param><param name="allowFullScreen" value="true"></param> <embed type="application/x-shockwave-flash" width="400" height="134" src="/wp-content/uploads/2008/05/preloadas3.swf" quality="high" bgcolor="#FFFFFF" wmode="transparent" menu="false" allowFullScreen="true" ></embed> </object></p><p>La clase <strong>URLRequest</strong> nos permitirá asignar el archivo que deseamos cargar y la clase <strong>Loader</strong> nos permitirá hacer el seguimiento en el proceso de la carga.</p><div class="syntax_hilite"><div id="actionscript-64"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> mcRequ:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"image.jpg"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> mcLoad:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Luego de ello iniciamos la carga del archivo utilizando el método <strong>load</strong> de la clase <em>Loader</em>.</p><div class="syntax_hilite"><div id="actionscript-65"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">mcLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>mcRequ<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Luego el siguiente paso es agregar los detectores de eventos, en esta caso detectaremos el inicio de la carga, el progreso de la carga y el fin de la carga.</p><div class="syntax_hilite"><div id="actionscript-66"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">OPEN</span>, onOpen<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ProgressEvent.<span style="color: #006600;">PROGRESS</span>, onProgress<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onComplete<span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Nótese que hemos agregado las funciones onOpen, onProgress y onComplete que se ejecutarán al inicio, progreso y fin de la carga. Entonces lo que hace falta es implementar estas funciones.</p><div class="syntax_hilite"><div id="actionscript-67"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onOpen<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"CARGANDO 0%"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onProgress<span style="color: #66cc66;">&#40;</span>event:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bLoad = event.<span style="color: #0066CC;">bytesLoaded</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bTot = event.<span style="color: #0066CC;">bytesTotal</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"CARGANDO "</span>+<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">100</span>*bLoad/bTot<span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">"%"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>mcLoad<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;color:#800000;">400</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;color:#800000;">134</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>En este paso hay que notar como se obtienes los valores de los bytes cargados (<em>bytesLoaded</em>) y los bytes totales (<em>bytesTotal</em>) para hacer el calculo del porcentaje de carga. Además de ello <strong>txtload</strong> es un campo de texto y <strong>mcclip</strong> un MovieClip que están en el Stage en donde se cargará la imagen. Finalmente una vez cargado la imagen la agregamos al MovieClip <strong>mcclip </strong>y luego lo escalamos para que encaje en nuestra película.</p><p>Uniendo todos los elementos, tenemos nuestro precargador de archivos en <strong>ActionScript 3</strong>, el cual fácilmente se puede convertir en una clase para poder utilizarla para precargar cualquier archivo.</p><div class="syntax_hilite"><div id="actionscript-68"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> mcRequ:URLRequest = <span style="color: #000000; font-weight: bold;">new</span> URLRequest<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"image.jpg"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> mcLoad:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style="">mcLoad.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>mcRequ<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">OPEN</span>, onOpen<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ProgressEvent.<span style="color: #006600;">PROGRESS</span>, onProgress<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">mcLoad.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, onComplete<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onOpen<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"CARGANDO 0%"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onProgress<span style="color: #66cc66;">&#40;</span>event:ProgressEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bLoad = event.<span style="color: #0066CC;">bytesLoaded</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> bTot = event.<span style="color: #0066CC;">bytesTotal</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"CARGANDO "</span>+<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;color:#800000;">100</span>*bLoad/bTot<span style="color: #66cc66;">&#41;</span>+<span style="color: #ff0000;">"%"</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #000000; font-weight: bold;">function</span> onComplete<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; txtload.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>mcLoad<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;color:#800000;">400</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; mcclip.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;color:#800000;">134</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Como pueden ver, no es muy complicado solo hay que entender la logica de funcionamiento de AS3 y el correcto uso de los detectores de eventos. Para finalizar les dejo los archivos fuentes para que puedan descargar y hacer sus pruebas.</p><p style="text-align:center;"> <a href="http://www.box.net/shared/ambvs1a0wk"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/precargar-archivos-en-as3/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Como utilizar Flashvars</title><link>http://blog.unijimpe.net/como-utilizar-flashvars/</link> <comments>http://blog.unijimpe.net/como-utilizar-flashvars/#comments</comments> <pubDate>Mon, 28 Apr 2008 00:23:28 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[ActionScript]]></category> <category><![CDATA[General]]></category> <category><![CDATA[AS2]]></category> <category><![CDATA[AS3]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[flashvars]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[player]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[SWFObject]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=821</guid> <description><![CDATA[<p><strong>Flashvars</strong> es un propiedad de <em>Flash Player</em> que ofrece un método eficaz para enviar variables desde HTML al archivos SWF, esta función fue implementada a partir de Flash Player 6, en esta ocasión veremos como utilizarla &#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>Flashvars</strong> es un propiedad de <em>Flash Player</em> que ofrece un método eficaz para enviar variables desde HTML al archivos SWF, esta función fue implementada a partir de Flash Player 6, en esta ocasión veremos como utilizarla en AS2 o AS3.</p><p style="text-align:center;"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/04/flashplayer.gif" alt="" title="flashplayer" width="92" height="92" /></p><p><strong>Pasando variables FlashVars</strong><br /> Si estas usando el método tradicional de insertar SWFs, pueden asignarlos en un parámetro adicional al cual deben llamar <em>flashvars</em> y cuyo valor debe contener todas las variables a pasar codificadas en url.</p><div class="syntax_hilite"><div id="html-73"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/object.html"><span style="color: #000000;">&lt;object</span></a> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"200"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"100"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/param.html"><span style="color: #000000;">&lt;param</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"movie"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"movie.swf"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #009900;"><a href="http://december.com/html/4/element/param.html"><span style="color: #000000;">&lt;param</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"FlashVars"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"var1=valor1&amp;var2=valor2"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #009900;">&lt;embed <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"miSwf.swf"</span> <span style="color: #000066;">width</span>=<span style="color: #ff0000;">"100"</span> <span style="color: #000066;">height</span>=<span style="color: #ff0000;">"100</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #ff0000;">&nbsp; &nbsp; FlashVars="</span>var1=valor1&amp;var2=valor2<span style="color: #ff0000;">"/&gt;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;">&lt;/object&gt;</span> </span></div></li></ol></div></div></div><p></p><p>Si estas utilizando SWFObject, puedes pasar las variables separadas utilizando el método <em>addVariable</em>, entonces el ejemplo anterior se vería de la siguiente forma:</p><div class="syntax_hilite"><div id="html-74"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">var so = new SWFObject(&quot;movie.swf&quot;, &quot;my&quot;, &quot;200&quot;, &quot;100&quot;, &quot;8&quot;, &quot;&quot;);</div></li><li style="color:#3A6A8B;"><div style="">so.addVariable(&quot;var1&quot;, &quot;valor1&quot;);</div></li><li style="color:#26536A;"><div style="">so.addVariable(&quot;var2&quot;, &quot;valor2&quot;);</div></li><li style="color:#3A6A8B;"><div style="">so.write(&quot;divmovie&quot;);</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Accediendo a FlashVars desde AS2</strong><br /> Cuando uno utiliza Flashvars, estas pasan a ser variables del <strong>_root</strong> de nuestra película principal. Luego podemos acceder de manera sencilla a estas variables anteponiendo la palabra <em>_root</em>.</p><div class="syntax_hilite"><div id="actionscript-75"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">_root</span>.<span style="color: #006600;">var1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// imprime &quot;valor1&quot;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">_root</span>.<span style="color: #006600;">var2</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// imprime &quot;valor2&quot; </span></div></li></ol></div></div></div><p></p><p><strong>Accediendo a FlashVars desde AS3</strong><br /> En AS3 las variables externas están contenidas en la propiedad <em>LoaderInfo</em>, entonces lo primero es tomar esta propiedad de la cual extraemos las variables contenidas en el método <em>parameters</em>.</p><div class="syntax_hilite"><div id="actionscript-76"><div class="actionscript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #000000; font-weight: bold;">var</span> param:<span style="color: #0066CC;">Object</span> = LoaderInfo<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>.<span style="color: #006600;">root</span>.<span style="color: #006600;">loaderInfo</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parameters</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>param<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"var1"</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// imprime &quot;valor1&quot;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>param<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"var2"</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// imprime &quot;valor2&quot; </span></div></li></ol></div></div></div><p></p><p>Como pueden observar es sencillo de acceder a estas variables, esto es muy practico cuando deseamos comunicar datos entre HTML y Flash.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/como-utilizar-flashvars/feed/</wfw:commentRss> <slash:comments>24</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic

Served from: blog.unijimpe.net @ 2012-02-08 20:57:48 -->
