<?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; componente</title>
	<atom:link href="http://www.codigoactionscript.org/tag/componente/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>Mon, 31 May 2010 14:58:30 +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>Panel de zoom de imágenes en Flex</title>
		<link>http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-flex/</link>
		<comments>http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-flex/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 21:04:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Básico]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[mxml]]></category>
		<category><![CDATA[panel]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=391</guid>
		<description><![CDATA[<p>Este ejemplo es, igual que hice en el post anterior, un ejemplo que he adaptado a Flex desde un ejemplo que hice hace tiempo para Flash. Se trata de un panel donde se ve un zoom de una parte de una imagen.</p>
<p>Este es el ejemplo montado en Flex:
</p>
<p>Y este es el código utilizado para la película principal:</p>



&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; xmlns:ui="*"
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; layout="absolute"
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; creationComplete="ini()"
&#160; &#160; &#160; &#160; &#160; &#160; &#160; [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flex/' rel='bookmark' title='Permanent Link: Ejemplo de Zoom con lupa en Flex'>Ejemplo de Zoom con lupa en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-actionscript-3/' rel='bookmark' title='Permanent Link: Panel de zoom de imágenes en ActionScript 3'>Panel de zoom de imágenes en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/drag-and-drop-en-as3/' rel='bookmark' title='Permanent Link: Drag and Drop en AS3'>Drag and Drop en AS3</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Este ejemplo es, igual que hice en el <a href="http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flex/">post anterior</a>, un ejemplo que he adaptado a Flex desde un <a href="http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-actionscript-3/">ejemplo que hice hace tiempo</a> para Flash. Se trata de un panel donde se ve un zoom de una parte de una imagen.</p>
<p>Este es el ejemplo montado en Flex:<br />
<object width="505" height="260"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.codigoactionscript.org/files/EfectoZoomFlex/EfectoZoom.swf" /><embed src="http://www.codigoactionscript.org/files/EfectoZoomFlex/EfectoZoom.swf" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="505" height="260"></embed></object></p>
<p>Y este es el código utilizado para la película principal:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-9">
<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns:ui=<span style="color: #ff0000;">"*"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #ff0000;">"absolute"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; creationComplete=<span style="color: #ff0000;">"ini()"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"505"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"260"</span>&gt;</p>
<p>&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;">import</span> ZoomFx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _zoom:ZoomFx;</p>
<p>&nbsp; &nbsp; &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; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _zoom=<span style="color: #000000; font-weight: bold;">new</span> ZoomFx<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, fotoZoom, panelZoom<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;</p>
<p>&nbsp; &nbsp; &lt;mx:HBox horizontalCenter=<span style="color: #ff0000;">"0"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; verticalCenter=<span style="color: #ff0000;">"0"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;ui:FotoZoom id=<span style="color: #ff0000;">"fotoZoom"</span>/&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;ui:PanelZoom id=<span style="color: #ff0000;">"panelZoom"</span>/&gt;<br />
&nbsp; &nbsp; &lt;/mx:HBox&gt;</p>
<p>&lt;/mx:Application&gt;</p></div>
</div>
</div>
</div>
<p></p>
<p>Este sería el componente que contiene la foto en grande:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-10">
<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:Canvas xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"350"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"250"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderStyle=<span style="color: #ff0000;">"solid"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderThickness=<span style="color: #ff0000;">"1"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#000000"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; horizontalScrollPolicy=<span style="color: #ff0000;">"off"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; verticalScrollPolicy=<span style="color: #ff0000;">"off"</span>&gt;<br />
&nbsp; &nbsp; &lt;mx:Image id=<span style="color: #ff0000;">"foto"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;scaleContent=<span style="color: #ff0000;">"false"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:source&gt;img/Waterfall.<span style="color: #006600;">jpg</span>&lt;/mx:source&gt;<br />
&nbsp; &nbsp; &lt;/mx:Image&gt;</p>
<p>&lt;/mx:Canvas&gt;</p></div>
</div>
</div>
</div>
<p></p>
<p>Y este el componente que contiene el panel de preview:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-11">
<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:Canvas xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"140"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderStyle=<span style="color: #ff0000;">"solid"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderThickness=<span style="color: #ff0000;">"1"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#000000"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; horizontalScrollPolicy=<span style="color: #ff0000;">"off"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; verticalScrollPolicy=<span style="color: #ff0000;">"off"</span>&gt;<br />
&nbsp; &nbsp; &lt;mx:Image id=<span style="color: #ff0000;">"foto"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;scaleContent=<span style="color: #ff0000;">"true"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"140"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;horizontalCenter=<span style="color: #ff0000;">"0"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;verticalCenter=<span style="color: #ff0000;">"0"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:source&gt;img/Waterfall.<span style="color: #006600;">jpg</span>&lt;/mx:source&gt;<br />
&nbsp; &nbsp; &lt;/mx:Image&gt;<br />
&nbsp; &nbsp; &lt;mx:Canvas x=<span style="color: #ff0000;">"0"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; y=<span style="color: #ff0000;">"0"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"70"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"50"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">"#FF0000"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; backgroundAlpha=<span style="color: #ff0000;">"0.5"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderStyle=<span style="color: #ff0000;">"solid"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; borderThickness=<span style="color: #ff0000;">"1"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#FF0000"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; id=<span style="color: #ff0000;">"zoomDrag"</span>&gt;<br />
&nbsp; &nbsp; &lt;/mx:Canvas&gt;<br />
&lt;/mx:Canvas&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Solo quedaría la clase de que controla el efecto:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-12">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">containers</span>.<span style="color: #006600;">Canvas</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Image</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;<br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ZoomFx<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _stage:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _fotoZoom:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _panelZoom:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _distX:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _distY:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _porcentajeX:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _porcentajeY:<span style="color: #0066CC;">Number</span>;</p>
<p>&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> ZoomFx<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>:UIComponent, fotoZoom:UIComponent, panelZoom:UIComponent<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _stage=<span style="color: #0066CC;">stage</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _fotoZoom=fotoZoom;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _panelZoom=panelZoom;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iniZoomDrag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> iniZoomDrag<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: #000000; font-weight: bold;">var</span> drag:Canvas=_panelZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"zoomDrag"</span><span style="color: #66cc66;">&#41;</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drag.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_DOWN</span>, onStartDrag<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drag.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_UP</span>, onStopDrag<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drag.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_OUT</span>, onStopDrag<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onStartDrag<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 />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> canvas:Canvas=<span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0066CC;">startDrag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _stage.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, onMouseDragMove<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onStopDrag<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 />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> canvas:Canvas=<span style="color: #0066CC;">e</span>.<span style="color: #0066CC;">target</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0066CC;">stopDrag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _stage.<span style="color: #006600;">removeEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, onMouseDragMove<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> onMouseDragMove<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 />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; calculaDist<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mueveVisorZona<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; controlaPosiciones<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//-------------------------------------------------------------</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> calculaDist<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: #000000; font-weight: bold;">var</span> drag:Canvas=_panelZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"zoomDrag"</span><span style="color: #66cc66;">&#41;</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> foto:Image=_fotoZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span> as Image;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _porcentajeX=<span style="color: #cc66cc;">100</span> / <span style="color: #66cc66;">&#40;</span>foto.<span style="color: #0066CC;">width</span> / _panelZoom.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _porcentajeY=<span style="color: #cc66cc;">100</span> / <span style="color: #66cc66;">&#40;</span>foto.<span style="color: #0066CC;">height</span> / _panelZoom.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drag.<span style="color: #0066CC;">width</span>=_fotoZoom.<span style="color: #0066CC;">width</span> * _porcentajeX / <span style="color: #cc66cc;">100</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; drag.<span style="color: #0066CC;">height</span>=_fotoZoom.<span style="color: #0066CC;">height</span> * _porcentajeY / <span style="color: #cc66cc;">100</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distX=drag.<span style="color: #006600;">x</span> * <span style="color: #cc66cc;">100</span> / _porcentajeX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distY=drag.<span style="color: #006600;">y</span> * <span style="color: #cc66cc;">100</span> / _porcentajeY;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distX=<span style="color: #66cc66;">&#40;</span>_distX &lt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #cc66cc;">0</span> : _distX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distY=<span style="color: #66cc66;">&#40;</span>_distY &lt;<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #cc66cc;">0</span> : _distY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mueveVisorZona<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: #000000; font-weight: bold;">var</span> drag:Canvas=_panelZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"zoomDrag"</span><span style="color: #66cc66;">&#41;</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> foto:Image=_fotoZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span> as Image;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foto.<span style="color: #006600;">x</span>=-_distX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foto.<span style="color: #006600;">y</span>=-_distY;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> controlaPosiciones<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: #000000; font-weight: bold;">var</span> drag:Canvas=_panelZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"zoomDrag"</span><span style="color: #66cc66;">&#41;</span> as Canvas;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> foto:Image=_fotoZoom.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span> as Image;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>drag.<span style="color: #006600;">x</span> &lt;<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; drag.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">0</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>drag.<span style="color: #006600;">x</span>&gt; _panelZoom.<span style="color: #0066CC;">width</span> - drag.<span style="color: #0066CC;">width</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; drag.<span style="color: #006600;">x</span>=_panelZoom.<span style="color: #0066CC;">width</span> - drag.<span style="color: #0066CC;">width</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>drag.<span style="color: #006600;">y</span> &lt;_panelZoom.<span style="color: #006600;">y</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; drag.<span style="color: #006600;">y</span>=_panelZoom.<span style="color: #006600;">y</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>drag.<span style="color: #006600;">y</span>&gt; _panelZoom.<span style="color: #006600;">y</span> + _panelZoom.<span style="color: #0066CC;">height</span> - drag.<span style="color: #0066CC;">height</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; drag.<span style="color: #006600;">y</span>=_panelZoom.<span style="color: #006600;">y</span> + _panelZoom.<span style="color: #0066CC;">height</span> - drag.<span style="color: #0066CC;">height</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>foto.<span style="color: #006600;">x</span>&gt; <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; foto.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">0</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>foto.<span style="color: #006600;">x</span> &lt;_fotoZoom.<span style="color: #0066CC;">width</span> - foto.<span style="color: #0066CC;">width</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; foto.<span style="color: #006600;">x</span>=_fotoZoom.<span style="color: #0066CC;">width</span> - foto.<span style="color: #0066CC;">width</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>foto.<span style="color: #006600;">y</span>&gt; <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; foto.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">0</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>foto.<span style="color: #006600;">y</span> &lt;_fotoZoom.<span style="color: #0066CC;">height</span> - foto.<span style="color: #0066CC;">height</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; foto.<span style="color: #006600;">y</span>=_fotoZoom.<span style="color: #0066CC;">height</span> - foto.<span style="color: #0066CC;">height</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></p>
<p>&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%2Fpanel-de-zoom-de-imagenes-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=Panel%20de%20zoom%20de%20im%C3%A1genes%20en%20Flex%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fpanel-de-zoom-de-imagenes-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%2Fpanel-de-zoom-de-imagenes-en-flex%2F&amp;t=Panel%20de%20zoom%20de%20im%C3%A1genes%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.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fpanel-de-zoom-de-imagenes-en-flex%2F&amp;title=Panel%20de%20zoom%20de%20im%C3%A1genes%20en%20Flex&amp;annotation=Este%20ejemplo%20es%2C%20igual%20que%20hice%20en%20el%20post%20anterior%2C%20un%20ejemplo%20que%20he%20adaptado%20a%20Flex%20desde%20un%20ejemplo%20que%20hice%20hace%20tiempo%20para%20Flash.%20Se%20trata%20de%20un%20panel%20donde%20se%20ve%20un%20zoom%20de%20una%20parte%20de%20una%20imagen.%0D%0A%0D%0AEste%20es%20el%20ejemplo%20montado%20en%20Flex%3A%0D%0A%0D%0A%09%0D" 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%2Fpanel-de-zoom-de-imagenes-en-flex%2F&amp;title=Panel%20de%20zoom%20de%20im%C3%A1genes%20en%20Flex&amp;notes=Este%20ejemplo%20es%2C%20igual%20que%20hice%20en%20el%20post%20anterior%2C%20un%20ejemplo%20que%20he%20adaptado%20a%20Flex%20desde%20un%20ejemplo%20que%20hice%20hace%20tiempo%20para%20Flash.%20Se%20trata%20de%20un%20panel%20donde%20se%20ve%20un%20zoom%20de%20una%20parte%20de%20una%20imagen.%0D%0A%0D%0AEste%20es%20el%20ejemplo%20montado%20en%20Flex%3A%0D%0A%0D%0A%09%0D" 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%2Fpanel-de-zoom-de-imagenes-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=Panel%20de%20zoom%20de%20im%C3%A1genes%20en%20Flex&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fpanel-de-zoom-de-imagenes-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%2Fpanel-de-zoom-de-imagenes-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/ejemplo-de-zoom-con-lupa-en-flex/' rel='bookmark' title='Permanent Link: Ejemplo de Zoom con lupa en Flex'>Ejemplo de Zoom con lupa en Flex</a></li>
<li><a href='http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-actionscript-3/' rel='bookmark' title='Permanent Link: Panel de zoom de imágenes en ActionScript 3'>Panel de zoom de imágenes en ActionScript 3</a></li>
<li><a href='http://www.codigoactionscript.org/drag-and-drop-en-as3/' rel='bookmark' title='Permanent Link: Drag and Drop en AS3'>Drag and Drop en AS3</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/panel-de-zoom-de-imagenes-en-flex/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ejemplo de Zoom con lupa en Flex</title>
		<link>http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flex/</link>
		<comments>http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flex/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 02:46:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Básico]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[mascara]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=379</guid>
		<description><![CDATA[<p>Hace un tiempo escribí un ejemplo de zoom sobre una imagen con Flash. Justo ahora me acaban de preguntar como adaptar ese ejemplo a una aplicación Flex.</p>
<p>Adaptar ese ejemplo es fácil, ya que el código actionscript se puede reutilizar prácticamente igual. Lo único que hay que tener en cuenta es que no vamos a trabajar con un MovieClip con una máscara sino con componentes mxml de Flex.</p>
<p>Así es como quedará el ejemplo montado en Flex:</p>

Desplaza el mouse sobre la imagen para mover la lupa
<p></p>
<p>Esta seria nuestra aplicación Flex:</p>



&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application [...]


Related posts:<ol><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/ejemplo-de-zoom-con-lupa-en-flash-cs3/' rel='bookmark' title='Permanent Link: Ejemplo de Zoom con lupa en Flash CS3'>Ejemplo de Zoom con lupa en Flash CS3</a></li>
<li><a href='http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/' rel='bookmark' title='Permanent Link: Personalizar componentes de Flex con estilos programáticos'>Personalizar componentes de Flex con estilos programáticos</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Hace un tiempo escribí un ejemplo de <a href="http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flash-cs3/">zoom sobre una imagen con Flash</a>. Justo ahora me acaban de preguntar como adaptar ese ejemplo a una aplicación <strong>Flex</strong>.</p>
<p>Adaptar ese ejemplo es fácil, ya que el código actionscript se puede reutilizar prácticamente igual. Lo único que hay que tener en cuenta es que no vamos a trabajar con un MovieClip con una máscara sino con componentes mxml de Flex.</p>
<p>Así es como quedará el ejemplo montado en Flex:</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="350" height="225"><param name="movie" value="http://www.codigoactionscript.org/files/EfectoLupaFlex/EfectoLupa.swf" /><param name="quality" value="high" /><embed src="http://www.codigoactionscript.org/files/EfectoLupaFlex/EfectoLupa.swf" width="350" height="225" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object><br />
<em>Desplaza el mouse sobre la imagen para mover la lupa</em></div>
<p><br/><br/></p>
<p>Esta seria nuestra aplicación Flex:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-19">
<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><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout=<span style="color: #ff0000;">"absolute"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns:ui=<span style="color: #ff0000;">"*"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; creationComplete=<span style="color: #ff0000;">"ini()"</span>&gt;</p>
<p>&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;">import</span> LupaFx;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _lupa:LupaFx;<br />
&nbsp; &nbsp; &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; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _lupa=<span style="color: #000000; font-weight: bold;">new</span> LupaFx<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span>, foto, lupa<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:Image&nbsp; id=<span style="color: #ff0000;">"foto"</span> scaleContent=<span style="color: #ff0000;">"true"</span> horizontalCenter=<span style="color: #ff0000;">"0"</span> verticalCenter=<span style="color: #ff0000;">"0"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"350"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"250"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:source&gt;img/Waterfall.<span style="color: #006600;">jpg</span>&lt;/mx:source&gt;<br />
&nbsp; &nbsp; &lt;/mx:Image&gt;</p>
<p>&nbsp; &nbsp; &lt;ui:Lupa id=<span style="color: #ff0000;">"lupa"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;x=<span style="color: #ff0000;">"0"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;y=<span style="color: #ff0000;">"0"</span>/&gt;</p>
<p>&lt;/mx:Application&gt;</p></div>
</div>
</div>
</div>
<p></p>
<p>El componente que utilizaremos como lupa:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-20">
<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:Canvas xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100"</span> borderStyle=<span style="color: #ff0000;">"solid"</span> borderThickness=<span style="color: #ff0000;">"4"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#FF0000"</span> horizontalScrollPolicy=<span style="color: #ff0000;">"off"</span> verticalScrollPolicy=<span style="color: #ff0000;">"off"</span>&gt;<br />
&nbsp; &nbsp; &lt;mx:Image id=<span style="color: #ff0000;">"foto"</span> scaleContent=<span style="color: #ff0000;">"false"</span> y=<span style="color: #ff0000;">"0"</span> x=<span style="color: #ff0000;">"0"</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:source&gt;img/Waterfall.<span style="color: #006600;">jpg</span>&lt;/mx:source&gt;<br />
&nbsp; &nbsp; &lt;/mx:Image&gt;</p>
<p>&lt;/mx:Canvas&gt;</p></div>
</div>
</div>
</div>
<p></p>
<p>Y la clase de actionscript que controlará el efecto:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-21">
<div class="actionscript">package<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">MouseEvent</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;</p>
<p>&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LupaFx<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _stage:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _foto:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _lupa:UIComponent;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _distX:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _distY:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _porcentajeX:<span style="color: #0066CC;">Number</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _porcentajeY:<span style="color: #0066CC;">Number</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> LupaFx<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">stage</span>:UIComponent, foto:UIComponent, lupa:UIComponent<span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _stage=<span style="color: #0066CC;">stage</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _foto=foto;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _lupa=lupa;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">stage</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">MOUSE_MOVE</span>, lupaMouseMove<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lupaMouseMove<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;">private</span> <span style="color: #000000; font-weight: bold;">function</span> lupaMouseMove<span style="color: #66cc66;">&#40;</span>event:MouseEvent=<span style="color: #000000; font-weight: bold;">null</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; calculaDist<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mueveLupa<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _lupa.<span style="color: #006600;">x</span>=_foto.<span style="color: #006600;">mouseX</span> + _foto.<span style="color: #006600;">x</span> - _lupa.<span style="color: #0066CC;">width</span> / <span style="color: #cc66cc;">2</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _lupa.<span style="color: #006600;">y</span>=_foto.<span style="color: #006600;">mouseY</span> + _foto.<span style="color: #006600;">y</span> - _lupa.<span style="color: #0066CC;">height</span> / <span style="color: #cc66cc;">2</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">x</span> &lt;_foto.<span style="color: #006600;">x</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; _lupa.<span style="color: #006600;">x</span>=_foto.<span style="color: #006600;">x</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">x</span>&gt; _foto.<span style="color: #006600;">x</span> + _foto.<span style="color: #0066CC;">width</span> - _lupa.<span style="color: #0066CC;">width</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; _lupa.<span style="color: #006600;">x</span>=_foto.<span style="color: #006600;">x</span> + _foto.<span style="color: #0066CC;">width</span> - _lupa.<span style="color: #0066CC;">width</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>_lupa.<span style="color: #006600;">y</span> &lt;_foto.<span style="color: #006600;">y</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; _lupa.<span style="color: #006600;">y</span>=_foto.<span style="color: #006600;">y</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;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">y</span>&gt; _foto.<span style="color: #006600;">y</span> + _foto.<span style="color: #0066CC;">height</span> - _lupa.<span style="color: #0066CC;">height</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; _lupa.<span style="color: #006600;">y</span>=_foto.<span style="color: #006600;">y</span> + _foto.<span style="color: #0066CC;">height</span> - _lupa.<span style="color: #0066CC;">height</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; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> calculaDist<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; _porcentajeX=<span style="color: #cc66cc;">100</span> / <span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">width</span> / <span style="color: #66cc66;">&#40;</span>_foto.<span style="color: #0066CC;">width</span> - _lupa.<span style="color: #0066CC;">width</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _porcentajeY=<span style="color: #cc66cc;">100</span> / <span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">height</span> / <span style="color: #66cc66;">&#40;</span>_foto.<span style="color: #0066CC;">height</span> - _lupa.<span style="color: #0066CC;">height</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distX=<span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">x</span> - _foto.<span style="color: #006600;">x</span><span style="color: #66cc66;">&#41;</span> / _porcentajeX * <span style="color: #cc66cc;">100</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _distY=<span style="color: #66cc66;">&#40;</span>_lupa.<span style="color: #006600;">y</span> - _foto.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span> / _porcentajeY * <span style="color: #cc66cc;">100</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;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mueveLupa<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; _lupa.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">x</span>=-_distX;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _lupa.<span style="color: #006600;">getChildByName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"foto"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">y</span>=-_distY;<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 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%2Fejemplo-de-zoom-con-lupa-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=Ejemplo%20de%20Zoom%20con%20lupa%20en%20Flex%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fejemplo-de-zoom-con-lupa-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%2Fejemplo-de-zoom-con-lupa-en-flex%2F&amp;t=Ejemplo%20de%20Zoom%20con%20lupa%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.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fejemplo-de-zoom-con-lupa-en-flex%2F&amp;title=Ejemplo%20de%20Zoom%20con%20lupa%20en%20Flex&amp;annotation=Hace%20un%20tiempo%20escrib%C3%AD%20un%20ejemplo%20de%20zoom%20sobre%20una%20imagen%20con%20Flash.%20Justo%20ahora%20me%20acaban%20de%20preguntar%20como%20adaptar%20ese%20ejemplo%20a%20una%20aplicaci%C3%B3n%20Flex.%0D%0A%0D%0AAdaptar%20ese%20ejemplo%20es%20f%C3%A1cil%2C%20ya%20que%20el%20c%C3%B3digo%20actionscript%20se%20puede%20reutilizar%20pr%C3%A1cticam" 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%2Fejemplo-de-zoom-con-lupa-en-flex%2F&amp;title=Ejemplo%20de%20Zoom%20con%20lupa%20en%20Flex&amp;notes=Hace%20un%20tiempo%20escrib%C3%AD%20un%20ejemplo%20de%20zoom%20sobre%20una%20imagen%20con%20Flash.%20Justo%20ahora%20me%20acaban%20de%20preguntar%20como%20adaptar%20ese%20ejemplo%20a%20una%20aplicaci%C3%B3n%20Flex.%0D%0A%0D%0AAdaptar%20ese%20ejemplo%20es%20f%C3%A1cil%2C%20ya%20que%20el%20c%C3%B3digo%20actionscript%20se%20puede%20reutilizar%20pr%C3%A1cticam" 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%2Fejemplo-de-zoom-con-lupa-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=Ejemplo%20de%20Zoom%20con%20lupa%20en%20Flex&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fejemplo-de-zoom-con-lupa-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%2Fejemplo-de-zoom-con-lupa-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/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/ejemplo-de-zoom-con-lupa-en-flash-cs3/' rel='bookmark' title='Permanent Link: Ejemplo de Zoom con lupa en Flash CS3'>Ejemplo de Zoom con lupa en Flash CS3</a></li>
<li><a href='http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/' rel='bookmark' title='Permanent Link: Personalizar componentes de Flex con estilos programáticos'>Personalizar componentes de Flex con estilos programáticos</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/ejemplo-de-zoom-con-lupa-en-flex/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Acceder a los itemRenderer de un componente lista en Flex</title>
		<link>http://www.codigoactionscript.org/acceder-a-los-itemrenderer-de-un-componente-lista-en-flex/</link>
		<comments>http://www.codigoactionscript.org/acceder-a-los-itemrenderer-de-un-componente-lista-en-flex/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 03:45:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Básico]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[DataProvider]]></category>
		<category><![CDATA[itemRenderer]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=361</guid>
		<description><![CDATA[<p>Este es un tip sencillo pero que me dió algún que otro dolor de cabeza al querer aplicar unos efectos sobre los componentes utilizados como itemRenderes dentro de un componente tipo lista en Flex. Se trata de cómo poder acceder a estos componentes para manipular su contenido a través de Actionscript.</p>
<p>Para acceder al componente del itemRenderer en concreto utilizaremos indexToItemRenderer, pasándole como parámetro el index del ítem que queremos obtener.</p>
<p>El detalle importante que debemos tener en cuenta es que no podemos referenciar un objeto que no sea visible dentro de [...]


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/cargar-xml-en-un-componente-list-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cargar XML en un componente List en Actionscript 3'>Cargar XML en un componente List en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/error-de-seleccion-de-color-en-el-componente-richtexteditor-de-flex/' rel='bookmark' title='Permanent Link: Error de selección de color en el componente RichTextEditor de Flex'>Error de selección de color en el componente RichTextEditor de Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Este es un <a href="http://www.cristalab.com/tip">tip</a> sencillo pero que me dió algún que otro dolor de cabeza al querer aplicar unos efectos sobre los componentes utilizados como <strong>itemRenderes </strong>dentro de un componente tipo lista en <a href="http://www.cristalab.com/tips/tags/flex">Flex</a>. Se trata de cómo poder acceder a estos componentes para manipular su contenido a través de <a href="http://www.cristalab.com/tips/tags/actionscript_3">Actionscript</a>.</p>
<p>Para acceder al componente del itemRenderer en concreto utilizaremos <strong>indexToItemRenderer</strong>, pasándole como parámetro el index del ítem que queremos obtener.</p>
<p>El detalle importante que debemos tener en cuenta es que no podemos referenciar un objeto que no sea visible dentro de la zona del scroll, ya que hasta entonces devolvería valor <em>null</em>. Para ello deveremos realizar la comprobación con <strong>isItemVisible</strong>, y ejecutar las acciones solo sobre los componentes visibles.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-24">
<div class="actionscript"><span style="color: #000000; font-weight: bold;">var</span> total:uint = tileList.<span style="color: #006600;">dataProvider</span>.<span style="color: #0066CC;">length</span>;<br />
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:uint = <span style="color: #cc66cc;">0</span>; i &lt;total; i++<span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>tileList.<span style="color: #006600;">isItemVisible</span><span style="color: #66cc66;">&#40;</span>tileList.<span style="color: #006600;">dataProvider</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> item:<span style="color: #0066CC;">Object</span> = tileList.<span style="color: #006600;">indexToItemRenderer</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// resto de implementación sobre los componentes</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%2Facceder-a-los-itemrenderer-de-un-componente-lista-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=Acceder%20a%20los%20itemRenderer%20de%20un%20componente%20lista%20en%20Flex%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-los-itemrenderer-de-un-componente-lista-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%2Facceder-a-los-itemrenderer-de-un-componente-lista-en-flex%2F&amp;t=Acceder%20a%20los%20itemRenderer%20de%20un%20componente%20lista%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.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-los-itemrenderer-de-un-componente-lista-en-flex%2F&amp;title=Acceder%20a%20los%20itemRenderer%20de%20un%20componente%20lista%20en%20Flex&amp;annotation=Este%20es%20un%20%20sencillo%20pero%20que%20me%20di%C3%B3%20alg%C3%BAn%20que%20otro%20dolor%20de%20cabeza%20al%20querer%20aplicar%20unos%20efectos%20sobre%20los%20componentes%20utilizados%20como%20dentro%20de%20un%20componente%20tipo%20lista%20en%20.%20Se%20trata%20de%20c%C3%B3mo%20poder%20acceder%20a%20estos%20componentes%20para%20manipular%20su%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%2Facceder-a-los-itemrenderer-de-un-componente-lista-en-flex%2F&amp;title=Acceder%20a%20los%20itemRenderer%20de%20un%20componente%20lista%20en%20Flex&amp;notes=Este%20es%20un%20%20sencillo%20pero%20que%20me%20di%C3%B3%20alg%C3%BAn%20que%20otro%20dolor%20de%20cabeza%20al%20querer%20aplicar%20unos%20efectos%20sobre%20los%20componentes%20utilizados%20como%20dentro%20de%20un%20componente%20tipo%20lista%20en%20.%20Se%20trata%20de%20c%C3%B3mo%20poder%20acceder%20a%20estos%20componentes%20para%20manipular%20su%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%2Facceder-a-los-itemrenderer-de-un-componente-lista-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=Acceder%20a%20los%20itemRenderer%20de%20un%20componente%20lista%20en%20Flex&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Facceder-a-los-itemrenderer-de-un-componente-lista-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%2Facceder-a-los-itemrenderer-de-un-componente-lista-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/cargar-xml-en-un-componente-list-en-actionscript-3/' rel='bookmark' title='Permanent Link: Cargar XML en un componente List en Actionscript 3'>Cargar XML en un componente List en Actionscript 3</a></li>
<li><a href='http://www.codigoactionscript.org/error-de-seleccion-de-color-en-el-componente-richtexteditor-de-flex/' rel='bookmark' title='Permanent Link: Error de selección de color en el componente RichTextEditor de Flex'>Error de selección de color en el componente RichTextEditor de Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/acceder-a-los-itemrenderer-de-un-componente-lista-en-flex/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mostrar una alerta antes del cierre de una aplicación AIR</title>
		<link>http://www.codigoactionscript.org/mostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air/</link>
		<comments>http://www.codigoactionscript.org/mostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 01:59:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Básico]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[componente]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=322</guid>
		<description><![CDATA[<p>En este ejemplo mostraré como crear una ventana de alerta cuando le demos al botón de cerrar en una aplicación AIR, teniendo que validar el cierre evitando que se cierre directamente. De esta manera podemos controlar que el usuario cierre la aplicación si haber realizado una operación necesaria, por ejemplo guardar los cambios realizados en el caso de tratarse de una a aplicación que edite documentos.</p>

<p>Lo primero que deberemos hacer es colocar la función a realizar cuando se detecte el evento de cierre de la aplicación (osea, cuando el usuario [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/como-personalizar-el-icono-del-panel-de-alerta-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar el icono del panel de Alerta de Flex'>Cómo personalizar el icono del panel de Alerta de Flex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>En este ejemplo mostraré como crear una ventana de alerta cuando le demos al botón de cerrar en una aplicación AIR, teniendo que validar el cierre evitando que se cierre directamente. De esta manera podemos controlar que el usuario cierre la aplicación si haber realizado una operación necesaria, por ejemplo guardar los cambios realizados en el caso de tratarse de una a aplicación que edite documentos.</p>
<div align="center"><img src="http://www.cristalab.com/images/tips/flex/cerrarAlert/cap_005.png" alt="" /></div>
<p>Lo primero que deberemos hacer es colocar la función a realizar cuando se detecte el evento de cierre de la aplicación (osea, cuando el usuario cierra la aplicación).</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-37">
<div class="actionscript">&lt;mx:WindowedApplication xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> layout=<span style="color: #ff0000;">"absolute"</span> closing=<span style="color: #ff0000;">"cerrarApp(event)"</span>&gt;</div>
</div>
</div>
</div>
<p></p>
<p>Ahora escribiremos la función. El punto importante aquí es como evitar el cierre de la aplicación, ya que el usuario realmente a clicado en el botón de cerrar. Esto lo conseguimos con el método <strong>preventDefault()</strong> de la clase Event. Con este método conseguimos que el evento no ejecute las funciones por defecto y por lo tanto no se cierra la aplicación. Lo que haremos en su lugar es abrir una ventana de <strong>Alert</strong>.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-38">
<div class="actionscript"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> cerrarApp<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 />
&nbsp; &nbsp; <span style="color: #0066CC;">e</span>.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Alert.<span style="color: #006600;">yesLabel</span> = <span style="color: #ff0000;">"Si"</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"¿Realmente quiere salir?"</span>,<span style="color: #ff0000;">"Salir aplicación"</span>, Alert.<span style="color: #006600;">YES</span> | Alert.<span style="color: #006600;">NO</span>, <span style="color: #000000; font-weight: bold;">null</span>, cerrar, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<div align="center"><img src="http://www.cristalab.com/images/tips/flex/cerrarAlert/cap_007.png" alt="" /></div>
<p>Con <strong>yesLabel  </strong>decimos que aparezca el texto "Si" en el botón de validar en lugar de "Yes". Y con el <strong>2</strong> al final de los parámetros decimos que el botón seleccionado por defecto sea el segundo, osea el "No".</p>
<p>También le estamos indicando que al clicar sobre cualquiera de los botones se ejecute la función "<strong>cerrar</strong>" que es la siguiente:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-39">
<div class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> cerrar<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:CloseEvent<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: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">detail</span> == Alert.<span style="color: #006600;">YES</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Donde le estamos indicando que si el botón seleccionado es el "Si" entonces cierre la aplicación. En el caso de seleccionar el "No" no se ejecuta nada y por lo tanto la aplicación sigue abierta.</p>
<p>[h3]Segundo ejemplo[/h3]</p>
<p>El código anterior se ejecutaría siempre que le demos al icono de cerrar aplicación. Pero lo interesante es poder controlar cuando queremos mostrar esa advertencia. </p>
<p>Por ejemplo en el caso de tener una aplicación que sea un editor de texto. Si le damos al botón de cerrar la aplicación teniendo cambios sin guardar mostraremos el Alert, pero en el caso de haber guardado los cambios previamente cerraremos directamente la aplicación.</p>
<p>Primero crearemos una variable booleana que controlará si la aplicación se cierra automáticamente o requiere mostrar la advertencia.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-40">
<div class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> cierre:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</div>
</div>
</div>
<p></p>
<p>En la función que se ejecuta al cerrar la aplicación colocaremos un condicional que detecte el estado de esa variable. </p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-41">
<div class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> cerrarApp<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 />
&nbsp; &nbsp; <span style="color: #0066CC;">e</span>.<span style="color: #006600;">preventDefault</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>cierre == <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #006600;">yesLabel</span> = <span style="color: #ff0000;">"Si"</span>;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"¿Desea guardar los cambios antes de salir?"</span>,<span style="color: #ff0000;">"Salir aplicación"</span>, Alert.<span style="color: #006600;">YES</span> | Alert.<span style="color: #006600;">NO</span> | Alert.<span style="color: #006600;">CANCEL</span>, <span style="color: #000000; font-weight: bold;">null</span>, cerrar, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<div align="center"><img src="http://www.cristalab.com/images/tips/flex/cerrarAlert/cap_009.png" alt="" /></div>
<p>Lógicamente esa función "<strong>cierre</strong>" la deberemos controlar con el resto de funciones de la aplicación. Es decir, todas las funciones que realicen <strong>cualquier cambio que deba ser guardado</strong> deberán colocar esa variable a "<strong>false</strong>", y la función que realice el <strong>guardado de datos</strong> deberá colocar la variable a "<strong>true</strong>".</p>
<p>La función de cierre quedaría asi:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-42">
<div class="actionscript"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> cerrar<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:CloseEvent<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: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">detail</span> == Alert.<span style="color: #006600;">YES</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; guardarDatos<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>.<span style="color: #006600;">detail</span> == Alert.<span style="color: #006600;">NO</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">nativeApplication</span>.<span style="color: #006600;">exit</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>De manera que si clicamos "Si" ejecutaríamos la función que nos guarda los datos y cerraríamos después la aplicación, si clisásemos "No" cerraríamos directamente y si clisásemos "Cancel" entonces no se ejecutaría nada y no cerraríamos la aplicación.</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%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%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=Mostrar%20una%20alerta%20antes%20del%20cierre%20de%20una%20aplicaci%C3%B3n%20AIR%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%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%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%2F&amp;t=Mostrar%20una%20alerta%20antes%20del%20cierre%20de%20una%20aplicaci%C3%B3n%20AIR" 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.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%2F&amp;title=Mostrar%20una%20alerta%20antes%20del%20cierre%20de%20una%20aplicaci%C3%B3n%20AIR&amp;annotation=En%20este%20ejemplo%20mostrar%C3%A9%20como%20crear%20una%20ventana%20de%20alerta%20cuando%20le%20demos%20al%20bot%C3%B3n%20de%20cerrar%20en%20una%20aplicaci%C3%B3n%20AIR%2C%20teniendo%20que%20validar%20el%20cierre%20evitando%20que%20se%20cierre%20directamente.%20De%20esta%20manera%20podemos%20controlar%20que%20el%20usuario%20cierre%20la%20aplic" 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%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%2F&amp;title=Mostrar%20una%20alerta%20antes%20del%20cierre%20de%20una%20aplicaci%C3%B3n%20AIR&amp;notes=En%20este%20ejemplo%20mostrar%C3%A9%20como%20crear%20una%20ventana%20de%20alerta%20cuando%20le%20demos%20al%20bot%C3%B3n%20de%20cerrar%20en%20una%20aplicaci%C3%B3n%20AIR%2C%20teniendo%20que%20validar%20el%20cierre%20evitando%20que%20se%20cierre%20directamente.%20De%20esta%20manera%20podemos%20controlar%20que%20el%20usuario%20cierre%20la%20aplic" 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%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%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=Mostrar%20una%20alerta%20antes%20del%20cierre%20de%20una%20aplicaci%C3%B3n%20AIR&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%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%2Fmostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air%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-personalizar-el-icono-del-panel-de-alerta-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar el icono del panel de Alerta de Flex'>Cómo personalizar el icono del panel de Alerta de Flex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.codigoactionscript.org/mostrar-una-alerta-antes-del-cierre-de-una-aplicacion-air/feed/</wfw:commentRss>
		<slash:comments>1</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.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>12</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-72">
<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-73">
<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-74">
<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-75">
<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.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>Personalizar botones de aplicaciones Flex con Actionscript</title>
		<link>http://www.codigoactionscript.org/personalizar-botones-de-aplicaciones-flex-con-actionscript/</link>
		<comments>http://www.codigoactionscript.org/personalizar-botones-de-aplicaciones-flex-con-actionscript/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 23:41:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[componente]]></category>

		<guid isPermaLink="false">http://www.codigoactionscript.org/?p=258</guid>
		<description><![CDATA[<p>Este tip es una continuación a tip escrito por Mx en Cristalab sobre como personalizar botones (y componentes en general) de Flex.</p>
<p>En ese tip, se muestra como podemos utilizar gráficos de Photoshop para sustituir los gráficos estándar del componente. Ella mostró la forma de hacerlo desde los menús de Flex Builder y el resultado de ese proceso es la generación de un archivo CSS como, por ejemplo, este:</p>



Button &#123;
&#160; &#160; upSkin: Embed&#40;"img/ico1.png"&#41;;
&#160; &#160; overSkin: Embed&#40;"img/ico2.png"&#41;;
&#160; &#160; downSkin: Embed&#40;"img/ico3.png"&#41;;
&#160; &#160; disableSkin: Embed&#40;"img/ico4.png"&#41;;
&#125;



<p></p>
<p>Con esto cambiaremos el aspecto de TODOS los componentes botón [...]


Related posts:<ol><li><a href='http://www.codigoactionscript.org/personalizar-componentes-de-flex-con-estilos-programaticos/' rel='bookmark' title='Permanent Link: Personalizar componentes de Flex con estilos programáticos'>Personalizar componentes de Flex con estilos programáticos</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-el-icono-del-panel-de-alerta-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar el icono del panel de Alerta de Flex'>Cómo personalizar el icono del panel de Alerta de 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>Este <a href="http://www.cristalab.com/tips">tip</a> es una continuación a tip escrito por <a href="http://www.cristalab.com/usuario/2122-mariux">Mx</a> en <a href="http://www.cristalab.com">Cristalab</a> sobre como <a href="http://www.cristalab.com/tips/65839/flex-y-disenadores-importar-diseno-desde-photoshop-a-flex.html">personalizar botones (y componentes en general) de Flex</a>.</p>
<p>En ese tip, se muestra como podemos utilizar gráficos de <a href="http://www.cristalab.com/tips/tags/photoshop">Photoshop</a> para sustituir los gráficos estándar del componente. Ella mostró la forma de hacerlo desde los menús de <a href="http://www.cristalab.com/tutoriales/216/tutorial-de-flex-builder-2.html">Flex Builder</a> y el resultado de ese proceso es la generación de un archivo <a href="http://www.cristalab.com/tips/tags/css">CSS</a> como, por ejemplo, este:</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-80">
<div class="actionscript"><span style="color: #0066CC;">Button</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; upSkin: Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico1.png"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; overSkin: Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico2.png"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; downSkin: Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico3.png"</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; disableSkin: Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico4.png"</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
</div>
<p></p>
<p>Con esto cambiaremos el aspecto de <strong>TODOS los componentes botón</strong> de nuestra aplicación. Pero.. <strong>¿que pasa si queremos cambiar el aspecto de un botón en concreto?</strong> por ejemplo para un botón de "<em>Play</em>" o de "<em>Stop</em>" en un reproductor de vídeo.</p>
<p>Para hacer eso, podemos asignar otro "estilo" a ese botón en concreto a través de <a href="http://www.cristalab.com/tips/tags/actionscript">actionscritp</a>.</p>
<p>Para ello abriremos un tag <em><mx:Script></em> y ahí incrustaremos los gráficos dentro de variables tipo <em>Class</em>, y asignaremos el nuevo estilo al botón a través de <em>setStyle()</em>.</p>
<div id="codigo">
<div class="syntax_hilite">
<div id="actionscript-81">
<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: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico2_1.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><br />
&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>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico2_2.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><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>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico2_3.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><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>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Embed<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"img/ico2_4.png"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><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>;<br />
&nbsp; &nbsp; &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>De esta manera, todos los componentes botón tendrán el estilo definido desde el archivo CSS menos nuestro botón "boton1" que tendrá el estilo definido en el actionscript.</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-botones-de-aplicaciones-flex-con-actionscript%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%20botones%20de%20aplicaciones%20Flex%20con%20Actionscript%20-%20http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-botones-de-aplicaciones-flex-con-actionscript%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-botones-de-aplicaciones-flex-con-actionscript%2F&amp;t=Personalizar%20botones%20de%20aplicaciones%20Flex%20con%20Actionscript" 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.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-botones-de-aplicaciones-flex-con-actionscript%2F&amp;title=Personalizar%20botones%20de%20aplicaciones%20Flex%20con%20Actionscript&amp;annotation=Este%20%20es%20una%20continuaci%C3%B3n%20a%20tip%20escrito%20por%20%20en%20Cristalab%20sobre%20como%20personalizar%20botones%20%28y%20componentes%20en%20general%29%20de%20Flex.%0D%0A%0D%0AEn%20ese%20tip%2C%20se%20muestra%20como%20podemos%20utilizar%20gr%C3%A1ficos%20de%20%20para%20sustituir%20los%20gr%C3%A1ficos%20est%C3%A1ndar%20del%20componente.%20Ella%20m" 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-botones-de-aplicaciones-flex-con-actionscript%2F&amp;title=Personalizar%20botones%20de%20aplicaciones%20Flex%20con%20Actionscript&amp;notes=Este%20%20es%20una%20continuaci%C3%B3n%20a%20tip%20escrito%20por%20%20en%20Cristalab%20sobre%20como%20personalizar%20botones%20%28y%20componentes%20en%20general%29%20de%20Flex.%0D%0A%0D%0AEn%20ese%20tip%2C%20se%20muestra%20como%20podemos%20utilizar%20gr%C3%A1ficos%20de%20%20para%20sustituir%20los%20gr%C3%A1ficos%20est%C3%A1ndar%20del%20componente.%20Ella%20m" 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-botones-de-aplicaciones-flex-con-actionscript%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%20botones%20de%20aplicaciones%20Flex%20con%20Actionscript&amp;body=http%3A%2F%2Fwww.codigoactionscript.org%2Fpersonalizar-botones-de-aplicaciones-flex-con-actionscript%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-botones-de-aplicaciones-flex-con-actionscript%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-componentes-de-flex-con-estilos-programaticos/' rel='bookmark' title='Permanent Link: Personalizar componentes de Flex con estilos programáticos'>Personalizar componentes de Flex con estilos programáticos</a></li>
<li><a href='http://www.codigoactionscript.org/como-personalizar-el-icono-del-panel-de-alerta-de-flex/' rel='bookmark' title='Permanent Link: Cómo personalizar el icono del panel de Alerta de Flex'>Cómo personalizar el icono del panel de Alerta de 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-botones-de-aplicaciones-flex-con-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</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-86">
<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-87">
<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.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>
	</channel>
</rss>
