<?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>llops blog &#187; Tips</title>
	<atom:link href="http://llops.com/blog/category/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://llops.com/blog</link>
	<description>Blog de programación creativa mantenido por llops. Experimentos y artículos entorno a la plataforma flash y as3.</description>
	<lastBuildDate>Fri, 07 Oct 2011 22:22:23 +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>Exportando para Flash Player 11 desde Flash Professional</title>
		<link>http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/</link>
		<comments>http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 22:22:23 +0000</pubDate>
		<dc:creator>llops</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Flash Professional]]></category>
		<category><![CDATA[playerglobal.swc]]></category>
		<category><![CDATA[standalone]]></category>

		<guid isPermaLink="false">http://llops.com/blog/?p=735</guid>
		<description><![CDATA[Como ya sabréis todos, esta semana se ha lanzado la versión final de Flash Player 11. Para los que quieran utilizar ya la nueva versión, Adobe ha facilitado instrucciones para compilar mediante Flash Builder o el command-line del SDK de Flex. Aunque no comenten nada de Flash Professional, también es posible hacerlo desde cualquier Flash [...]]]></description>
			<content:encoded><![CDATA[<p>Como ya sabréis todos, esta semana se ha lanzado la versión final de <a href="http://www.adobe.com/products/flashplayer.html">Flash Player 11</a>. Para los que quieran utilizar ya la nueva versión, Adobe ha facilitado <a title="Authoring for Flash Player 11" href="http://kb2.adobe.com/cps/919/cpsid_91932.html#main_authoring_flash_player">instrucciones</a> para compilar mediante Flash Builder o el command-line del SDK de Flex. Aunque no comenten nada de Flash Professional, también es posible hacerlo desde cualquier Flash CSx. Vamos a ver el proceso.</p>
<p><span id="more-735"></span></p>
<h4>Archivos necesarios</h4>
<p><strong>Projector Content Debugger</strong> - La versión para poder depurar.</p>
<p><strong>Projector</strong> - La versión standalone del Player.</p>
<p><strong>PlayerGlobal.swc</strong> - Contiene las definiciones de las clases que se encuentran en el Player. Básicamente es una API para el compilador.</p>
<p>Todos ellos te los puedes bajar de <a href="http://www.adobe.com/support/flashplayer/downloads.html#fp11">http://www.adobe.com/support/flashplayer/downloads.html#fp11</a></p>
<p>Y si no lo tienes todavía instalado, el plugin del navegador: <a title="Get Flash Player" href="http://get.adobe.com/es/flashplayer/">http://get.adobe.com/es/flashplayer</a></p>
<h4><strong>Configuración</strong></h4>
<p>Una vez descargados, vamos a la carpeta donde tenemos instalado Flash y navegamos hasta <strong>\Common\Configuration</strong></p>
<ul>
<li>Dentro de la carpeta <strong>ActionScript 3.0</strong> creamos una nueva que se llame <strong>FP11</strong>, y copiamos el PlayerGlobal, renombrándolo como <strong>playerglobal.swc</strong></li>
</ul>
<p><img class="alignnone" title="Ruta del PlayerGlobal" src="http://llops.com/blog/content/articulos/oct11/playerglobal-swc.png" alt="" width="602" height="183" /></p>
<ul>
<li>Dentro de la carpeta <strong>Players</strong> duplicamos el archivo <strong>FlashPlayer10_1.xml</strong> y lo renombramos como <strong>FlashPlayer11.xml</strong>.</li>
</ul>
<p><img class="alignnone" title="Ruta del xml" src="http://llops.com/blog/content/articulos/oct11/fp11-xml.png" alt="" width="398" height="289" /></p>
<p>Luego lo editamos con la siguiente información (<a title="FlashPlayer11.xml" href="http://llops.com/blog/content/articulos/oct11/FlashPlayer11.xml" target="_blank">ver xml completo</a>):</p>
<p><img class="alignnone" title="Opciones del xml" src="http://llops.com/blog/content/articulos/oct11/opciones-xml.jpg" alt="" width="501" height="157" /></p>
<p>Volvemos a la carpeta raíz de Flash, nos metemos en el directorio <strong>Players</strong> y encontraremos dos carpetas: <strong>Debug</strong> y <strong>Release</strong>, donde copiaremos el <strong>Flash Player Debugger</strong> y el <strong>Flash Player</strong> respectivamente.</p>
<blockquote><p><strong>Nota:</strong> Mejor no sobreescribir los ficheros, renombrar para no perder las versiones anteriores.</p></blockquote>
<p><img class="centered" title="Flash Player Release" src="http://llops.com/blog/content/articulos/oct11/fp-release.jpg" alt="" width="661" height="310" /></p>
<h4>Probando Flash Player 11</h4>
<p>Para probar que todo funciona correctamente creamos una nueva película, añadimos 3 TextFields dinámicos en el escenario y escribimos el siguiente código:</p>
<div class="igBar"><span id="lactionscript3-3"><a href="#" onclick="javascript:showCodeTxt('actionscript3-3'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-3">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #000099;">system</span>.<span style="color: #000099;">Capabilities</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">display</span>.<span style="color: #555;">Stage3D</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">version_txt.<span style="color: #555;">text</span> = <span style="color: #000099;">Capabilities</span>.<span style="color: #555;">version</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">type_txt.<span style="color: #555;">text</span> = <span style="color: #000099;">Capabilities</span>.<span style="color: #555;">playerType</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">var</span> s3D:Stage3D = <span style="color: #1518ff;">new</span> Stage3D<span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">trace_txt.<span style="color: #555;">text</span> = s3D.<span style="color: #555;">toString</span><span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Vamos a las opciones de publicación y, gracias al xml que hemos añadido, deberíamos tener una nueva opción: <strong>Flash Player 11</strong>.</p>
<p><img class="alignnone" title="Opciones de publicación" src="http://llops.com/blog/content/articulos/oct11/opciones-publicacion.png" alt="" width="536" height="360" /></p>
<p>Y ahora probamos la película en el <strong>MODO DEBUG</strong> (cmd+shift+enter en Mac o ctrl+shift+enter en Windows). Si todo está configurado correctamente deberíamos ver la película con información similar a esta:</p>
<p><img class="alignnone" title="Test debugger" src="http://llops.com/blog/content/articulos/oct11/test-debugger.png" alt="" width="475" height="238" /></p>
<p>También funcionará si ejecutamos directamente el swf (utilizará el player standalone) o lo abrimos en el navegador. Pero si hacemos el clásico <strong>Test Movie</strong> dará un error en tiempo de ejecución</p>
<div class="igBar"><span id="lactionscript3-4"><a href="#" onclick="javascript:showCodeTxt('actionscript3-4'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-4">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">VerifyError</span>: <span style="color: #000099;">Error</span> #1014: No se encontró la clase flash.<span style="color: #555;">display</span>::Stage3D. </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>pero no en tiempo de compilación, confirmando que el compilador reconoce la clase <em>Stage3D</em> en el <em>playerglobal.swc</em>.</p>
<p>Si comentamos las lineas que hacen referencia a <em>Stage3D</em> y probamos nuevamente la película veremos que la versión del player será la <strong>10.x</strong> y el <em>playerType</em> <strong>external</strong>. Resulta que el IDE utiliza una especie de player integrado para probar las películas, de ahí que no se pueda utilizar esta opción para apuntar a un player superior. Realmente sería mucho más útil que utilizara el Player de <em>Release</em>, igual que lo hace con el de <em>Debug</em>.</p>
<p>A pesar de este pequeño inconveniente, ya podemos disfrutar desde nuestro querido Flash de las ventajas que nos trae Flash Player 11.</p>
<hr />
<p><small>
<a href="http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/#comments">3 comentarios</a>
<br/>
<a href="http://twitter.com/share?url=http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/&text=Leyendo%20%22Exportando para Flash Player 11 desde Flash Professional%22&via=llops%20blog">Compartir en Twitter</a> | 
<a href="http://www.facebook.com/sharer.php?u=http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/&t=Exportando para Flash Player 11 desde Flash Professional">Compartir en Facebook</a>

<br/><br/>
© <a href="http://llops.com/blog">llops blog</a> 2011 
</small></p>]]></content:encoded>
			<wfw:commentRss>http://llops.com/blog/2011/10/07/exportando-para-flash-player-11-desde-flash-professional/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ayuda offline en Flash CS4</title>
		<link>http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/</link>
		<comments>http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 10:52:38 +0000</pubDate>
		<dc:creator>llops</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[ayuda]]></category>
		<category><![CDATA[flash cs4]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[lenguage reference]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[online]]></category>

		<guid isPermaLink="false">http://llops.com/blog/?p=58</guid>
		<description><![CDATA[Una de las cosas más molestas de Flash CS4 es que la ayuda (F1) es online, se conecta con http://help.adobe.com y a partir de ahí buscar un simple método es una tarea lenta y tediosa. Afortunadamente, la ayuda también se encuentra en local y se puede poner por defecto. Para ello debemos ir a Window [...]]]></description>
			<content:encoded><![CDATA[<p>Una de las cosas más molestas de Flash CS4 es que la ayuda (F1) es online, se conecta con <a href="http://help.adobe.com/en_US/Flash/10.0_UsingFlash/" target="_blank">http://help.adobe.com</a> y a partir de ahí buscar un simple método es una tarea lenta y tediosa. Afortunadamente, la ayuda también se encuentra en local y se puede poner por defecto.</p>
<p><span id="more-58"></span></p>
<p>Para ello debemos ir a <em>Window &gt; Extensions </em>y abrir el panel <em>Connections</em>. Al clicar en las opciones (botón superior derecha) veremos que una es <em>Offline options</em>.</p>
<p><img title="Panel Connections" src="http://llops.com/blog/content/articulos/mar09/panel_connections.jpg" alt="Panel Connections" width="381" height="382" /></p>
<p>Marcamos después el check de <em>Keep me offline</em> y aceptamos. Ahora al pulsar F1 dispondremos de toda la referencia en modo local, y aunque sigue abriéndose a través de navegador, al menos nos ahorramos los tiempo de carga.</p>
<blockquote><p><strong>Nota</strong>: a tener en cuenta que al activar este modo perdemos todas las funcionalidades que necesitan conexión (por ejemplo, el panel de Kuler).</p></blockquote>
<p>También hay otras dos opciones interesantes en forma de aplicaciones AIR:</p>
<ul>
<li><a title="Doc?" href="http://airdoc.be" target="_blank">http://airdoc.be</a></li>
<li><a title="AS3 language reference app" href="http://labs.bigspaceship.com/2008/12/09/air-app-as3-language-reference/" target="_blank">http://labs.bigspaceship.com/2008/12/09/air-app-as3-language-reference</a></li>
</ul>
<p>En la primera, Doc?, te tienes que descargar y configurar las distintas referencias de lenguaje que necesites (AS3, Flash CS4, CS3, Flex...) y la aplicación te permite ver, buscar y guardar la documentación. Yo la tengo instalada y es bastante útil.</p>
<p>La de BigSpaceShip, de similar funcionamiento, tiene integrada la referencia del lenguaje de AS3, pero a mí no me convenció mucho...</p>
<p>De todas maneras, la ayuda tal y como estaba planteada en CS3 era perfecta... :(</p>
<hr />
<p><small>
<a href="http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/#comments">1 comentario</a>
<br/>
<a href="http://twitter.com/share?url=http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/&text=Leyendo%20%22Ayuda offline en Flash CS4%22&via=llops%20blog">Compartir en Twitter</a> | 
<a href="http://www.facebook.com/sharer.php?u=http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/&t=Ayuda offline en Flash CS4">Compartir en Facebook</a>

<br/><br/>
© <a href="http://llops.com/blog">llops blog</a> 2009 
</small></p>]]></content:encoded>
			<wfw:commentRss>http://llops.com/blog/2009/03/04/ayuda-offline-en-flash-cs4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recogiendo variables externas</title>
		<link>http://llops.com/blog/2008/09/19/recogiendo-variables-externas/</link>
		<comments>http://llops.com/blog/2008/09/19/recogiendo-variables-externas/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:49:00 +0000</pubDate>
		<dc:creator>llops</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[displayList]]></category>
		<category><![CDATA[loaderInfo]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://llops.com/blog/?p=37</guid>
		<description><![CDATA[A pesar de tener poco cero tiempo para dedicarle al blog, no quería dejar de escribir este pequeño tip sobre como se recogen variables externas en AS3. No es que sea nada muy complejo (la verdad es que incluso en la ayuda se comenta), pero me resultó curioso cuando el otro día un compañero me [...]]]></description>
			<content:encoded><![CDATA[<p>A pesar de tener <span style="text-decoration: line-through;">poco</span> cero tiempo para dedicarle al blog, no quería dejar de escribir este pequeño tip sobre como se recogen variables externas en AS3. No es que sea nada muy complejo (la verdad es que incluso en la ayuda se comenta), pero me resultó curioso cuando el otro día un compañero me preguntó si lo sabía y me di cuenta que en todo este tiempo tocando AS3 no había tenido necesidad de usarlo... Así que lo documento por si existe por ahí algún despistado como yo :)</p>
<p><span id="more-37"></span></p>
<p>Haciendo un poco de memoria, en versiones anteriores se podía acceder a las variables directamente en el  <em>_root </em>(<em>_root.miVariable</em>). Ahora es bastante menos intuitivo, aunque no carece de lógica.</p>
<p>En AS3 se utiliza la clase <em>Loader </em>cuando queremos cargar un swf o una imagen, y su propiedad <em>contentLoaderInfo </em>para acceder a la información del fichero y al proceso de carga (bytesLoaded, etc). Dicha propiedad es en realidad una instancia de la clase <em>LoaderInfo</em>. Así pues, al buscar cualquier información referente al swf, tiene sentido hacerlo en dicha clase, y las variables externas no son una excepción. Por esa razón existe una propiedad llamada <em>parameters</em>, de tipo <em>Object </em>para almacenar pares de nombre-valor.</p>
<p>Y la pregunta evidente es: si el primer swf no está cargado mediante Loader, ¿cómo acceder a esta información? La respuesta consiste en que cualquier objeto de la Display List cuenta con una propiedad <em>loaderInfo</em> que provee la información del SWF principal.</p>
<p>En este punto, si quisiéramos acceder a una variable llamada <em>textoA</em> sabemos que podemos hacerlo de la siguiente forma:</p>
<div class="igBar"><span id="lactionscript3-6"><a href="#" onclick="javascript:showCodeTxt('actionscript3-6'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-6">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">var</span> variableA:<span style="color: #000099;">String</span> = <span style="color: #000099;">this</span>.<span style="color: #000099;">loaderInfo</span>.<span style="color: #555;">parameters</span>.<span style="color: #555;">textoA</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>donde <em>this</em> puede ser tanto el <em>DocumentClass </em>como cualquier frame del timeline.</p>
<p>Y un par de consideraciones:</p>
<ul>
<li>Debemos asegurarnos que al acceder a <em>loaderInfo </em>en un objeto, además de ser del tipo <em>Display</em>, éste se encuentre en la <em>Display List</em>, ya que sino generará error.</li>
<li>Sino se conocen el número de variables a recibir, podemos usar un <em>for..in</em> sobre <em>parameters</em> para que nos muestre todos los valores, ya que es un Object.</li>
</ul>
<p>Dejo un ejemplo que utiliza <a title="swfobject" href="http://code.google.com/p/swfobject/" target="_blank">swfobject 2.1</a> para cargar un swf y pasarle 2 variables que se muestran en cajas de texto:<br />
<a title="Descargar ejemplo" href="http://llops.com/blog/content/articulos/sep08/ejemplo_variables.zip">Descargar ejemplo</a>.</p>
<hr />
<p><small>
<a href="http://llops.com/blog/2008/09/19/recogiendo-variables-externas/#comments">4 comentarios</a>
<br/>
<a href="http://twitter.com/share?url=http://llops.com/blog/2008/09/19/recogiendo-variables-externas/&text=Leyendo%20%22Recogiendo variables externas%22&via=llops%20blog">Compartir en Twitter</a> | 
<a href="http://www.facebook.com/sharer.php?u=http://llops.com/blog/2008/09/19/recogiendo-variables-externas/&t=Recogiendo variables externas">Compartir en Facebook</a>

<br/><br/>
© <a href="http://llops.com/blog">llops blog</a> 2008 
</small></p>]]></content:encoded>
			<wfw:commentRss>http://llops.com/blog/2008/09/19/recogiendo-variables-externas/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Habilitar botón derecho en AS3</title>
		<link>http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/</link>
		<comments>http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 15:52:20 +0000</pubDate>
		<dc:creator>llops</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[botón derecho]]></category>
		<category><![CDATA[menu contextual]]></category>

		<guid isPermaLink="false">http://llops.com/blog/?p=34</guid>
		<description><![CDATA[Es sabido que en Flash Player no se puede utilizar el botón derecho del mouse de forma "propietaria". Con dicho botón se activa el menú contextual, y aunque se puede modificar, como mínimo encontramos las opciones Configuración y Acerca de Adobe Flash Player 9... Pues navegando por Google Code me he encontrado un proyecto llamado [...]]]></description>
			<content:encoded><![CDATA[<p>Es sabido que en Flash Player no se puede utilizar el botón derecho del mouse de forma "propietaria". Con dicho botón se activa el menú contextual, y aunque se puede modificar, como mínimo encontramos las opciones <strong>Configuración</strong> y <strong>Acerca de Adobe Flash Player 9...</strong> </p>
<p>Pues navegando por <a href="http://code.google.com/">Google Code</a> me he encontrado un proyecto llamado <a href="http://code.google.com/p/custom-context-menu/">Custom-context-menu</a> que nos permite utilizar a nuestro antojo el botón derecho. Para ello combina javascript y flash de una manera muy ingeniosa. Básicamente el hack consiste en:</p>
<ul>
<li>Con javascript, capturar el click derecho en HTML antes que llegue al swf</li>
<li>Una vez capturado el evento, informar al swf mediante ExternalInterface</li>
<li>Crear una función en ActionScript que responda a la llamada de ExternalInterface</li>
</ul>
<p>Se puede ver un ejemplo <a href="http://www.uza.lt/rightclick/index.php">aquí</a>.</p>
<p>Aunque puede ser un recurso muy útil, hay que tener en cuenta los siguientes inconvenientes:</p>
<ul>
<li>Funciona en la mayoría de navegadores/so, pero no en todos</li>
<li>Antes de tener el evento en AS, recorre un ciclo de llamadas entre el swf y el html, con lo que el rendimiento es mucho peor que una llamada nativa</li>
<li>En el menú contextual se encuentran las opciones de configuración del Flash Player, y estaríamos quitándoselas al usuario</li>
</ul>
<p>Aún así, en casos específicos en los que sería muy importante tener este botón habilitado, es una gran solución y no está de más conocerla.</p>
<hr />
<p><small>
<a href="http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/#comments">2 comentarios</a>
<br/>
<a href="http://twitter.com/share?url=http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/&text=Leyendo%20%22Habilitar botón derecho en AS3%22&via=llops%20blog">Compartir en Twitter</a> | 
<a href="http://www.facebook.com/sharer.php?u=http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/&t=Habilitar botón derecho en AS3">Compartir en Facebook</a>

<br/><br/>
© <a href="http://llops.com/blog">llops blog</a> 2008 
</small></p>]]></content:encoded>
			<wfw:commentRss>http://llops.com/blog/2008/07/06/habilitar-boton-derecho-en-as3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Accediendo al stage antes de tiempo</title>
		<link>http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/</link>
		<comments>http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 15:07:59 +0000</pubDate>
		<dc:creator>llops</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[added]]></category>
		<category><![CDATA[addedToStage]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Error #1009]]></category>
		<category><![CDATA[stage]]></category>

		<guid isPermaLink="false">http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/</guid>
		<description><![CDATA[En AS3 es una práctica habitual asociar eventos al stage para cogerlos globalmente. El caso más utilizado probablemente se dé con los del tipo MouseEvent. Por ejemplo, si tenemos varios objetos en pantalla, en vez de definir un evento click para cada uno de ellos, cogemos sólo el click en el escenario (global) y vemos [...]]]></description>
			<content:encoded><![CDATA[<p>En AS3 es una práctica habitual asociar eventos al <em>stage</em> para cogerlos globalmente. El caso más utilizado probablemente se dé con los del tipo <em>MouseEvent</em>. Por ejemplo, si tenemos varios objetos en pantalla, en vez de definir un evento click para cada uno de ellos, cogemos sólo el click en el escenario (global) y vemos sobre quién se está interactuando:</p>
<div class="igBar"><span id="lactionscript3-11"><a href="#" onclick="javascript:showCodeTxt('actionscript3-11'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-11">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">stage</span>.<span style="color: #555;">addEventListener</span><span style="color: #555;">&#40;</span><span style="color: #000099;">MouseEvent</span>.<span style="color: #555;">CLICK</span>, click<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">private</span> <span style="color: #1518ff;">function</span> click<span style="color: #555;">&#40;</span>e:<span style="color: #000099;">MouseEvent</span><span style="color: #555;">&#41;</span>:<span style="color: #000099;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">trace<span style="color: #555;">&#40;</span><span style="color: #555;">"Click en"</span>, e.<span style="color: #555;">target</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Pero a veces, cuando intentamos añadir un evento al <em>stage</em> obtenemos el siguiente error:</p>
<blockquote><p>TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.</p></blockquote>
<p>Vamos a reproducir el error.</p>
<p><span id="more-25"></span></p>
<p>Tenemos dos clases: <em>Main</em>, asociada al <em>documentClass</em>, y <em>Circulo</em>, que se encarga de dibujar un pequeño circulo y capta un evento <em>click</em>.</p>
<h4>Clase Main</h4>
<div class="igBar"><span id="lactionscript3-12"><a href="#" onclick="javascript:showCodeTxt('actionscript3-12'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-12">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">package</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">display</span>.<span style="color: #000099;">Sprite</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> Circulo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">public</span> <span style="color: #1518ff;">class</span> Main <span style="color: #1518ff;">extends</span> <span style="color: #000099;">Sprite</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">function</span> Main<span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">var</span> c:Circulo = <span style="color: #1518ff;">new</span> Circulo<span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addChild<span style="color: #555;">&#40;</span>c<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h4>Clase Circulo</h4>
<div class="igBar"><span id="lactionscript3-13"><a href="#" onclick="javascript:showCodeTxt('actionscript3-13'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-13">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">package</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">display</span>.<span style="color: #000099;">Sprite</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">events</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">public</span> <span style="color: #1518ff;">class</span> Circulo <span style="color: #1518ff;">extends</span> <span style="color: #000099;">Sprite</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">function</span> Circulo<span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// Dibujar Circulo</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">beginFill</span><span style="color: #555;">&#40;</span>0xFF0000<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">drawCircle</span><span style="color: #555;">&#40;</span><span style="color: #FF0000;color:#000099;">50</span>, <span style="color: #FF0000;color:#000099;">50</span>, <span style="color: #FF0000;color:#000099;">10</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">endFill</span><span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// Definir el evento click</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">stage</span>.<span style="color: #555;">addEventListener</span><span style="color: #555;">&#40;</span><span style="color: #000099;">MouseEvent</span>.<span style="color: #555;">CLICK</span>, clic<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">private</span> <span style="color: #1518ff;">function</span> clic<span style="color: #555;">&#40;</span>e:<span style="color: #000099;">MouseEvent</span><span style="color: #555;">&#41;</span>:<span style="color: #000099;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">if</span> <span style="color: #555;">&#40;</span>e.<span style="color: #555;">target</span> == <span style="color: #000099;">this</span><span style="color: #555;">&#41;</span> trace<span style="color: #555;">&#40;</span><span style="color: #555;">"Click sobre circulo"</span><span style="color: #555;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">else</span> trace<span style="color: #555;">&#40;</span><span style="color: #555;">"No es circulo"</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Si compilamos obtenemos:</p>
<blockquote><p>TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.<br />
at Circulo()<br />
at Main()</p></blockquote>
<h4>¿Por qué obtenemos este error?</h4>
<p><em>Stage</em> es el contenedor base de todos los objetos visuales y se encuentra en lo más alto de la <em>displayList</em>.  Este contenedor no se puede acceder directamente, sino que se tiene que hacer mediante la propiedad stage, que se encuentra en cualquier objeto que extiende de <em>DisplayObject</em>.</p>
<p>Nuestro objeto Circulo extiende de <em>Sprite</em> y por tanto es un <em>DisplayObject</em> que soporta la propiedad <em>stage</em>, pero <strong>cuando intentamos acceder a dicha propiedad el objeto no se encuentra todavía en la displayList y por tanto la referencia es nula</strong>.</p>
<h4>Solución</h4>
<p>Para solucionar esto existen dos eventos muy útiles definidos en <em>DisplayObjet</em>: <em>added</em> y <em>addedToStage</em>. El primero se dispacha cuando un objeto se añade a la <em>displayList</em> y el segundo cuando se añade al escenario.</p>
<p>Así pues, podemos suscribirnos a estos eventos antes de acceder al <em>stage</em> y así garantizar que está disponible y que no genera error.</p>
<p>Finalmente nuestra clase Circulo quedaría:</p>
<div class="igBar"><span id="lactionscript3-14"><a href="#" onclick="javascript:showCodeTxt('actionscript3-14'); return false;">Plain Text</a></span></div>
<div class="syntax_hilite">
<div id="actionscript3-14">
<div class="actionscript3">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">package</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">display</span>.<span style="color: #000099;">Sprite</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">import</span> flash.<span style="color: #555;">events</span>.*;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">public</span> <span style="color: #1518ff;">class</span> Circulo <span style="color: #1518ff;">extends</span> <span style="color: #000099;">Sprite</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">function</span> Circulo<span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span> <span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// Dibujar Circulo</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">beginFill</span><span style="color: #555;">&#40;</span>0xFF0000<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">drawCircle</span><span style="color: #555;">&#40;</span><span style="color: #FF0000;color:#000099;">50</span>, <span style="color: #FF0000;color:#000099;">50</span>, <span style="color: #FF0000;color:#000099;">10</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">graphics</span>.<span style="color: #555;">endFill</span><span style="color: #555;">&#40;</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// Escuchar el evento ADDED</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #555;">addEventListener</span><span style="color: #555;">&#40;</span><span style="color: #000099;">Event</span>.<span style="color: #555;">ADDED</span>, init<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// o en este caso también ADDED_TO_STAGE</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">//this.addEventListener(Event.ADDED_TO_STAGE, init);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">private</span> <span style="color: #1518ff;">function</span> init<span style="color: #555;">&#40;</span>e:<span style="color: #000099;">Event</span><span style="color: #555;">&#41;</span>:<span style="color: #000099;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #F0F; font-style: italic;">// Definir el evento click</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000099;">this</span>.<span style="color: #000099;">stage</span>.<span style="color: #555;">addEventListener</span><span style="color: #555;">&#40;</span><span style="color: #000099;">MouseEvent</span>.<span style="color: #555;">CLICK</span>, clic<span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">private</span> <span style="color: #1518ff;">function</span> clic<span style="color: #555;">&#40;</span>e:<span style="color: #000099;">MouseEvent</span><span style="color: #555;">&#41;</span>:<span style="color: #000099;">void</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">if</span> <span style="color: #555;">&#40;</span>e.<span style="color: #555;">target</span> == <span style="color: #000099;">this</span><span style="color: #555;">&#41;</span> trace<span style="color: #555;">&#40;</span><span style="color: #555;">"Click sobre circulo"</span><span style="color: #555;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #1518ff;">else</span> trace<span style="color: #555;">&#40;</span><span style="color: #555;">"No es circulo"</span><span style="color: #555;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#666666;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #555;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="linea-extra"></div>
<p><a title="Descargar ejemplo" href="http://llops.com/blog/content/articulos/feb08/addedToStage.zip" target="_blank">&gt;&gt; Descargar ejemplo</a></p>
<hr />
<p><small>
<a href="http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/#comments">25 comentarios</a>
<br/>
<a href="http://twitter.com/share?url=http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/&text=Leyendo%20%22Accediendo al stage antes de tiempo%22&via=llops%20blog">Compartir en Twitter</a> | 
<a href="http://www.facebook.com/sharer.php?u=http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/&t=Accediendo al stage antes de tiempo">Compartir en Facebook</a>

<br/><br/>
© <a href="http://llops.com/blog">llops blog</a> 2008 
</small></p>]]></content:encoded>
			<wfw:commentRss>http://llops.com/blog/2008/02/18/accediendo-al-stage-antes-de-tiempo/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>

