<?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>CODIGO.actionscript &#187; Avanzado</title>
	<atom:link href="http://www.codigoactionscript.org/category/actionscript-avanzado/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codigoactionscript.org</link>
	<description>Blog de programación en ActionScript. Tips, tutoriales, ejemplos de Adobe Flash, Flex y AIR</description>
	<lastBuildDate>Thu, 02 Sep 2010 22:59:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cómo encriptar textos en Actionscript 3</title>
		<link>http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/</link>
		<comments>http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 15:41:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Seguridad]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/</guid>
		<description><![CDATA[<p>En muchas ocasiones tenemos información que debemos guardar y que no queremos que sea accesible directamente por el usuario. Por ejemplo, archivos de configuración de aplicaciones AIR o archivos de texto con variables. La solución es escriptar ese texto para que no sea entendible si el usuario accede a él directamente.</p>
<p>Para encriptar un texto en actionscript 3 lo primero que hacemos es descargarnos esta librería que nos permitirá utilizar varios algoritmos de encriptación.</p>

 http://ascrypt3.riaforge.org/

<p>Ahora nos crearemos una clase que utilice el cifrado en TEA. Este algoritmo requiere de un texto [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/' rel='bookmark' title='Permanent Link: Busquedas de palabras en textos con expresiones regulares'>Busquedas de palabras en textos con expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/onreleaseoutside-ondragout-ondragover-en-actionscript-3/' rel='bookmark' title='Permanent Link: onReleaseOutside, onDragOut, onDragOver en ActionScript 3'>onReleaseOutside, onDragOut, onDragOver en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/legibilidad-de-los-textos/' rel='bookmark' title='Permanent Link: Legibilidad de los textos'>Legibilidad de los textos</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>En muchas ocasiones tenemos información que debemos guardar y que no queremos que sea accesible directamente por el usuario. Por ejemplo, archivos de configuración de aplicaciones <a href="http://www.cristalab.com/tips/tags/air">AIR</a> o archivos de texto con variables. La solución es escriptar ese texto para que no sea entendible si el usuario accede a él directamente.</p>
<p>Para encriptar un texto en <a href="http://www.cristalab.com/tips/tags/actionscript">actionscript 3</a> lo primero que hacemos es descargarnos esta librería que nos permitirá utilizar varios algoritmos de encriptación.</p>
<ul>
<li> <a href="http://ascrypt3.riaforge.org">http://ascrypt3.riaforge.org/</a></li>
</ul>
<p>Ahora nos crearemos una clase que utilice el cifrado en TEA. Este algoritmo requiere de un texto clave que tendrá que ser el mismo a la hora de encriptar y a la hora de desencriptar.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-7">
<div class="actionscript">package com.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">security</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">meychi</span>.<span style="color: #006600;">ascrypt3</span>.<span style="color: #006600;">TEA</span>;<br />
<span style="color: #808080; font-style: italic;">//-------------------------------------------------------------</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EncryptUtils<br />
<span style="color: #66cc66;">&#123;</span><br />
internal <span style="color: #0066CC;">static</span> const ENCRYPTION_KEY:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"mi_contraseña_de_encriptado"</span>;<br />
<span style="color: #808080; font-style: italic;">//-------------------------------------------------------------</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> encryptString<span style="color: #66cc66;">&#40;</span>s:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> tea:TEA = <span style="color: #000000; font-weight: bold;">new</span> TEA<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> encryptedString:<span style="color: #0066CC;">String</span> = tea.<span style="color: #006600;">encrypt</span><span style="color: #66cc66;">&#40;</span>s, ENCRYPTION_KEY<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #b1b100;">return</span> encryptedString;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> decryptString<span style="color: #66cc66;">&#40;</span>s:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> tea:TEA = <span style="color: #000000; font-weight: bold;">new</span> TEA<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> decryptedString:<span style="color: #0066CC;">String</span> = tea.<span style="color: #006600;">decrypt</span><span style="color: #66cc66;">&#40;</span>s, ENCRYPTION_KEY<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #b1b100;">return</span> decryptedString;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>La utilización de esta clase para encriptar texto sería:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-8">
<div class="actionscript"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">utils</span>.<span style="color: #006600;">security</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"Lo que sea"</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> texto_encriptado:<span style="color: #0066CC;">String</span> = EncryptUtils.<span style="color: #006600;">encryptString</span><span style="color: #66cc66;">&#40;</span>texto<span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Y para desencriptar:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-9">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> texto:<span style="color: #0066CC;">String</span> = EncryptUtils.<span style="color: #006600;">decryptString</span><span style="color: #66cc66;">&#40;</span>texto_encriptado<span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>En esta clase de ejemplo la palabra clave para codificar esta añadida dentro de la misma clase, pero podríamos haber creado la clase haciendo que ese String le viniese como parámetro y así utilizar diferentes keys para diferentes proyectos. Lo que ha de estar claro es que para desencriptar un texto deberemos utilizar el mismo key que utilizamos para encriptarlo.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F&amp;t=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F&amp;title=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=En%20muchas%20ocasiones%20tenemos%20informaci%C3%B3n%20que%20debemos%20guardar%20y%20que%20no%20queremos%20que%20sea%20accesible%20directamente%20por%20el%20usuario.%20Por%20ejemplo%2C%20archivos%20de%20configuraci%C3%B3n%20de%20aplicaciones%20%20o%20archivos%20de%20texto%20con%20variables.%20La%20soluci%C3%B3n%20es%20escriptar%20ese%20te" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F&amp;title=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203&amp;annotation=En%20muchas%20ocasiones%20tenemos%20informaci%C3%B3n%20que%20debemos%20guardar%20y%20que%20no%20queremos%20que%20sea%20accesible%20directamente%20por%20el%20usuario.%20Por%20ejemplo%2C%20archivos%20de%20configuraci%C3%B3n%20de%20aplicaciones%20%20o%20archivos%20de%20texto%20con%20variables.%20La%20soluci%C3%B3n%20es%20escriptar%20ese%20te" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F&amp;title=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203&amp;notes=En%20muchas%20ocasiones%20tenemos%20informaci%C3%B3n%20que%20debemos%20guardar%20y%20que%20no%20queremos%20que%20sea%20accesible%20directamente%20por%20el%20usuario.%20Por%20ejemplo%2C%20archivos%20de%20configuraci%C3%B3n%20de%20aplicaciones%20%20o%20archivos%20de%20texto%20con%20variables.%20La%20soluci%C3%B3n%20es%20escriptar%20ese%20te" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=C%C3%B3mo%20encriptar%20textos%20en%20Actionscript%203&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-encriptar-textos-en-actionscript-3%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/' rel='bookmark' title='Permanent Link: Busquedas de palabras en textos con expresiones regulares'>Busquedas de palabras en textos con expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/onreleaseoutside-ondragout-ondragover-en-actionscript-3/' rel='bookmark' title='Permanent Link: onReleaseOutside, onDragOut, onDragOver en ActionScript 3'>onReleaseOutside, onDragOut, onDragOver en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/legibilidad-de-los-textos/' rel='bookmark' title='Permanent Link: Legibilidad de los textos'>Legibilidad de los textos</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programación orientada a objetos: Herencia de clases.</title>
		<link>http://www.codigoactionscript.org/programacion-orientada-a-objetos-herencia-de-clases/</link>
		<comments>http://www.codigoactionscript.org/programacion-orientada-a-objetos-herencia-de-clases/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 00:49:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[POO]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[patrones]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=325</guid>
		<description><![CDATA[<p>La herencia de clases es uno de los conceptos básicos de la programación orientada a objetos. Decir que una clase hereda de otra quiere decir que esa clase obtiene los mismos métodos y propiedades de la otra clase. Permitiendo de esta forma añadir a las características heredadas las suyas propias.</p>
<p>Supongamos que tenemos una clase "Persona" con los métodos y propiedades básicas de una objeto persona como podrian ser "caminar" o "hablar", podríamos tener otras clases como "Guillermo" o "Elder" que comparten todas las características de una "Persona" pero que añaden [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Permanent Link: Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
<li><a href='http://www.codigoactionscript.org/poo-dependencia-de-clases-y-polimorfismo/' rel='bookmark' title='Permanent Link: POO: Dependencia de clases y Polimorfismo'>POO: Dependencia de clases y Polimorfismo</a></li>
<li><a href='http://www.codigoactionscript.org/articulo-sobre-la-programacion-orientada-a-objetos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Articulo sobre la programación orientada a objetos en Actionscript 3'>Articulo sobre la programación orientada a objetos en Actionscript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>La <strong>herencia de clases</strong> es uno de los conceptos básicos de la <strong>programación orientada a objetos</strong>. Decir que una clase hereda de otra quiere decir que esa clase obtiene los mismos métodos y propiedades de la otra clase. Permitiendo de esta forma añadir a las características heredadas las suyas propias.</p>
<p>Supongamos que tenemos una clase "Persona" con los métodos y propiedades básicas de una objeto persona como podrian ser "caminar" o "hablar", podríamos tener otras clases como "Guillermo" o "Elder" que comparten todas las características de una "Persona" pero que añaden características propias. Por lo que "Guillermo" y "Elder" pueden realizar las </p>
<p>mismas funciones que puede realizar una "Persona" y además cada una puede realizar las suyas propias, por ejemplo, "Guillermo" sabe nadar pero "Elder" no, y "Elder" sabe bailar reggeton pero "Guillermo" no.</p>
<p>En terminos de programación estaríamos diciendo que "Guillermo" y "Elder" son dos clases especializadas que heredan o extienden de la superclase "Persona".</p>
<h2>Tipos de herencia de clases</h2>
<p>Existen <strong>dos tipos</strong> de herencia:</p>
<ul>
<li>Herencia por <strong>especialización</strong></li>
<li>Herencia por <strong>generalización</strong></li>
</ul>
<p>En realidad <strong>la herencia es la misma</strong>, esta es una diferenciación puramente conceptual sobre la forma en que se a llegado a ella. </p>
<p>Una <strong>herencia por especialización</strong> es la que se realiza cuando necesitamos crear una clase nueva que disponga de las mismas características que otra pero que le añada funcionalidades. Por ejemplo si tenemos una clase que genera un botón simple, y necesitamos crear un botón que sea igual que el anterior pero que además añada un efecto al ser clicado.</p>
<p>La <strong>herencia por generalización</strong> es la que realizamos cuando tenemos muchas clases que comparten unas mismas funcionalidades y por homogeneizar las partes comunes se decide crear una clase que implemente toda esa parte común y se dejan solo las partes especificas en cada clase. Por ejemplo si tenemos clases para dibujar formas geométricas todas ellas </p>
<p>disponen de las mismas propiedades (un color de fondo, color de linea, etc..), todas estas características pueden estar en una clase general de la que hereden todas las clases concretas, evitando tener que escribir todo ese código común en todas ellas.</p>
<h1>Herencia de clases en Actionscript</h1>
<p>En Actionscript definimos que una clase hereda de otra con la sentencia "<strong>extends</strong>".</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-32">
<div class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Guillermo <span style="color: #0066CC;">extends</span> Persona</div>
</div>
</div>
</div>
<p></p>
<h2>Public, private o protected</h2>
<p>Una consideración a tener en cuenta de la herencia es que una clase <strong>no hereda</strong> la propiedades o métodos <strong>privados</strong>, con lo que no tendrán acceso a ellas. Si necesitamos heredar propiedades o métodos que no queremos que sean accesibles desde fuera de las clases las definiremos como <strong>protected</strong>.</p>
<h2>Sobreescritura de métodos</h2>
<p>Una característica muy importante que permite la herencia es que podemos hacer que una clase implemente <strong>de manera diferente</strong> un método heredado. Haciendo que dos clases que heredan de la misma clase y heredan los mismos métodos se comporten de maneras diferentes.</p>
<p>Por ejemplo, unas clases de dibujo de figuras geométricas pueden heredar de una clase general la función "dibujar". Todas las clases dispondrán de esa función, pero cada clase la implementará de diferente manera y por lo tanto dibujará una figura diferente.</p>
<p>Para sobrescribir un método de la superclase utilizaremos la sentencia <strong>override</strong> en la definición del método.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-33">
<div class="actionscript"><span style="color: #808080; font-style: italic;">//función de la superclase</span><br />
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> traza<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"superclase"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-34">
<div class="actionscript"><span style="color: #808080; font-style: italic;">//función de la subclase</span><br />
override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> traza<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"subclase"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>De esta manera al ejecutar la función "traza()" desde una subclase obtendremos el texto "subclase" sobrescribiendo las acciones del método de la subclase (no obtendríamos el texto "superclase").</p>
<p>En el caso de no querer sobrescribir por completo toda la implementación del método de la superclase, si no que lo que queremos es ampliarlo, podemos acceder a la implementación de la superclase con el operador "super". </p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-35">
<div class="actionscript"><span style="color: #808080; font-style: italic;">//función de la subclase</span><br />
override <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> traza<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">super</span>.<span style="color: #006600;">traza</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"subclase"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>En este caso, se ejecutaría la implementación del método en la superclase (obtendriamos el texto "superclase") y luego el de la subclase (obtendríamos también el texto "subclase").</p>
<p>Esto también lo podemos realizar en el constructor de la clase. Es bastante probable que una clase esté definiendo valores dentro de su constructor, de manera que al ser extendida nos interese que esas definiciones se continúen realizando. En este caso deberemos realizar una llamada al constructor de la superclase a través del operador "super".</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-36">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> A<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">variable</span>:uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> A<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">variable</span> = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-37">
<div class="actionscript">package <br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> A;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> B <span style="color: #0066CC;">extends</span> A<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> B<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//ejecuta el contructor de la clase A, enviandole el parámetro</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>En el caso de que queramos asegurarnos de que una propiedad o método no pueda ser sobrescrita por otra clase la definiremos como <strong>final</strong>.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-38">
<div class="actionscript"><span style="color: #808080; font-style: italic;">//función de la subclase que no permitirá ser sobreescrita</span><br />
<span style="color: #0066CC;">public</span> final <span style="color: #000000; font-weight: bold;">function</span> traza<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"subclase"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<h1>Ejemplo del uso de herencia de clases:</h1>
<p>Veamos un sencillo ejemplo práctico: <strong>Crearemos un par de clases muy simples para dibujar un cuadrado o un círculo</strong>.</p>
<p>Lógicamente el primer paso es pensar que <strong>características compartirán</strong> tanto los cuadrados y los círculos.</p>
<ul>
<li>Ambos son elementos gráficos que tienen propiedades que definen su tamaño (size), si disponen de relleno o solo de línea (fill), el color de relleno (bgColor), el grosor de linea (borderSize) y el color de la linea (borderColor).</li>
<li>Tambien ambás dispondrán de una función que permitirá actualizar el gráfico en caso de modificar sus propiedades.</li>
<li>Por último amb´s dispondran de la método que dibujará el gráfico. Lógicamente esta será la función que cada clase implementará de forma diferente.</li>
</ul>
<p>Así que lo que haremos es crear una superclase "Grafico" que disponga de todas las propiedades mencionadas anteriormente, y dejaremos la implementación del método "dibuja()" a las subclases "Cuadrado" y "Circulo".</p>
<p>Empecemos escribiendo la interface de métodos públicos que deberán disponer todos los objetos que extiendan de "Grafico". En este caso serán todos los <em>setters </em>y <em>getters </em>para las propiedades, y el método para actualizar el gráfico.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-39">
<div class="actionscript">package org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IGrafico<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">size</span><span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> fill<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> fill<span style="color: #66cc66;">&#40;</span>n:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> bgColor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> bgColor<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> borderSize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> borderSize<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Escribiremos la superclase "Grafico" que implementará la interface "IGrafico" y definirá todos los setters y getters de las propiedades.</p>
<p>Las propiedades las definiremos como "portected" para que sean privadas pero heredables.</p>
<p>El constructor de la clase recibirá todos los parámetros necesarios para definir las propiedades (les asignaremos valores por defecto por si se crea una instancia sin pasarle parámetros). Y realizará una llamada a la función "dibuja()" que es la que creará el gráfico.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-40">
<div class="actionscript">package org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">IGrafico</span>;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Grafico <span style="color: #0066CC;">extends</span> Sprite <span style="color: #0066CC;">implements</span> IGrafico<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> _size:uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> _fill:<span style="color: #0066CC;">Boolean</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> _bgColor:uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> _borderSize:uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">var</span> _borderColor:uint;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Grafico<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">size</span>:uint = <span style="color: #cc66cc;">10</span>, fill:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>, bgColor:uint = 0x000000, borderSize:uint = <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>:uint = 0x000000<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _size = <span style="color: #0066CC;">size</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _fill = fill;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _bgColor = bgColor;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _borderSize = borderSize;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _borderColor = <span style="color: #0066CC;">borderColor</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dibuja<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _size;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">size</span><span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _size = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> fill<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _fill;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> fill<span style="color: #66cc66;">&#40;</span>n:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _fill = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> bgColor<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _size;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> bgColor<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _bgColor = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> borderSize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _borderSize;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> borderSize<span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _borderSize = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:uint<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _borderColor;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#40;</span>n:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _borderColor = n;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dibuja<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; protected <span style="color: #000000; font-weight: bold;">function</span> dibuja<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">Throw</span>.<span style="color: #006600;">newError</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"clase abstracta"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Como hemos dicho, la clase "Grafico" no implementa el método "dibuja()" ya que eso depende de cada subclase, con lo que si intentamos crear una instancia de "Grafico" nos lanzará un error. Lo único que hacemos es definir que todas las subclases hereden el método y cada una lo implenete a su manera.</p>
<p>Escribamos ahora la clase "Cuadrado".</p>
<p>Esta clase extendrá de la clase "Grafico" e implementará la interface "IGrafico". Por lo tanto heredará todas las propiedades y métodos de la superclase marcados como public o protected, con lo que no necesitaremos definir las protiedades ni los setter y getters, pero dispondrá de ellos.</p>
<p>El constructor de esta clase recibirá como parámetros los valores del objeto a crear, y deberemos pasarselos al constructor de la superclase para que asigne los valores y ejecute la función de dibujar. Como hemos mencionado esto lo haremos utilizando la sentencia super();</p>
<p>Ahora solo nos quedará sobreescribir el método "dibuja()" para que se dibuje lo que nos interese en función de la clase actual, en este caso queremo sdibujar un cuadrado. Utilizaremos un override para sobrescribir el método.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-41">
<div class="actionscript">package org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">IGrafico</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">Grafico</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Cuadrado <span style="color: #0066CC;">extends</span> Grafico <span style="color: #0066CC;">implements</span> IGrafico<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Cuadrado<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">size</span>:uint = <span style="color: #cc66cc;">10</span>, fill:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>, bgColor:uint = 0x000000, borderSize:uint = <span style="color: #cc66cc;">0</span>, <span style="color: #0066CC;">borderColor</span>:uint = 0x000000<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">size</span>, fill, bgColor, borderSize, <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> dibuja<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_fill == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>_bgColor<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_borderSize != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span>_borderSize, _borderColor<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, _size, _size<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_fill == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Haremos lo mismo para la clase "Circulo". Únicamente deberemos implementar de diferente manera el método "dibuja".</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-42">
<div class="actionscript">package org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">IGrafico</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> org.<span style="color: #006600;">cristalab</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">Grafico</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Shape</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Circulo <span style="color: #0066CC;">extends</span> Grafico <span style="color: #0066CC;">implements</span> IGrafico<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Circulo<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">size</span>:uint = <span style="color: #cc66cc;">10</span>, fill:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>, bgColor:uint = 0x000000, borderSize:uint = <span style="color: #cc66cc;">0</span>, bordeColor:uint = 0x000000<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">size</span>, fill, bgColor, borderSize, <span style="color: #0066CC;">borderColor</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; override protected <span style="color: #000000; font-weight: bold;">function</span> dibuja<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_fill == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>_bgColor<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_borderSize != <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineStyle</span><span style="color: #66cc66;">&#40;</span>_borderSize, _borderColor<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> radio:uint = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">round</span><span style="color: #66cc66;">&#40;</span>_size / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawCircle</span><span style="color: #66cc66;">&#40;</span>radio, radio, radio<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_fill == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//------------------------------------------------------------------------</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>A partir de aquí iremos creando tantas clases como gráficos diferentes nos interese dibujar, incluso podemos extender estas subclases en otras subclases, por ejemplo para crear objetos más complejos pero que su base sea un cuadrado o un circulo.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases.%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F&amp;t=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases." title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F&amp;title=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases.&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=La%20herencia%20de%20clases%20es%20uno%20de%20los%20conceptos%20b%C3%A1sicos%20de%20la%20programaci%C3%B3n%20orientada%20a%20objetos.%20Decir%20que%20una%20clase%20hereda%20de%20otra%20quiere%20decir%20que%20esa%20clase%20obtiene%20los%20mismos%20m%C3%A9todos%20y%20propiedades%20de%20la%20otra%20clase.%20Permitiendo%20de%20esta%20forma%20a%C3%B1adi" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F&amp;title=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases.&amp;annotation=La%20herencia%20de%20clases%20es%20uno%20de%20los%20conceptos%20b%C3%A1sicos%20de%20la%20programaci%C3%B3n%20orientada%20a%20objetos.%20Decir%20que%20una%20clase%20hereda%20de%20otra%20quiere%20decir%20que%20esa%20clase%20obtiene%20los%20mismos%20m%C3%A9todos%20y%20propiedades%20de%20la%20otra%20clase.%20Permitiendo%20de%20esta%20forma%20a%C3%B1adi" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F&amp;title=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases.&amp;notes=La%20herencia%20de%20clases%20es%20uno%20de%20los%20conceptos%20b%C3%A1sicos%20de%20la%20programaci%C3%B3n%20orientada%20a%20objetos.%20Decir%20que%20una%20clase%20hereda%20de%20otra%20quiere%20decir%20que%20esa%20clase%20obtiene%20los%20mismos%20m%C3%A9todos%20y%20propiedades%20de%20la%20otra%20clase.%20Permitiendo%20de%20esta%20forma%20a%C3%B1adi" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Programaci%C3%B3n%20orientada%20a%20objetos%3A%20Herencia%20de%20clases.&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fprogramacion-orientada-a-objetos-herencia-de-clases%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Permanent Link: Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
<li><a href='http://www.codigoactionscript.org/poo-dependencia-de-clases-y-polimorfismo/' rel='bookmark' title='Permanent Link: POO: Dependencia de clases y Polimorfismo'>POO: Dependencia de clases y Polimorfismo</a></li>
<li><a href='http://www.codigoactionscript.org/articulo-sobre-la-programacion-orientada-a-objetos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Articulo sobre la programación orientada a objetos en Actionscript 3'>Articulo sobre la programación orientada a objetos en Actionscript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/programacion-orientada-a-objetos-herencia-de-clases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Busquedas de palabras en textos con expresiones regulares</title>
		<link>http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/</link>
		<comments>http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 02:53:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=318</guid>
		<description><![CDATA[<p>Este es un ejemplo de como realizar búsquedas de palabras dentro de cajas de texto haciendo uso de Expresiones Regulares de Actionscript 3.</p>
<p>Lo primero que haremos es crear un patrón con los caracteres de texto que queremos seleccionar. En este caso le indicaremos la palabra desde un TextInput</p>



var patron:RegExp = new RegExp&#40;input.text&#41;;



<p></p>
<p>Este patrón nos encontrará la primera cadena de texto que coincida con los caracteres introducidos en el campo de texto. Si al patrón le añadimos el indicador g (global) hará que nos encuentre no solo la primera coincidencia sino [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/editar-cadenas-de-texto-utilizando-expresiones-regulares/' rel='bookmark' title='Permanent Link: Editar cadenas de texto utilizando expresiones regulares'>Editar cadenas de texto utilizando expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cómo encriptar textos en Actionscript 3'>Cómo encriptar textos en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/51/' rel='bookmark' title='Permanent Link: Texto con enlaces en Flash al estilo HTML'>Texto con enlaces en Flash al estilo HTML</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Este es un ejemplo de como realizar búsquedas de palabras dentro de cajas de texto haciendo uso de <strong>Expresiones Regulares</strong> de Actionscript 3.</p>
<p>Lo primero que haremos es crear un patrón con los caracteres de texto que queremos seleccionar. En este caso le indicaremos la palabra desde un TextInput</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-57">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>input.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Este patrón nos encontrará la primera cadena de texto que coincida con los caracteres introducidos en el campo de texto. Si al patrón le añadimos el indicador <strong>g</strong> (<em>global</em>) hará que nos encuentre no solo la primera coincidencia sino todas las que haya en el texto. También le añadiremos el indicador <strong>i </strong>(<em>ignoreCase</em>) para que no haga distinción entre mayúsculas y minúsculas.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-58">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>input.<span style="color: #0066CC;">text</span>,<span style="color: #ff0000;">"gi"</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Ahora tendremos que solucionar el detalle de que nos encuentre palabras y no caracteres dentro de otras palabras. Es decir, si buscamos la palabra "<strong>mi</strong>" no queremos que nos la seleccione dentro de "ca<strong>mi</strong>no". Para ello utilizaremos grupos de búsqueda. Indicaremos que solo nos interesa cuando despues de la coincidencia haya un espacio, un punto o una coma.  Y por el otro lado indicaremos que haya un espacio o que sea inicio de párrafo.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-59">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"(^| )"</span> + input.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"[<span style="color: #000099; font-weight: bold;">\ </span>.,]"</span>,<span style="color: #ff0000;">"gi"</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Utilizando este patrón dentro del método <strong>match()</strong> de la clase String podremos recuperar todas la concordancias que haya en el texto.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-60">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"(^| )"</span> + input.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"[<span style="color: #000099; font-weight: bold;">\ </span>.,]"</span>,<span style="color: #ff0000;">"gi"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #000000; font-weight: bold;">var</span> busqueda:<span style="color: #0066CC;">Array</span> = texto.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">match</span><span style="color: #66cc66;">&#40;</span>patron<span style="color: #66cc66;">&#41;</span>;<br />
output.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"Total: "</span> + busqueda.<span style="color: #0066CC;">length</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Ahora haremos que las palabras encontradas queden resaltadas en negrita, color rojo y subrayado. Para ello empezaremos escribiendo un estilo CSS, y asignándolo al campo de texto.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-61">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> estilo:StyleSheet = <span style="color: #000000; font-weight: bold;">new</span> StyleSheet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
estilo.<span style="color: #0066CC;">parseCSS</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">".select{fontWeight:bold; color: #FF0000; text-decoration: underline;}"</span><span style="color: #66cc66;">&#41;</span>;<br />
texto.<span style="color: #006600;">styleSheet</span> = estilo;</div>
</div>
</div>
</div>
<p></p>
<p>Con el método <strong>replace()</strong> de la clase String sustituiremos el contenido del patrón por un String que nos añadirá el tag que asignará el estilo CSS a la palabra. Como en el patrón hemos indicado que nos seleccione la palabra junto a los espacios en blanco o los puntos y comas, deberemos utilizar otro patrón que solo seleccione los caracteres de texto introducidos en el TextInput. Este segundo patrón lo colocaremos dentro de una función recursiva.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-62">
<div class="actionscript">texto.<span style="color: #0066CC;">htmlText</span> = texto.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>patron,setSpan<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #000000; font-weight: bold;">function</span> setSpan<span style="color: #66cc66;">&#40;</span>txt:<span style="color: #0066CC;">String</span>, ...<span style="color: #006600;">rest</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>input.<span style="color: #0066CC;">text</span>,<span style="color: #ff0000;">"i"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tag:<span style="color: #0066CC;">String</span> = txt.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>patron,<span style="color: #ff0000;">"&lt;span class='select'&gt;$&amp;&lt;/span&gt;"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> tag;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Ý listo, ya tenemos el ejemplo montado (coloquen una palabra en el TextInput y denle al botón):</p>
<div align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="460" height="170"><param name="movie" value="http://www.cristalab.com/images/tips/actionscript_3/wordSearch/wordSearch.swf" /><param name="quality" value="high" /><embed src="http://www.cristalab.com/images/tips/actionscript_3/wordSearch/wordSearch.swf" width="460" height="170" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></div>
<p>Este es el código completo:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-63">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> estilo:StyleSheet = <span style="color: #000000; font-weight: bold;">new</span> StyleSheet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
estilo.<span style="color: #0066CC;">parseCSS</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">".select{fontWeight:bold; color: #FF0000; text-decoration: underline;}"</span><span style="color: #66cc66;">&#41;</span>;<br />
texto.<span style="color: #006600;">styleSheet</span> = estilo;</p>
<p>boton.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, buscaPalabra<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #000000; font-weight: bold;">function</span> buscaPalabra<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:MouseEvent=<span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"(^| )"</span> + input.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"[<span style="color: #000099; font-weight: bold;">\ </span>.,]"</span>,<span style="color: #ff0000;">"gi"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> busqueda:<span style="color: #0066CC;">Array</span> = texto.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">match</span><span style="color: #66cc66;">&#40;</span>patron<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; output.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"Total: "</span> + busqueda.<span style="color: #0066CC;">length</span>;<br />
&nbsp; &nbsp; texto.<span style="color: #0066CC;">htmlText</span> = texto.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>patron,setSpan<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">function</span> setSpan<span style="color: #66cc66;">&#40;</span>txt:<span style="color: #0066CC;">String</span>, ...<span style="color: #006600;">rest</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> patron:RegExp = <span style="color: #000000; font-weight: bold;">new</span> RegExp<span style="color: #66cc66;">&#40;</span>input.<span style="color: #0066CC;">text</span>,<span style="color: #ff0000;">"i"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> tag:<span style="color: #0066CC;">String</span> = txt.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>patron,<span style="color: #ff0000;">"&lt;span class='select'&gt;$&amp;&lt;/span&gt;"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> tag;<br />
<span style="color: #66cc66;">&#125;</span></p>
<p>buscaPalabra<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Y aquí el <a href="http://www.cristalab.com/images/tips/actionscript_3/wordSearch/wordSearch.fla">archivo .FLA</a> para descargar. (archivo CS4)</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F&amp;t=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F&amp;title=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=Este%20es%20un%20ejemplo%20de%20como%20realizar%20b%C3%BAsquedas%20de%20palabras%20dentro%20de%20cajas%20de%20texto%20haciendo%20uso%20de%20Expresiones%20Regulares%20de%20Actionscript%203.%0D%0A%0D%0ALo%20primero%20que%20haremos%20es%20crear%20un%20patr%C3%B3n%20con%20los%20caracteres%20de%20texto%20que%20queremos%20seleccionar.%20En%20este%20c" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F&amp;title=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares&amp;annotation=Este%20es%20un%20ejemplo%20de%20como%20realizar%20b%C3%BAsquedas%20de%20palabras%20dentro%20de%20cajas%20de%20texto%20haciendo%20uso%20de%20Expresiones%20Regulares%20de%20Actionscript%203.%0D%0A%0D%0ALo%20primero%20que%20haremos%20es%20crear%20un%20patr%C3%B3n%20con%20los%20caracteres%20de%20texto%20que%20queremos%20seleccionar.%20En%20este%20c" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F&amp;title=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares&amp;notes=Este%20es%20un%20ejemplo%20de%20como%20realizar%20b%C3%BAsquedas%20de%20palabras%20dentro%20de%20cajas%20de%20texto%20haciendo%20uso%20de%20Expresiones%20Regulares%20de%20Actionscript%203.%0D%0A%0D%0ALo%20primero%20que%20haremos%20es%20crear%20un%20patr%C3%B3n%20con%20los%20caracteres%20de%20texto%20que%20queremos%20seleccionar.%20En%20este%20c" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Busquedas%20de%20palabras%20en%20textos%20con%20expresiones%20regulares&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fbusquedas-de-palabras-en-textos-con-expresiones-regulares%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/editar-cadenas-de-texto-utilizando-expresiones-regulares/' rel='bookmark' title='Permanent Link: Editar cadenas de texto utilizando expresiones regulares'>Editar cadenas de texto utilizando expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/como-encriptar-textos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cómo encriptar textos en Actionscript 3'>Cómo encriptar textos en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/51/' rel='bookmark' title='Permanent Link: Texto con enlaces en Flash al estilo HTML'>Texto con enlaces en Flash al estilo HTML</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Ordenar elementos de un Vector en Actionscript 3</title>
		<link>http://www.codigoactionscript.org/como-ordenar-elementos-de-un-vector-en-actionscript-3/</link>
		<comments>http://www.codigoactionscript.org/como-ordenar-elementos-de-un-vector-en-actionscript-3/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 16:54:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Básico]]></category>
		<category><![CDATA[Noticias]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=310</guid>
		<description><![CDATA[<p>En este ejemplo explicaré como ordenar elementos internos de un objeto de clase Vector en Actionscript 3. Para ordenar los elementos en realidad se realiza de igual manera que en un Array. Únicamente deberemos escribir una función que compare lo elementos según el orden que nos interese.</p>
<p>El valor que nos ha de devolver la función que realiza la comparación deberá ser:</p>

1: Si el primer valor es superior al segundo
-1: si el primer valor es inferior al segundo
0: Si los valores son iguales

<p>De manera que si creamos un Vector con 10 [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/ordenar-los-elementos-de-un-arraycollection-en-flex/' rel='bookmark' title='Permanent Link: Ordenar los elementos de un ArrayCollection en Flex'>Ordenar los elementos de un ArrayCollection en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/anadir-funciones-al-teclado-con-actionscript-3/' rel='bookmark' title='Permanent Link: Añadir funciones al teclado con Actionscript 3'>Añadir funciones al teclado con Actionscript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>En este ejemplo explicaré como ordenar elementos internos de un objeto de clase Vector en Actionscript 3. Para ordenar los elementos en realidad se realiza de igual manera que en un Array. Únicamente deberemos escribir una función que compare lo elementos según el orden que nos interese.</p>
<p>El valor que nos ha de devolver la función que realiza la comparación deberá ser:</p>
<ul>
<li>1: Si el primer valor es superior al segundo</li>
<li>-1: si el primer valor es inferior al segundo</li>
<li>0: Si los valores son iguales</li>
</ul>
<p>De manera que si creamos un Vector con 10 numero aleatorios:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-70">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> vector:Vector.&lt;uint&gt; = <span style="color: #000000; font-weight: bold;">new</span> Vector.&lt;uint&gt;<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<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;">int</span> = <span style="color: #cc66cc;">0</span>; i &lt;<span style="color: #cc66cc;">10</span>; i++<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; vector.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>vector<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//25,19,69,95,57,78,59,86,2,97 </span></div>
</div>
</div>
</div>
<p></p>
<p>Si ahora lo quisiésemos ordenar de forma ascendente haríamos lo siguiente:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-71">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">function</span> ascendente<span style="color: #66cc66;">&#40;</span>x:uint, y:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">int</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>x&gt;= y<span style="color: #66cc66;">&#41;</span>?<span style="color: #cc66cc;">1</span> :-<span style="color: #cc66cc;">1</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
vector.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span>ascendente<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>vector<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//2,19,25,57,59,69,78,86,95,97 </span></div>
</div>
</div>
</div>
<p></p>
<p>Y lo mismo para ordenarlo de forma descendente:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-72">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">function</span> descendente<span style="color: #66cc66;">&#40;</span>x:uint, y:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">int</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>x &lt;y<span style="color: #66cc66;">&#41;</span>?<span style="color: #cc66cc;">1</span> :-<span style="color: #cc66cc;">1</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
vector.<span style="color: #0066CC;">sort</span><span style="color: #66cc66;">&#40;</span>descendente<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>vector<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//97,95,86,78,69,59,57,25,19,2 </span></div>
</div>
</div>
</div>
<p></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F&amp;t=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F&amp;title=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=En%20este%20ejemplo%20explicar%C3%A9%20como%20ordenar%20elementos%20internos%20de%20un%20objeto%20de%20clase%20Vector%20en%20Actionscript%203.%20Para%20ordenar%20los%20elementos%20en%20realidad%20se%20realiza%20de%20igual%20manera%20que%20en%20un%20Array.%20%C3%9Anicamente%20deberemos%20escribir%20una%20funci%C3%B3n%20que%20compare%20lo%20e" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F&amp;title=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203&amp;annotation=En%20este%20ejemplo%20explicar%C3%A9%20como%20ordenar%20elementos%20internos%20de%20un%20objeto%20de%20clase%20Vector%20en%20Actionscript%203.%20Para%20ordenar%20los%20elementos%20en%20realidad%20se%20realiza%20de%20igual%20manera%20que%20en%20un%20Array.%20%C3%9Anicamente%20deberemos%20escribir%20una%20funci%C3%B3n%20que%20compare%20lo%20e" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F&amp;title=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203&amp;notes=En%20este%20ejemplo%20explicar%C3%A9%20como%20ordenar%20elementos%20internos%20de%20un%20objeto%20de%20clase%20Vector%20en%20Actionscript%203.%20Para%20ordenar%20los%20elementos%20en%20realidad%20se%20realiza%20de%20igual%20manera%20que%20en%20un%20Array.%20%C3%9Anicamente%20deberemos%20escribir%20una%20funci%C3%B3n%20que%20compare%20lo%20e" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Ordenar%20elementos%20de%20un%20Vector%20en%20Actionscript%203&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomo-ordenar-elementos-de-un-vector-en-actionscript-3%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/ordenar-los-elementos-de-un-arraycollection-en-flex/' rel='bookmark' title='Permanent Link: Ordenar los elementos de un ArrayCollection en Flex'>Ordenar los elementos de un ArrayCollection en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/anadir-funciones-al-teclado-con-actionscript-3/' rel='bookmark' title='Permanent Link: Añadir funciones al teclado con Actionscript 3'>Añadir funciones al teclado con Actionscript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/como-ordenar-elementos-de-un-vector-en-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Editar cadenas de texto utilizando expresiones regulares</title>
		<link>http://www.codigoactionscript.org/editar-cadenas-de-texto-utilizando-expresiones-regulares/</link>
		<comments>http://www.codigoactionscript.org/editar-cadenas-de-texto-utilizando-expresiones-regulares/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 18:26:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Trucos]]></category>
		<category><![CDATA[expresiones regulares]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=271</guid>
		<description><![CDATA[<p>La clase String dispone de un método replace() que nos permite reemplazar parte del texto por otro. Esto nos puede resultar muy útil no solo para editar campos de texto grandes, si no para realizar simples acciones de programación.</p>
<p>Un ejemplo podría ser utilizar este método para saber el ID del botón que ejecutó una acción. Por ejemplo, tenemos una serie de botones con un nombre secuencial que todos ejecutan la misma acción, pero que debe pasar como parámetro el numero de la secuencia para ejecutar la acción de manera diferente.</p>



boton1.addEventListener&#40;MouseEvent.CLICK, [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/' rel='bookmark' title='Permanent Link: Busquedas de palabras en textos con expresiones regulares'>Busquedas de palabras en textos con expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/texto-con-scroll-a-dos-columnas-en-flash-cs3/' rel='bookmark' title='Permanent Link: Texto con scroll a dos columnas en Flash CS3'>Texto con scroll a dos columnas en Flash CS3</a></li>
<li><a href='http://www.codigoactionscript.org/ejecutar-acciones-actionscript-en-hiperlinks-con-as3/' rel='bookmark' title='Permanent Link: Ejecutar acciones actionscript en enlaces de texto con AS3'>Ejecutar acciones actionscript en enlaces de texto con AS3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>La clase String dispone de un método <strong>replace()</strong> que nos permite reemplazar parte del texto por otro. Esto nos puede resultar muy útil no solo para editar campos de texto grandes, si no para realizar simples acciones de programación.</p>
<p>Un ejemplo podría ser utilizar este método para saber el ID del botón que ejecutó una acción. Por ejemplo, tenemos una serie de botones con un nombre secuencial que todos ejecutan la misma acción, pero que debe pasar como parámetro el numero de la secuencia para ejecutar la acción de manera diferente.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-79">
<div class="actionscript">boton1.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, onClickBoton<span style="color: #66cc66;">&#41;</span>;<br />
boton2.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, onClickBoton<span style="color: #66cc66;">&#41;</span>;<br />
boton3.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, onClickBoton<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #808080; font-style: italic;">//etc..</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> onClickBoton<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> id:uint = uint<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">name</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>RegExp<span style="color: #66cc66;">&#40;</span>/boton/<span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"me clicó el botón numero "</span> + id<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Dando uso de las <a href="http://www.cristalab.com/tips/expresiones-regulares-en-actionscript-3.-tip-1-c30867l">expresiones</a> <a href="http://www.cristalab.com/tips/expresiones-regulares-en-actionscript-3-tip-2-c30909l">regulares</a> se crea un patrón que le dice al método replace() que sustituya el texto "boton" del nombre del botón por nada, con lo que nos quedamos solo con el numero de la secuencia... A partir de ahi ejecutamos las acciones que queramos.</p>
<p>Otro ejemplo de uso práctico de método es editar partes de direcciones URL. Por ejemplo, tenemos una serie de archivos XML situados en diferentes carpetas con la misma estructura:</p>
<p>http://www.dominio.com/usuarios/1320/datos/archivo.xml</p>
<p>http://www.dominio.com/usuarios/1321/datos/archivo.xml</p>
<p>http://www.dominio.com/usuarios/1322/datos/archivo.xml</p>
<p>etc..</p>
<p>En este caso podríamos tener un URL genérica de acceso global definiendo que esa carpeta en concreto será variable:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-80">
<div class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _xmlURL:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://www.dominio.com/usuarios/#id#/datos/archivo.xml"</span></div>
</div>
</div>
</div>
<p></p>
<p>Y para utilizar esta url, unicamente sustituiremos el nombre de la carpeta por la que necesitemos en cada llamada.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-81">
<div class="actionscript">_urlRequest.<span style="color: #0066CC;">url</span>&nbsp; = Global.<span style="color: #006600;">getXmlURL</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span>RegExp<span style="color: #66cc66;">&#40;</span>/<span style="color: #808080; font-style: italic;">#id#/), _id); </span></div>
</div>
</div>
</div>
<p></p>
<p>Espero les sea útil  <img src='http://www.codigoactionscript.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F&amp;t=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F&amp;title=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=La%20clase%20String%20dispone%20de%20un%20m%C3%A9todo%20%20que%20nos%20permite%20reemplazar%20parte%20del%20texto%20por%20otro.%20Esto%20nos%20puede%20resultar%20muy%20%C3%BAtil%20no%20solo%20para%20editar%20campos%20de%20texto%20grandes%2C%20si%20no%20para%20realizar%20simples%20acciones%20de%20programaci%C3%B3n.%0D%0A%0D%0AUn%20ejemplo%20podr%C3%ADa%20se" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F&amp;title=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares&amp;annotation=La%20clase%20String%20dispone%20de%20un%20m%C3%A9todo%20%20que%20nos%20permite%20reemplazar%20parte%20del%20texto%20por%20otro.%20Esto%20nos%20puede%20resultar%20muy%20%C3%BAtil%20no%20solo%20para%20editar%20campos%20de%20texto%20grandes%2C%20si%20no%20para%20realizar%20simples%20acciones%20de%20programaci%C3%B3n.%0D%0A%0D%0AUn%20ejemplo%20podr%C3%ADa%20se" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F&amp;title=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares&amp;notes=La%20clase%20String%20dispone%20de%20un%20m%C3%A9todo%20%20que%20nos%20permite%20reemplazar%20parte%20del%20texto%20por%20otro.%20Esto%20nos%20puede%20resultar%20muy%20%C3%BAtil%20no%20solo%20para%20editar%20campos%20de%20texto%20grandes%2C%20si%20no%20para%20realizar%20simples%20acciones%20de%20programaci%C3%B3n.%0D%0A%0D%0AUn%20ejemplo%20podr%C3%ADa%20se" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Editar%20cadenas%20de%20texto%20utilizando%20expresiones%20regulares&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Feditar-cadenas-de-texto-utilizando-expresiones-regulares%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/busquedas-de-palabras-en-textos-con-expresiones-regulares/' rel='bookmark' title='Permanent Link: Busquedas de palabras en textos con expresiones regulares'>Busquedas de palabras en textos con expresiones regulares</a></li>
<li><a href='http://www.codigoactionscript.org/texto-con-scroll-a-dos-columnas-en-flash-cs3/' rel='bookmark' title='Permanent Link: Texto con scroll a dos columnas en Flash CS3'>Texto con scroll a dos columnas en Flash CS3</a></li>
<li><a href='http://www.codigoactionscript.org/ejecutar-acciones-actionscript-en-hiperlinks-con-as3/' rel='bookmark' title='Permanent Link: Ejecutar acciones actionscript en enlaces de texto con AS3'>Ejecutar acciones actionscript en enlaces de texto con AS3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/editar-cadenas-de-texto-utilizando-expresiones-regulares/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ordenar los elementos de un ArrayCollection en Flex</title>
		<link>http://www.codigoactionscript.org/ordenar-los-elementos-de-un-arraycollection-en-flex/</link>
		<comments>http://www.codigoactionscript.org/ordenar-los-elementos-de-un-arraycollection-en-flex/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 18:24:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[ArrayCollection]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=269</guid>
		<description><![CDATA[<p>En el siguiente tip mostraré como ordenar un ArrayCollection en Flex. Esto nos puede ser necesario a la hora de mostrar su contenido. Para mostrar esto utilizaré como ejemplo los resultados (hasta este momento) de las votaciones de los premios Cristalab 2008.</p>
<p>Supongamos que tenemos este ArrayCollection:</p>



public var premioPopular:ArrayCollection = new ArrayCollection&#40;&#91;
&#160; &#160; &#160; &#160; &#123;claber: "Eldervaz", votos: 6&#125;,
&#160; &#160; &#123;claber: "Freddie", votos: 13&#125;,
&#160; &#160; &#123;claber: "XKlibur", votos: 3&#125;,
&#160; &#160; &#123;claber: "TheParrot", votos: 7&#125;,
&#160; &#160; &#123;claber: "M@U", votos: 1&#125;,
&#160; &#160; &#123;claber: "Mariux", votos: 4&#125;,
&#160; &#160; &#123;claber: "JaLeRu", votos: 1&#125;,
&#160; &#160; &#123;claber: [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/como-ordenar-elementos-de-un-vector-en-actionscript-3/' rel='bookmark' title='Permanent Link: Ordenar elementos de un Vector en Actionscript 3'>Ordenar elementos de un Vector en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/modificar-datos-en-componentes-flex-con-itemeditors/' rel='bookmark' title='Permanent Link: Modificar datos en componentes Flex con ItemEditors'>Modificar datos en componentes Flex con ItemEditors</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-los-iconos-en-componentes-tree-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar los iconos en componentes Tree de Flex'>Cómo personalizar los iconos en componentes Tree de Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>En el siguiente <a href="http://www.cristalab.com/tips/tags">tip</a> mostraré como ordenar un <strong>ArrayCollection</strong> en <a href="http://www.cristalab.com/tips/tags/flex">Flex</a>. Esto nos puede ser necesario a la hora de mostrar su contenido. Para mostrar esto utilizaré como ejemplo los resultados (hasta este momento) de las votaciones de los <a href="http://www.cristalab.com/blog/66033/vota-para-elegir-los-ganadores-a-los-premios-cristalab-2008.html">premios Cristalab 2008</a>.</p>
<p>Supongamos que tenemos este ArrayCollection:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-92">
<div class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> premioPopular:ArrayCollection = <span style="color: #000000; font-weight: bold;">new</span> ArrayCollection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"Eldervaz"</span>, votos: <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"Freddie"</span>, votos: <span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"XKlibur"</span>, votos: <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"TheParrot"</span>, votos: <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"M@U"</span>, votos: <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"Mariux"</span>, votos: <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"JaLeRu"</span>, votos: <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span>claber: <span style="color: #ff0000;">"Pley"</span>, votos: <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#125;</span>,<br />
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Y asignamos este ArrayCollection a un componente PieChart para mostrar los resultados:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-93">
<div class="actionscript">&lt;mx:VBox <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"25%"</span> horizontalCenter=<span style="color: #ff0000;">"0"</span> verticalCenter=<span style="color: #ff0000;">"0"</span>&gt;<br />
&lt;mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Claber más Popular"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"18"</span>/&gt;<br />
&lt;mx:HBox <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span>&gt;<br />
&nbsp; &nbsp; &lt;mx:Legend id=<span style="color: #ff0000;">"legend1"</span> dataProvider=<span style="color: #ff0000;">"{pie1}"</span>/&gt;<br />
&nbsp; &nbsp; &lt;mx:PieChart id=<span style="color: #ff0000;">"pie1"</span> dataProvider=<span style="color: #ff0000;">"{premioPopular}"</span> showDataTips=<span style="color: #ff0000;">"true"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"150"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"150"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:series&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:PieSeries field=<span style="color: #ff0000;">"votos"</span> nameField=<span style="color: #ff0000;">"claber"</span>/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:series&gt;<br />
&nbsp; &nbsp; &lt;/mx:PieChart&gt;<br />
&nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;<br />
&lt;/mx:VBox&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Daría este resultado:</p>
<div align="center"><div align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="" height="">  <param name="movie" value="http://www.cristalab.com/images/tips//flex/sortArrayCollection/sortPie1.swf" />  <param name="quality" value="high" /> <embed src="http://www.cristalab.com/images/tips//flex/sortArrayCollection/sortPie1.swf" width="" height="" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></div></div>
<p>Como podemos ver, los resultados aparecen en el orden en que están colocados dentro del ArrayCollection. Pero de esta manera en el <em>Legend </em>no sabemos quien es el que obtuvo más votos.</p>
<p>En este caso podríamos haber ordenado el ArrayCollection manualmente, pero para casos más complejos nos resultaría más fácil ordenarlo por código. Para ello utilizaremos la clase <strong>SortField</strong> y la clase <strong>Sort</strong>.</p>
<p>Crearemos una instancia de la clase <strong>SortField</strong>, y le pasaremos como propiedad el nombre del parámetro que queremos ordenar del ArrayCollection. También indicaremos si el parámetro a ordenar es un dato numérico o no.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-94">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> sortField:SortField = <span style="color: #000000; font-weight: bold;">new</span> SortField<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
sortField.<span style="color: #0066CC;">name</span> = <span style="color: #ff0000;">"votos"</span>;<br />
sortField.<span style="color: #006600;">numeric</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</div>
</div>
</div>
<p></p>
<p>También crearemos una instancia de la clase <strong>Sort </strong>y le pasaremos referencia del objeto SortField creado. Aqui ejecutaremos el método <strong>reverse()</strong> para que la ordenación de elementos sea de mayor a menor (por defecto es de nemor a mayor).</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-95">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">sort</span>:<span style="color: #0066CC;">Sort</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Sort</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #0066CC;">sort</span>.<span style="color: #006600;">fields</span> = <span style="color: #66cc66;">&#91;</span>sortField<span style="color: #66cc66;">&#93;</span>;<br />
<span style="color: #0066CC;">sort</span>.<span style="color: #0066CC;">reverse</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Ahora pasaremos este objeto al ArrayCollection, y ejecutaremos el método refresh() que hará que el Array se ordene segun los parámetros indicados.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-96">
<div class="actionscript">premioPopular.<span style="color: #0066CC;">sort</span> = <span style="color: #0066CC;">sort</span>;<br />
premioPopular.<span style="color: #006600;">refresh</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
</div>
<p></p>
<p>Este es es resultado:</p>
<div align="center"><div align="center"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="" height="">  <param name="movie" value="http://www.cristalab.com/images/tips//flex/sortArrayCollection/sortPie2.swf" />  <param name="quality" value="high" /> <embed src="http://www.cristalab.com/images/tips//flex/sortArrayCollection/sortPie2.swf" width="" height="" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></div></div>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F&amp;t=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F&amp;title=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=En%20el%20siguiente%20%20mostrar%C3%A9%20como%20ordenar%20un%20%20en%20.%20Esto%20nos%20puede%20ser%20necesario%20a%20la%20hora%20de%20mostrar%20su%20contenido.%20Para%20mostrar%20esto%20utilizar%C3%A9%20como%20ejemplo%20los%20resultados%20%28hasta%20este%20momento%29%20de%20las%20votaciones%20de%20los%20.%0D%0A%0D%0ASupongamos%20que%20tenemos%20este%20A" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F&amp;title=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex&amp;annotation=En%20el%20siguiente%20%20mostrar%C3%A9%20como%20ordenar%20un%20%20en%20.%20Esto%20nos%20puede%20ser%20necesario%20a%20la%20hora%20de%20mostrar%20su%20contenido.%20Para%20mostrar%20esto%20utilizar%C3%A9%20como%20ejemplo%20los%20resultados%20%28hasta%20este%20momento%29%20de%20las%20votaciones%20de%20los%20.%0D%0A%0D%0ASupongamos%20que%20tenemos%20este%20A" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F&amp;title=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex&amp;notes=En%20el%20siguiente%20%20mostrar%C3%A9%20como%20ordenar%20un%20%20en%20.%20Esto%20nos%20puede%20ser%20necesario%20a%20la%20hora%20de%20mostrar%20su%20contenido.%20Para%20mostrar%20esto%20utilizar%C3%A9%20como%20ejemplo%20los%20resultados%20%28hasta%20este%20momento%29%20de%20las%20votaciones%20de%20los%20.%0D%0A%0D%0ASupongamos%20que%20tenemos%20este%20A" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Ordenar%20los%20elementos%20de%20un%20ArrayCollection%20en%20Flex&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fordenar-los-elementos-de-un-arraycollection-en-flex%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/como-ordenar-elementos-de-un-vector-en-actionscript-3/' rel='bookmark' title='Permanent Link: Ordenar elementos de un Vector en Actionscript 3'>Ordenar elementos de un Vector en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/modificar-datos-en-componentes-flex-con-itemeditors/' rel='bookmark' title='Permanent Link: Modificar datos en componentes Flex con ItemEditors'>Modificar datos en componentes Flex con ItemEditors</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-los-iconos-en-componentes-tree-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar los iconos en componentes Tree de Flex'>Cómo personalizar los iconos en componentes Tree de Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/ordenar-los-elementos-de-un-arraycollection-en-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Personalizar componentes de Flex con estilos programáticos</title>
		<link>http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/</link>
		<comments>http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 23:45:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[componente]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=260</guid>
		<description><![CDATA[<p>Como ampliación a los tips anteriores sobre personalización de componentes en Flex, "Importar diseño desde Photoshop a Flex" y "Personalizar botones de aplicaciones Flex con Actionscript", explicaré un sistema que nos da mcha libertad a la hora de personalizar nuestras aplicaciones: Los estilos programáticos.</p>
<p>Un estilo programático es simplemente un estilo vinculado a una clase de actionscript con la que dibujamos el gráfico a través de código.</p>
<p>Para ello crearemos dentro de nuestro proyecto una clase de actionscript que extienda de ProgrammaticSkin, la llamaremos por ejemplo EstiloBoton:</p>



package clases.estilos
&#123;
&#160; &#160; import mx.skins.ProgrammaticSkin;</p>
<p>&#160; &#160; [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/personalizar-botones-de-aplicaciones-flex-con-actionscript/' rel='bookmark' title='Permanent Link: Personalizar botones de aplicaciones Flex con Actionscript'>Personalizar botones de aplicaciones Flex con Actionscript</a></li>
<li><a href='http://www.codigoactionscript.org/personalizar-la-tipografia-en-componentes-flex/' rel='bookmark' title='Permanent Link: Personalizar la tipografía en componentes Flex'>Personalizar la tipografía en componentes Flex</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-los-iconos-en-componentes-tree-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar los iconos en componentes Tree de Flex'>Cómo personalizar los iconos en componentes Tree de Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Como ampliación a los tips anteriores sobre personalización de componentes en Flex, "<a href="http://www.cristalab.com/tips/65839/flex-y-disenadores-importar-diseno-desde-photoshop-a-flex.html">Importar diseño desde Photoshop a Flex</a>" y "<a href="http://www.cristalab.com/foros/t65916_personalizar-botones-de-aplicaciones-flex-con-actionscript.html">Personalizar botones de aplicaciones Flex con Actionscript</a>", explicaré un sistema que nos da mcha libertad a la hora de personalizar nuestras aplicaciones: Los <strong>estilos programáticos</strong>.</p>
<p>Un estilo programático es simplemente un estilo vinculado a una clase de <a href="http://www.cristalab.com/tips/tags/actionscript">actionscript</a> con la que dibujamos el gráfico a través de código.</p>
<p>Para ello crearemos dentro de nuestro proyecto una clase de actionscript que extienda de ProgrammaticSkin, la llamaremos por ejemplo EstiloBoton:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-105">
<div class="actionscript">package clases.<span style="color: #006600;">estilos</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">skins</span>.<span style="color: #006600;">ProgrammaticSkin</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EstiloBoton <span style="color: #0066CC;">extends</span> ProgrammaticSkin<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Ahora lo que deberemos hacer es sobrescribir la función <strong>updateDisplayList </strong>de la clase <strong>ProgrammaticSkin</strong>. Dentro de esta nueva función dibujaremos con la API de dibujo de Flash los gráficos que queramos para el botón (para este ejemplo dibujaré un circulo de diferente color para cada estado del botón):</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-106">
<div class="actionscript">protected override <span style="color: #000000; font-weight: bold;">function</span> updateDisplayList<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">Number</span>, h:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; graphics.<span style="color: #0066CC;">clear</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">"upSkin"</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF0000<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">"overSkin"</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF4400<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">"downSkin"</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xFF8800<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">"disableSkin"</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; graphics.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0xCCCCCC<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">break</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; graphics.<span style="color: #006600;">drawEllipse</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,w,h<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; graphics.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Ahora solo queda asignar este estilo al botón:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-107">
<div class="actionscript">&lt;mx:Script&gt;<br />
&nbsp; &nbsp; &lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">import</span> clases.<span style="color: #006600;">estilos</span>.<span style="color: #006600;">EstiloBoton</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ico1:<span style="color: #000000; font-weight: bold;">Class</span> = EstiloBoton;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ico2:<span style="color: #000000; font-weight: bold;">Class</span> = EstiloBoton;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ico3:<span style="color: #000000; font-weight: bold;">Class</span> = EstiloBoton;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> ico4:<span style="color: #000000; font-weight: bold;">Class</span> = EstiloBoton;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> ini<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boton1.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"upSkin"</span>, ico1<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boton1.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"overSkin"</span>, ico2<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boton1.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"downSkin"</span>, ico3<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; boton1.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"disableSkin"</span>, ico4<span style="color: #66cc66;">&#41;</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;<br />
&lt;/mx:Script&gt;</div>
</div>
</div>
</div>
<p></p>
<p>En caso de querer asignar el estilo a todos los componentes a través de CSS podemos hacerlo con la directiva ClassReference:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-108">
<div class="actionscript"><span style="color: #0066CC;">Button</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; upSkin: ClassReference<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'clases.estilos.EstiloBoton'</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; overSkin: ClassReference<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'clases.estilos.EstiloBoton'</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; downSkin: ClassReference<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'clases.estilos.EstiloBoton'</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; disableSkin: ClassReference<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'clases.estilos.EstiloBoton'</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Y listo ^^</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F&amp;t=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F&amp;title=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=Como%20ampliaci%C3%B3n%20a%20los%20tips%20anteriores%20sobre%20personalizaci%C3%B3n%20de%20componentes%20en%20Flex%2C%20%22%22%20y%20%22%22%2C%20explicar%C3%A9%20un%20sistema%20que%20nos%20da%20mcha%20libertad%20a%20la%20hora%20de%20personalizar%20nuestras%20aplicaciones%3A%20Los%20.%0D%0A%0D%0AUn%20estilo%20program%C3%A1tico%20es%20simplemente%20un%20estilo%20v" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F&amp;title=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos&amp;annotation=Como%20ampliaci%C3%B3n%20a%20los%20tips%20anteriores%20sobre%20personalizaci%C3%B3n%20de%20componentes%20en%20Flex%2C%20%22%22%20y%20%22%22%2C%20explicar%C3%A9%20un%20sistema%20que%20nos%20da%20mcha%20libertad%20a%20la%20hora%20de%20personalizar%20nuestras%20aplicaciones%3A%20Los%20.%0D%0A%0D%0AUn%20estilo%20program%C3%A1tico%20es%20simplemente%20un%20estilo%20v" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F&amp;title=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos&amp;notes=Como%20ampliaci%C3%B3n%20a%20los%20tips%20anteriores%20sobre%20personalizaci%C3%B3n%20de%20componentes%20en%20Flex%2C%20%22%22%20y%20%22%22%2C%20explicar%C3%A9%20un%20sistema%20que%20nos%20da%20mcha%20libertad%20a%20la%20hora%20de%20personalizar%20nuestras%20aplicaciones%3A%20Los%20.%0D%0A%0D%0AUn%20estilo%20program%C3%A1tico%20es%20simplemente%20un%20estilo%20v" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Personalizar%20componentes%20de%20Flex%20con%20estilos%20program%C3%A1ticos&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-componentes-de-flex-con-estilos-programaticos%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/personalizar-botones-de-aplicaciones-flex-con-actionscript/' rel='bookmark' title='Permanent Link: Personalizar botones de aplicaciones Flex con Actionscript'>Personalizar botones de aplicaciones Flex con Actionscript</a></li>
<li><a href='http://www.codigoactionscript.org/personalizar-la-tipografia-en-componentes-flex/' rel='bookmark' title='Permanent Link: Personalizar la tipografía en componentes Flex'>Personalizar la tipografía en componentes Flex</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-los-iconos-en-componentes-tree-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar los iconos en componentes Tree de Flex'>Cómo personalizar los iconos en componentes Tree de Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comunicación entre módulos cargados con ModuleLoader en Flex</title>
		<link>http://www.codigoactionscript.org/comunicacion-entre-modulos-cargados-con-moduleloader-en-flex/</link>
		<comments>http://www.codigoactionscript.org/comunicacion-entre-modulos-cargados-con-moduleloader-en-flex/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 01:18:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[ModuleLoader]]></category>
		<category><![CDATA[mxml]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=223</guid>
		<description><![CDATA[<p>En este tip mostraré como comunicarse con módulos cargados dentro de una película Flex principal. Los módulos son pequeñas películas MXML que creamos para luego incorporar dentro de otro MXML principal, de igual manera que un componente pero en este caso se genera un archivo .SWF externo independiente, lo que resulta útil ya que podemos compartir módulos entre diferentes películas.</p>
<p>Para colocar un módulo dentro de una película principal existen dos opciones, y con una nos encontraremos un pequeño problema al intentar comunicarnos.</p>
<p>La primera forma es como si de un componente [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/asignar-una-clase-actionscript-3-a-un-itemrenderer-en-flex/' rel='bookmark' title='Permanent Link: Asignar una clase ActionScript 3 a un itemRenderer en Flex'>Asignar una clase ActionScript 3 a un itemRenderer en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-flex/' rel='bookmark' title='Permanent Link: Panel de zoom de imágenes en Flex'>Panel de zoom de imágenes en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Permanent Link: Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>En este <a href="http://www.cristalab.com/tips">tip</a> mostraré como comunicarse con módulos cargados dentro de una película Flex principal. Los módulos son pequeñas películas MXML que creamos para luego incorporar dentro de otro MXML principal, de igual manera que un componente pero en este caso se genera un archivo .SWF externo independiente, lo que resulta útil ya que podemos compartir módulos entre diferentes películas.</p>
<p>Para colocar un módulo dentro de una película principal existen dos opciones, y con una nos encontraremos un pequeño problema al intentar comunicarnos.</p>
<p>La primera forma es como si de un componente se tratase, osea definiríamos el namespace, por ejemplo, xmlns:modules="*", y lo colocaríamos con ese tag:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-117">
<div class="actionscript">&lt;modules:module id=<span style="color: #ff0000;">"modulo"</span>/&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Si este módulo tuviese una función actionscript pública llamada setTexto(t:String); que le asignase el valor a una variable privada podríamos acceder a ella sin problema desde la película MXML principal.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="code-118">
<div class="code">private function setModuleText<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:void<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; modulo.<span style="">setTexto</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"texto"</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Ahora bien, también podríamos haber cargado el módulo con el componente <strong>ModuleLoader</strong>. De esta manera hubiésemos enlazado directamente al archivo .SWF generado al publicar el módulo:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-119">
<div class="actionscript">&lt;mx:ModuleLoader id=<span style="color: #ff0000;">"modulo"</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">"module.swf"</span>/&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Cargarlo de esta manera es útil ya que nos permite intercambiar un modulo por otro dentro del mismo componente reasignando el parámetro URL. Al enlazar directamente al SWF nos permite incorporar módulos generados desde otras películas, incluso desde otros servidores.</p>
<p>El problema es que al colocar el módulo con <strong>ModuleLoader</strong> nos saltará un error al intentar acceder a sus funciones públicas.</p>
<blockquote>1061: Llamada a un método setTexto posiblemente no definido mediante una referencia con tipo estático mx.modules:ModuleLoader.</blockquote>
<strong>¿Cómo lo podemos solucionar? </strong>Deberemos hacer que ese módulo <strong>implemente una Interface</strong> que disponga de esa función pública a la que queremos acceder.</p>
<p>Crearíamos esta sencillo archivo de interface, al que llamaríamos <strong>IModule.as</strong>:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-120">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IModule<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> setTexto<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Para hacer que el módulo implemente esta interface le incluiremos el parámetro en el tag de definición:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="code-121">
<div class="code">&lt;mx:Module xmlns:mx=<span style="color:#CC0000;">"http://www.adobe.com/2006/mxml"</span> layout=<span style="color:#CC0000;">"absolute"</span> implements=<span style="color:#CC0000;">"IModule"</span>&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Y de esta manera deberemos asignar la definición de tipo a la instancia del módulo para llamar a la función que implementa la interface:</p>
<p>private function setModuleText():void<br />
{<br />
	var mod:IModule = modulo.child as IModule;<br />
	mod.setTexto("texto");<br />
} </p>
<p>Ahora si tenemos acceso a las funciones públicas del módulo <img src='http://www.codigoactionscript.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Este es todo el código completo por si alguien quiere darle un vistazo:</p>
<p><strong>module.mxml</strong>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-122">
<div class="actionscript">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?&gt;<br />
&lt;mx:Module xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> layout=<span style="color: #ff0000;">"absolute"</span> <span style="color: #0066CC;">implements</span>=<span style="color: #ff0000;">"IModule"</span>&gt;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &lt;mx:Script&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setTexto<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _texto = t;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;<br />
&nbsp; &nbsp; &lt;/mx:Script&gt;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &lt;mx:Label verticalCenter=<span style="color: #ff0000;">"0"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"20"</span> textAlign=<span style="color: #ff0000;">"center"</span> id=<span style="color: #ff0000;">"textoInput"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"{_texto}"</span>/&gt;&nbsp; <br />
&lt;/mx:Module&gt;</div>
</div>
</div>
</div>
<p></p>
<strong>Main.mxml</strong>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-123">
<div class="actionscript">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?&gt;<br />
&lt;mx:Application xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> xmlns:modules=<span style="color: #ff0000;">"*"</span>&nbsp;layout=<span style="color: #ff0000;">"absolute"</span>&gt;<br />
&nbsp; &nbsp; &lt;mx:Script&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setModuleText1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; modulo1.<span style="color: #006600;">setTexto</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"texto1"</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setModuleText2<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> mod:IModule = modulo2.<span style="color: #006600;">child</span> as IModule;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mod.<span style="color: #006600;">setTexto</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"texto2"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt;<br />
&nbsp; &nbsp; &lt;/mx:Script&gt;<br />
&nbsp; &nbsp; &lt;mx:VBox horizontalCenter=<span style="color: #ff0000;">"0"</span> verticalCenter=<span style="color: #ff0000;">"0"</span> horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;modules:module id=<span style="color: #ff0000;">"modulo1"</span>/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:ModuleLoader id=<span style="color: #ff0000;">"modulo2"</span> <span style="color: #0066CC;">url</span>=<span style="color: #ff0000;">"module.swf"</span>/&gt;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">"Button1"</span> click=<span style="color: #ff0000;">"setModuleText1()"</span>/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> label=<span style="color: #ff0000;">"Button2"</span> click=<span style="color: #ff0000;">"setModuleText2()"</span>/&gt;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp; &lt;/mx:VBox&gt;&nbsp; <br />
&lt;/mx:Application&gt;</div>
</div>
</div>
</div>
<p></p>
<strong>IModule.as</strong>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-124">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">interface</span> IModule<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> setTexto<span style="color: #66cc66;">&#40;</span>t:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F&amp;t=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F&amp;title=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=En%20este%20%20mostrar%C3%A9%20como%20comunicarse%20con%20m%C3%B3dulos%20cargados%20dentro%20de%20una%20pel%C3%ADcula%20Flex%20principal.%20Los%20m%C3%B3dulos%20son%20peque%C3%B1as%20pel%C3%ADculas%20MXML%20que%20creamos%20para%20luego%20incorporar%20dentro%20de%20otro%20MXML%20principal%2C%20de%20igual%20manera%20que%20un%20componente%20pero%20en%20es" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F&amp;title=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex&amp;annotation=En%20este%20%20mostrar%C3%A9%20como%20comunicarse%20con%20m%C3%B3dulos%20cargados%20dentro%20de%20una%20pel%C3%ADcula%20Flex%20principal.%20Los%20m%C3%B3dulos%20son%20peque%C3%B1as%20pel%C3%ADculas%20MXML%20que%20creamos%20para%20luego%20incorporar%20dentro%20de%20otro%20MXML%20principal%2C%20de%20igual%20manera%20que%20un%20componente%20pero%20en%20es" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F&amp;title=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex&amp;notes=En%20este%20%20mostrar%C3%A9%20como%20comunicarse%20con%20m%C3%B3dulos%20cargados%20dentro%20de%20una%20pel%C3%ADcula%20Flex%20principal.%20Los%20m%C3%B3dulos%20son%20peque%C3%B1as%20pel%C3%ADculas%20MXML%20que%20creamos%20para%20luego%20incorporar%20dentro%20de%20otro%20MXML%20principal%2C%20de%20igual%20manera%20que%20un%20componente%20pero%20en%20es" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Comunicaci%C3%B3n%20entre%20m%C3%B3dulos%20cargados%20con%20ModuleLoader%20en%20Flex&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcomunicacion-entre-modulos-cargados-con-moduleloader-en-flex%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/asignar-una-clase-actionscript-3-a-un-itemrenderer-en-flex/' rel='bookmark' title='Permanent Link: Asignar una clase ActionScript 3 a un itemRenderer en Flex'>Asignar una clase ActionScript 3 a un itemRenderer en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-flex/' rel='bookmark' title='Permanent Link: Panel de zoom de imágenes en Flex'>Panel de zoom de imágenes en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/comunicacion-entre-clases-actionscript-3-con-eventdispatcher/' rel='bookmark' title='Permanent Link: Comunicación entre clases Actionscript 3 con EventDispatcher'>Comunicación entre clases Actionscript 3 con EventDispatcher</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/comunicacion-entre-modulos-cargados-con-moduleloader-en-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cargar XML en un componente List en Actionscript 3</title>
		<link>http://www.codigoactionscript.org/cargar-xml-en-un-componente-list-en-actionscript-3/</link>
		<comments>http://www.codigoactionscript.org/cargar-xml-en-un-componente-list-en-actionscript-3/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 15:01:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[DataProvider]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[URLLoader]]></category>
		<category><![CDATA[URLRequest]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=216</guid>
		<description><![CDATA[<p>Este es un ejemplo de clase que extiende el componente List de Flash y le añade la posibilidad de cargar el contenido desde un archivo XML externo.</p>
<p>Este ejemplo de clase surguió a partir de optimizar un clase que me mostró penHolder en Cristalab. Aqui pueden ver su codigo y el post original.</p>

Cargar XML en un componente List en Actionscript 3

<p>Basicamente mi aporte fue hacer que la clase extendiese de List para no tener que crear una instancia del componente y pasarla como parametro a otra clase, ya que nuestra intención [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/clase-para-cargar-contenido-externo-en-actionscript-3/' rel='bookmark' title='Permanent Link: Clase para cargar contenido externo en Actionscript 3'>Clase para cargar contenido externo en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/asignar-una-clase-actionscript-3-a-un-itemrenderer-en-flex/' rel='bookmark' title='Permanent Link: Asignar una clase ActionScript 3 a un itemRenderer en Flex'>Asignar una clase ActionScript 3 a un itemRenderer en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/onreleaseoutside-ondragout-ondragover-en-actionscript-3/' rel='bookmark' title='Permanent Link: onReleaseOutside, onDragOut, onDragOver en ActionScript 3'>onReleaseOutside, onDragOut, onDragOver en ActionScript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Este es un ejemplo de clase que extiende el componente List de Flash y le añade la posibilidad de cargar el contenido desde un archivo XML externo.</p>
<p>Este ejemplo de clase surguió a partir de optimizar un clase que me mostró <a href="http://www.cristalab.com/usuario/30870-penholder" target="_blank">penHolder</a> en <a href="http://www.cristalab.com" target="_blank">Cristalab</a>. Aqui pueden ver su codigo y el post original.</p>
<ul>
<li><a href="http://www.cristalab.com/tips/63017/cargar-xml-en-un-componente-list-en-actionscript-3.html" target="_blank">Cargar XML en un componente List en Actionscript 3</a></li>
</ul>
<p>Basicamente mi aporte fue hacer que la clase extendiese de List para no tener que crear una instancia del componente y pasarla como parametro a otra clase, ya que nuestra intención es crear un mismo componete List pero que contenga unos metodos ampliados, en este caso que contewnga un metodo para cargar los datos desde un archivo XML.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-127">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
   <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;<br />
   <span style="color: #0066CC;">import</span> fl.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">DataProvider</span>;<br />
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLRequest</span>;<br />
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">URLLoader</span>;<br />
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
   <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
   <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FillList <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">List</span><br />
   <span style="color: #66cc66;">&#123;</span><br />
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _xml:<span style="color: #0066CC;">XML</span>;<br />
      <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> FillList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>   <span style="color: #66cc66;">&#123;</span>   <span style="color: #66cc66;">&#125;</span><br />
      <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setData<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">url</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
      <span style="color: #66cc66;">&#123;</span><br />
         <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: #0066CC;">url</span><span style="color: #66cc66;">&#41;</span>;<br />
         <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>;<br />
         loader.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span>request<span style="color: #66cc66;">&#41;</span>;<br />
         loader.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, xmlLoaded<span style="color: #66cc66;">&#41;</span>;<br />
      <span style="color: #66cc66;">&#125;</span><br />
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> xmlLoaded<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><br />
      <span style="color: #66cc66;">&#123;</span><br />
         _xml = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">XML</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span>.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#41;</span>;<br />
         dataProvider = <span style="color: #000000; font-weight: bold;">new</span> DataProvider<span style="color: #66cc66;">&#40;</span>_xml<span style="color: #66cc66;">&#41;</span>;<br />
      <span style="color: #66cc66;">&#125;</span><br />
      <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
   <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Para crear la instacia colocariamos este codigo enb la clase Main:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-128">
<div class="actionscript">package <br />
<span style="color: #66cc66;">&#123;</span><br />
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;<br />
   <span style="color: #0066CC;">import</span> fl.<span style="color: #006600;">controls</span>.<span style="color: #0066CC;">List</span>;<br />
   <span style="color: #0066CC;">import</span> FillList;<br />
   <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
   <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #0066CC;">extends</span> <span style="color: #0066CC;">MovieClip</span><br />
   <span style="color: #66cc66;">&#123;</span><br />
      <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> bofhList:FillList;<br />
   <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
      <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
      <span style="color: #66cc66;">&#123;</span><br />
         bofhList = <span style="color: #000000; font-weight: bold;">new</span> FillList<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
         bofhList.<span style="color: #006600;">setData</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"datos.xml"</span><span style="color: #66cc66;">&#41;</span>;<br />
         bofhList.<span style="color: #006600;">setSize</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">150</span>,<span style="color: #cc66cc;">200</span><span style="color: #66cc66;">&#41;</span>;<br />
         bofhList.<span style="color: #006600;">move</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;<br />
         addChild<span style="color: #66cc66;">&#40;</span>bofhList<span style="color: #66cc66;">&#41;</span>;<br />
      <span style="color: #66cc66;">&#125;</span><br />
   <span style="color: #808080; font-style: italic;">//------------------------------------</span><br />
   <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F&amp;t=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F&amp;title=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=Este%20es%20un%20ejemplo%20de%20clase%20que%20extiende%20el%20componente%20List%20de%20Flash%20y%20le%20a%C3%B1ade%20la%20posibilidad%20de%20cargar%20el%20contenido%20desde%20un%20archivo%20XML%20externo.%0D%0A%0D%0AEste%20ejemplo%20de%20clase%20surgui%C3%B3%20a%20partir%20de%20optimizar%20un%20clase%20que%20me%20mostr%C3%B3%20penHolder%20en%20Cristala" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F&amp;title=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203&amp;annotation=Este%20es%20un%20ejemplo%20de%20clase%20que%20extiende%20el%20componente%20List%20de%20Flash%20y%20le%20a%C3%B1ade%20la%20posibilidad%20de%20cargar%20el%20contenido%20desde%20un%20archivo%20XML%20externo.%0D%0A%0D%0AEste%20ejemplo%20de%20clase%20surgui%C3%B3%20a%20partir%20de%20optimizar%20un%20clase%20que%20me%20mostr%C3%B3%20penHolder%20en%20Cristala" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F&amp;title=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203&amp;notes=Este%20es%20un%20ejemplo%20de%20clase%20que%20extiende%20el%20componente%20List%20de%20Flash%20y%20le%20a%C3%B1ade%20la%20posibilidad%20de%20cargar%20el%20contenido%20desde%20un%20archivo%20XML%20externo.%0D%0A%0D%0AEste%20ejemplo%20de%20clase%20surgui%C3%B3%20a%20partir%20de%20optimizar%20un%20clase%20que%20me%20mostr%C3%B3%20penHolder%20en%20Cristala" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Cargar%20XML%20en%20un%20componente%20List%20en%20Actionscript%203&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Fcargar-xml-en-un-componente-list-en-actionscript-3%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/clase-para-cargar-contenido-externo-en-actionscript-3/' rel='bookmark' title='Permanent Link: Clase para cargar contenido externo en Actionscript 3'>Clase para cargar contenido externo en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/asignar-una-clase-actionscript-3-a-un-itemrenderer-en-flex/' rel='bookmark' title='Permanent Link: Asignar una clase ActionScript 3 a un itemRenderer en Flex'>Asignar una clase ActionScript 3 a un itemRenderer en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/onreleaseoutside-ondragout-ondragover-en-actionscript-3/' rel='bookmark' title='Permanent Link: onReleaseOutside, onDragOut, onDragOver en ActionScript 3'>onReleaseOutside, onDragOut, onDragOver en ActionScript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/cargar-xml-en-un-componente-list-en-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Acceder a funciones en MovieClips de películas .swf externas</title>
		<link>http://www.codigoactionscript.org/acceder-a-funciones-en-movieclips-de-peliculas-swf-externas/</link>
		<comments>http://www.codigoactionscript.org/acceder-a-funciones-en-movieclips-de-peliculas-swf-externas/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 01:00:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Avanzado]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[linkage]]></category>
		<category><![CDATA[loader]]></category>
		<category><![CDATA[public]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=147</guid>
		<description><![CDATA[<p>Cuando creamos aplicaciones complejas es probable que las construyamos a partir de cargar módulos creados en pequeñas películas .swf externas cargadas dentro de un Loader en la película principal. Estas pequeñas películas contendrán clips con clases asociadas que dispondrán de funciones públicas que nos interesará ejecutar desde la película principal. En este tip explicaré precisamente eso, cómo acceder a las funciones públicas de la clase asignada a un MovieClip de la librería de un archivo .swf externo desde la película principal.</p>
<p>Para mostrar el proceso utilizaré un ejemplo muy simplificado. Tendremos [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/como-duplicar-movieclips-con-graficos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cómo duplicar MovieClips con gráficos en ActionScript 3'>Cómo duplicar MovieClips con gráficos en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/anadir-funciones-al-teclado-con-actionscript-3/' rel='bookmark' title='Permanent Link: Añadir funciones al teclado con Actionscript 3'>Añadir funciones al teclado con Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/manejo-de-movieclips-con-actionscript-3/' rel='bookmark' title='Permanent Link: Manejo de MovieClips con ActionScript 3'>Manejo de MovieClips con ActionScript 3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Cuando creamos aplicaciones complejas es probable que las construyamos a partir de cargar módulos creados en pequeñas películas .swf externas cargadas dentro de un <strong><em>Loader</em></strong> en la película principal. Estas pequeñas películas contendrán clips con clases asociadas que dispondrán de funciones públicas que nos interesará ejecutar desde la película principal. En este tip explicaré precisamente eso, cómo acceder a las funciones públicas de la clase asignada a un MovieClip de la librería de un archivo .swf externo desde la película principal.</p>
<p>Para mostrar el proceso utilizaré un ejemplo muy simplificado. Tendremos una película swfClipA.fla en cuya biblioteca tendrá un MovieClip al que le hemos asignado una clase, en este caso la clase se llama <strong>ClipA </strong>que estará dentro del package <strong>clases</strong>.</p>
<div align="center"><img src="http://www.cristalab.com/images/tips/actionscript_3/fcpublicasExt/1.jpg" alt="" /></div>
<p>Para simplificar al máximo este ejemplo únicamente haremos que la clase de este clip le coloque un angulo de rotación aleatorio y coloque este valor dentro de una variable, y contendrá una función publica que devuelve dicho valor.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="code-135">
<div class="code">package clases<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
import flash.<span style="">display</span>.<span style="">MovieClip</span>;</p>
<p>public class ClipA extends MovieClip<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
private var angulo:uint;</p>
<p>public function ClipA<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
this.<span style="">rotation</span> = Math.<span style="">round</span><span style="color:#006600; font-weight:bold;">&#40;</span>Math.<span style="">random</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> *<span style="color:#800000;">360</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
angulo = this.<span style="">rotation</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
public function getAngulo<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>:uint<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
return angulo;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Ahora bien, imaginemos que tenemos una película principal en la que cargamos este archivo <strong>swfClipA.swf</strong>. Esta sería la clase asignada a la película principal:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="code-136">
<div class="code">package clases<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
import flash.<span style="">display</span>.<span style="">Loader</span>;<br />
import flash.<span style="">display</span>.<span style="">MovieClip</span>;<br />
import flash.<span style="">net</span>.<span style="">URLRequest</span>;<br />
import flash.<span style="">events</span>.<span style="">Event</span>;</p>
<p>public class Main extends MovieClip<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
private var _swf:MovieClip;</p>
<p>public function Main<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
var loader:Loader = new Loader<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
var request:URLRequest = new URLRequest<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"swfClipA.swf"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
loader.<span style="">load</span><span style="color:#006600; font-weight:bold;">&#40;</span>request<span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
loader.<span style="">contentLoaderInfo</span>.<span style="">addEventListener</span><span style="color:#006600; font-weight:bold;">&#40;</span>Event.<span style="">COMPLETE</span>, onCargado<span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
private function onCargado<span style="color:#006600; font-weight:bold;">&#40;</span>e:Event<span style="color:#006600; font-weight:bold;">&#41;</span>:void<br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
_swf = addChild<span style="color:#006600; font-weight:bold;">&#40;</span>e.<span style="">target</span>.<span style="">content</span><span style="color:#006600; font-weight:bold;">&#41;</span> as MovieClip;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Y ahora desde esta película principal acceder a la función pública del MovieClip interno del archivo externo. Lo único que tenemos que hacer es buscar la ruta de esa clase dentro del clip cargado.</p>
<p>Para ello realizaremos una búsqueda dentro del clip cargado y seleccionaremos cual de ellos está creado con la clase que nos interesa interactuar. Una vez encontrada podremos acceder sin problema a sus funciones públicas.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="code-137">
<div class="code">for <span style="color:#006600; font-weight:bold;">&#40;</span>var i:uint = <span style="color:#800000;">0</span>; i &amp;lt;_swf.<span style="">numChildren</span>; i++<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
var clip:MovieClip = _swf.<span style="">getChildAt</span><span style="color:#006600; font-weight:bold;">&#40;</span>i<span style="color:#006600; font-weight:bold;">&#41;</span> as MovieClip;<br />
if <span style="color:#006600; font-weight:bold;">&#40;</span>clip.<span style="">constructor</span> == ClipA<span style="color:#006600; font-weight:bold;">&#41;</span><br />
<span style="color:#006600; font-weight:bold;">&#123;</span><br />
var _clipA:MovieClip = clip;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
trace<span style="color:#006600; font-weight:bold;">&#40;</span>_clipA.<span style="">getAngulo</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
</div>
<p></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Comparte:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://meneame.net/submit.php?url=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F" title="Meneame"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/meneame.png" title="Meneame" alt="Meneame" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F" title="Twitter"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F&amp;t=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas" title="Facebook"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F&amp;title=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas&amp;source=CODIGO.actionscript+Blog+de+programaci%C3%B3n+en+ActionScript.+Tips%2C+tutoriales%2C+ejemplos+de+Adobe+Flash%2C+Flex+y+AIR&amp;summary=Cuando%20creamos%20aplicaciones%20complejas%20es%20probable%20que%20las%20construyamos%20a%20partir%20de%20cargar%20m%C3%B3dulos%20creados%20en%20peque%C3%B1as%20pel%C3%ADculas%20.swf%20externas%20cargadas%20dentro%20de%20un%20%20en%20la%20pel%C3%ADcula%20principal.%20Estas%20peque%C3%B1as%20pel%C3%ADculas%20contendr%C3%A1n%20clips%20con%20clases" title="LinkedIn"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F&amp;title=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas&amp;annotation=Cuando%20creamos%20aplicaciones%20complejas%20es%20probable%20que%20las%20construyamos%20a%20partir%20de%20cargar%20m%C3%B3dulos%20creados%20en%20peque%C3%B1as%20pel%C3%ADculas%20.swf%20externas%20cargadas%20dentro%20de%20un%20%20en%20la%20pel%C3%ADcula%20principal.%20Estas%20peque%C3%B1as%20pel%C3%ADculas%20contendr%C3%A1n%20clips%20con%20clases" title="Google Bookmarks"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F&amp;title=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas&amp;notes=Cuando%20creamos%20aplicaciones%20complejas%20es%20probable%20que%20las%20construyamos%20a%20partir%20de%20cargar%20m%C3%B3dulos%20creados%20en%20peque%C3%B1as%20pel%C3%ADculas%20.swf%20externas%20cargadas%20dentro%20de%20un%20%20en%20la%20pel%C3%ADcula%20principal.%20Estas%20peque%C3%B1as%20pel%C3%ADculas%20contendr%C3%A1n%20clips%20con%20clases" title="del.icio.us"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F" title="Technorati"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="mailto:?subject=Acceder%20a%20funciones%20en%20MovieClips%20de%20pel%C3%ADculas%20.swf%20externas&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F" title="email"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-funciones-en-movieclips-de-peliculas-swf-externas%2F&amp;partner=sociable" title="Print"><img src="http://www.codigoactionscript.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a></li>
</ul>
</div>


<p>Related posts:<ol><li><a href='http://www.codigoactionscript.org/como-duplicar-movieclips-con-graficos-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cómo duplicar MovieClips con gráficos en ActionScript 3'>Cómo duplicar MovieClips con gráficos en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/anadir-funciones-al-teclado-con-actionscript-3/' rel='bookmark' title='Permanent Link: Añadir funciones al teclado con Actionscript 3'>Añadir funciones al teclado con Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/manejo-de-movieclips-con-actionscript-3/' rel='bookmark' title='Permanent Link: Manejo de MovieClips con ActionScript 3'>Manejo de MovieClips con ActionScript 3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/acceder-a-funciones-en-movieclips-de-peliculas-swf-externas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
