<?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>Código Metrópoli &#187; AIR</title>
	<atom:link href="http://www.codigometropoli.com/category/air/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codigometropoli.com</link>
	<description>Programación para Super Héroes</description>
	<lastBuildDate>Tue, 08 Jun 2010 00:30:52 +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>Sistema de Clientes (AIR y SQLite) Parte IV (Consulta a la base de datos)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 05:30:04 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=350</guid>
		<description><![CDATA[Esta es la cuarta y última parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo modificar y eliminar registros en la base de datos (clientesDB.sqlite) desde nuestra aplicación en AIR.

En esta ocasión veremos cómo realizar consultas de los registros en la [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la cuarta y última parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-iii/" target="_blank">entrada</a> anterior vimos cómo modificar y eliminar registros en la base de datos (<em>clientesDB.sqlite</em>) desde nuestra aplicación en AIR.</p>
<p><span id="more-350"></span></p>
<p>En esta ocasión veremos cómo realizar consultas de los registros en la base de datos; para esto crearemos una forma en la cual el usuario puede introducir el nombre, teléfono o correo del cliente que está buscando. Los resultados de esta consulta los escribiremos en un archivo HTML y lo mostraremos dentro del componente <strong>HTML </strong>(aprovechando el <a href="http://www.codigometropoli.com/crear-archivo-en-air-con-flex-builder-3/" target="_blank">post</a> que publiqué hace ya tiempo sobre cómo crear un archivo en AIR).</p>
<p><span style="color: #ff0000;"><strong>Parte 4: Consulta a la base de datos en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta actionscript. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 255px"><img title="Imagen 1: Estructura de la aplicación" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1: Estructura de la aplicación" width="245" height="373" />
<p class="wp-caption-text">Imagen 1: Estructura de la aplicación</p>
</div>
</div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta <em>componentes</em>. La interfaz que en esta ocasión veremos es la del archivo <em>ConsultaClientes.mxml</em>. Esta interfaz funciona de la siguiente manera:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 391px"><a href="http://www.codigometropoli.com/images/screens/proy1image7.jpg" target="_blank"><img alt="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image7.jpg" title="Imagen 2: Interfaz del usuario" width="381" height="295" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Al seleccionar la opción "Consultar…" del menú, se mostrará una forma con tres campos de texto, en donde el usuario podrá introducir el nombre, teléfono y correo del cliente que está buscando. Además, en la forma tendremos el botón de <em>Mostrar</em>el cual ejecutará la búsqueda. Los resultados serán mostrados dentro del rectángulo que ves en la parte de abajo de la imagen anterior.</p>
<p>Una vez que el usuario ejecute al búsqueda, si no se encontraron registros que coincidan con los datos buscados, el sistema mostrará dentro del archivo HTML la leyenda "<em>No se encontraron resultados</em>". En caso contrario, el sistema mostrará los resultados de forma similar a la mostrada a continuación:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 389px"><a href="http://www.codigometropoli.com/images/screens/proy1image8.jpg" target="_blank"><img alt="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image8.jpg" title="Imagen 3: Resultado de la consulta" width="379" height="267" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Dicho lo anterior, comenzaremos mostrando la estructura y el código del archivo <em>ConsultaClientes.mxml</em>:</p>
<ul>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Nombre es <em>nombre_txt</em></li>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Correo es <em>correo_txt</em></li>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Teléfono es <em>teléfono_txt</em></li>
<li>El <strong>ID</strong> del componente <strong>HTML</strong> es <em>HTMLLoader</em></li>
</ul>
<p>El código de este  archivo  es el siguiente:</p>
<div class="igBar"><span id="lactionscript-6"><a href="#" onclick="javascript:showPlainTxt('actionscript-6'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-6">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion();"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">"#FFFFFF"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/ConsultarCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"13"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Consulta de Clientes"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"75"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"55"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"61"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Mostrar clientes por:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"151"</span> x=<span style="color: #ff0000;">"31"</span> textDecoration=<span style="color: #ff0000;">"underline"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"83"</span> x=<span style="color: #ff0000;">"62"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"119"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"65"</span> x=<span style="color: #ff0000;">"62"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"74"</span> x=<span style="color: #ff0000;">"285"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">"415"</span> y=<span style="color: #ff0000;">"119"</span> label=<span style="color: #ff0000;">"Mostrar"</span> click=<span style="color: #ff0000;">"generaConsulta();"</span>/&gt;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">HTML</span> <span style="color: #0066CC;">focusEnabled</span>=<span style="color: #ff0000;">"false"</span> id=<span style="color: #ff0000;">"HTMLLoader"</span> borderStyle=<span style="color: #ff0000;">"solid"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"31"</span> top=<span style="color: #ff0000;">"171"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"31"</span> bottom=<span style="color: #ff0000;">"21"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"123"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"355"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"119"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"123"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es <strong>&lt;mx:Canvas&gt;</strong> y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio componentes las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show</strong> del <strong>Canvas</strong> le estamos especificando que llame a la función  <em>abreConexion() </em>una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>ConsultarCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-7"><a href="#" onclick="javascript:showPlainTxt('actionscript-7'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-7">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/ConsultarCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código del botón <em>Mostrar</em> hacemos la llamada a la función <em>generaConsulta</em> una vez que el usuario haya hecho click en dicho botón. El código de esta función (<em>generaConsulta</em>) y de la función principal (<em>abreConexion</em>) se encuentra dentro del archivo ConsultarCliente.as:</p>
<div class="igBar"><span id="lactionscript-8"><a href="#" onclick="javascript:showPlainTxt('actionscript-8'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-8">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Importamos todas las librerías y clases que necesitamos. La clase HTMLTags la hice para establecer el código de cada elemento del archivo HTML, así como los estilos que usa dicho archivo; esta clase la veremos más adelante. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> clases.<span style="color: #006600;">HTMLTags</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filesystem</span>.<span style="color: #006600;">File</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">html</span>.<span style="color: #006600;">HTMLLoader</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Es importante establecer el tipo de codficación (encodeType) para que, al momento de escribir y generar el archivo, se muestren los acentos correctamente.&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _encodeType:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"iso-8859-1"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> stream:FileStream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Declaramos una variable de tipo FileStream para poder crear y escribir en el archivo */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> htmlElements:HTMLTags = <span style="color: #000000; font-weight: bold;">new</span> HTMLTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">/* Este es un objeto de nuestra clase HTMLTags */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbErrorConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se pudo conectar a la base de datos"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Después de haber importado las librerías necesarias y de haber declarado nuestras variables, escribimos el código de la función <em>abreConexion</em>. Esta función la hemos estado utilizando en las entradas anteriores, por lo que su código no debería causarte ruido.</p>
<p>Antes de ver el código de la función <em>generaConsulta</em>, mostraré el código de la clase HTMLTags:</p>
<div class="igBar"><span id="lactionscript-9"><a href="#" onclick="javascript:showPlainTxt('actionscript-9'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-9">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package clases</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HTMLTags</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> HTMLTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;/body&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;/html&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRulerTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;hr class=&quot;Ruler&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-2&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;title&gt;Consulta: Tarjetas&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'body {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-family:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size:12px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:30px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'hr.Ruler {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:-20px !important;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;border:1px solid #003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;background-color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;width:800px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo3 {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color: #993300;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-weight: bold;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size: 14px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo4 {font-size: 12px; color: #666666;}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Tabla_Datos td {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;height:25px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTitleTags<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;br /&gt;&lt;span class=&quot;Estilo3&quot;&gt;'</span> + <span style="color: #0066CC;">name</span> + <span style="color: #ff0000;">'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTable1Tags<span style="color: #66cc66;">&#40;</span>nombre:<span style="color: #0066CC;">String</span>, direccion:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;table class=&quot;Tabla_Datos&quot; width=&quot;700&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Nombre:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + nombre + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Dirección:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + direccion + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTable2Tags<span style="color: #66cc66;">&#40;</span>telefono:<span style="color: #0066CC;">String</span>, correo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">''</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Teléfono:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + telefono + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Correo:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + correo + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/table&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como pudiste observar en el código anterior, esta clase lo único que hace es regresarnos los tags del documento HTML que vamos a generar. Por ejemplo, la función <em>getFirstTags</em> nos regresa los primeros elementos que debe llevar el archivo HTML (los tags &lt;html&gt;, &lt;head&gt;, &lt;meta&gt; y los estilos que usaremos &lt;style&gt;). La función <em>getTitleTags</em> la mandaremos a llamar cada vez que recorramos un nuevo registro, le pasaremos como parámetro un texto de tipo "Cliente N" donde N es el valor de un contador que pondremos en el código (Cliente #1, Cliente #2, etc.) y nos regresará un texto con los tags y estilo que debe llevar. A la función <em>getTable1Tags</em> le estamos pasando como parámetro el nombre y la dirección del cliente, y ésta a su vez nos está regresando la información en forma de tabla con el código en HTML. Lo mismo sucede con la función <em>getTable2Tags</em>. La función <em>getRulerTag</em> nos regresa el tag &lt;hr&gt; para mostrar una línea horizontal. Por último, la función <em>getEndTags</em> nos regresa un texto con los tags que nos faltaban por cerrar (&lt;/body&gt; y &lt;/html&gt;).</p>
<p>Ahora veremos el código de generaConsulta. Presta atención en los comentarios que se encuentran dentro del código:</p>
<div class="igBar"><span id="lactionscript-10"><a href="#" onclick="javascript:showPlainTxt('actionscript-10'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-10">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> generaConsulta<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> prep:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">" WHERE "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> genericQuery:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"SELECT * FROM cliente "</span>; <span style="color: #808080; font-style: italic;">/* Seleccionamos todas las columnas del registro */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto nombre_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" nombre LIKE '%"</span> + nombre_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto nombre */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto correo_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" email LIKE '%"</span> + correo_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto correo */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto telefono_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" telefono LIKE '%"</span> + telefono_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto telefono */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; genericQuery += <span style="color: #ff0000;">" ORDER BY nombre asc"</span>; <span style="color: #808080; font-style: italic;">/* Le especificamos al query que los resultados los ordene de manera ascendente de acuerdo al nombre del cliente */</span>&nbsp;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = genericQuery; <span style="color: #808080; font-style: italic;">// Asignamos la variable del query al SQLStatement</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Ejecutamos la consulta</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Este será el archivo HTML que estamos creando. Su nombre es ConsultaCliente.html y se encontrará dentro de la carpeta HTML */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> htmlFile:File = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/HTML/ConsultaCliente.html"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>stream != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Cerramos el stream si es que existe */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>htmlFile, FileMode.<span style="color: #006600;">WRITE</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Abrimos el stream en modo de escritura */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, writeIOErrorHandler<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Establecemos un listener para detectar el evento */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = queryStatement.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Obtenemos los resultados regresados por la consulta */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// Si existen resultados... </span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> numResults:<span style="color: #0066CC;">int</span> = result.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">length</span>; <span style="color: #808080; font-style: italic;">// Determinamos el total de resultados regresados</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getFirstTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Escribimos en el archivo el texto regresado por la clase HTMLTags en su función getFirstTags */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;numResults; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// Hacemos un ciclo para recorrer todos los registros obtenidos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> row:<span style="color: #0066CC;">Object</span> = result.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; row.<span style="color: #006600;">nombre</span>;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Esta parte entraría a un ciclo */</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTitleTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Cliente #"</span> + <span style="color: #66cc66;">&#40;</span>i + <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTable1Tags</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #006600;">nombre</span>, row.<span style="color: #006600;">direccion</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTable2Tags</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #006600;">telefono</span>, row.<span style="color: #006600;">email</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getRulerTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Esta parte entraría a un ciclo */</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getEndTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se encontraron resultados"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Si todo salió bien, ahora podremos mostrar el archivo html en nuestro HTMLLoader */</span>&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; HTMLLoader.<span style="color: #006600;">location</span> = File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/HTML/ConsultaCliente.html"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que al final estamos especificando al control <strong>HTML</strong> (cuyo <strong>ID</strong> es <em>HTMLLoader</em>) el archivo HTML que debe mostrar (ConsultaCliente.html dentro de la carpeta HTML).</p>
<p>Hemos llegado al final de esta cuarta parte y de todas las entregas, no olvides bajar los archivos que se encuentran más abajo.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:30px; margin-bottom:20px;" align="center">
<table border="0" cellspacing="0" cellpadding="0" width="180">
<tbody>
<tr>
<td valign="top"><a href="http://www.megaupload.com/?d=277H67ZZ" target="_blank"><img src="../images/descargar_archivo.jpg" alt="Descargar Archivo" /></a></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-top:40px; margin-bottom:30px;">
<p><strong>Enlaces recomendados:</strong></p>
<p>» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte III (Modificar y Eliminar Registros)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 04:15:49 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=334</guid>
		<description><![CDATA[Esta es la tercera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo insertar registros en la base de datos (clientesDB.sqlite) desde nuestra aplicación en AIR.
En esta ocasión veremos cómo editar y eliminar registros de la base de datos; para esto [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la tercera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-ii/" target="_blank">entrada</a> anterior vimos cómo insertar registros en la base de datos (<em>clientesDB.sqlite</em>) desde nuestra aplicación en AIR.<br />
En esta ocasión veremos cómo editar y eliminar registros de la base de datos; para esto mostraremos dentro de un DataGrid todos los registros que tenemos en nuestra base de datos; en este DataGrid usaremos <strong>itemRenderer(s)</strong> para llenar con botones dos columnas, uno de los botones será para editar el registro seleccionado y el otro para eliminarlo.</p>
<p><span id="more-334"></span><span style="color: #ff0000;"><strong>Parte 3: Modificar y eliminar registros en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta actionscript. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 255px"><img title="Imagen 1: Estructura de la aplicación" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1: Estructura de la aplicación" width="245" height="373" /><p class="wp-caption-text">Imagen 1: Estructura de la aplicación</p></div>
</div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta componentes. La interfaz que en esta ocasión veremos es la del archivo <em>EditarBorrarCliente.mxml</em>. Esta interfaz funciona de la siguiente manera:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 552px"><a href="http://www.codigometropoli.com/images/screens/proy1image4.jpg" target="_blank"><img title="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image4.jpg" alt="Imagen 2: Interfaz del usuario" width="542" height="255" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Al seleccionar la opción "Editar/Eliminar…" del menú, se mostrará un DataGrid con todos los registros que tenemos dados de alta en nuestra base. En este ejemplo solamente tengo dos registros. Si el usuario hace click al botón de <strong>Modificar</strong> del primer registro, se mostrará lo siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 552px"><a href="http://www.codigometropoli.com/images/screens/proy1image5.jpg" target="_blank"><img title="Imagen 3: Opción Modificar Cliente" src="http://www.codigometropoli.com/images/screens/proy1image5.jpg" alt="Imagen 3: Opción Modificar Cliente" width="542" height="511" /></a><p class="wp-caption-text">Imagen 3: Opción Modificar Cliente</p></div>
</div>
<p>…Un Canvas con los datos de nuestro registro. Si el usuario lo desea, podrá modificar o actualizar los datos de este registro. Por el contrario, si el usuario le da click al botón de <strong>Eliminar</strong> del primer registro, se mostrará un mensaje de alerta pidiéndole que confirme si desea o no borrar el registro.</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 551px"><a href="http://www.codigometropoli.com/images/screens/proy1image6.jpg" target="_blank"><img title="Imagen 4: Mensaje de confirmación" src="http://www.codigometropoli.com/images/previews/proy1image6.jpg" alt="Imagen 4: Mensaje de confirmación" width="541" height="254" /></a><p class="wp-caption-text">Imagen 4: Mensaje de confirmación</p></div>
</div>
<p>Explicado lo anterior, comenzaremos mostrando la estructura y el código del archivo EditarBorrarCliente.mxml:</p>
<ul>
<li> El <strong>ID</strong> del <strong>DataGrid </strong>donde mostraremos los registros es <em>clientes_dg</em></li>
<li>El <strong>ID </strong>de nuestro <strong>Canvas </strong>en donde mostraremos la información del registro que el usuario puede modificar es <em>Modificar_Cliente</em>
<ul>
<li>El botón de <em>Cambiar</em> que se encuentra dentro del Canvas tiene de <strong>ID </strong><em>guardarBtn</em></li>
<li>El botón con una X tiene de <strong>ID </strong><em>cerrarBtn</em></li>
<li>Los <strong>ID</strong>s de cada una de las áreas de texto son:
<ul>
<li>nombre_txt, direccion_txt (TextArea), telefono_txt, correo_txt</li>
<li>Además, tenemos tres etiquetas cuyo texto es <strong>(*)</strong> y con los cuales le indicaremos al usuario qué dato le faltó por llenar. Estas etiquetas tienen de <strong>ID</strong>: <em>msj1</em>, <em>msj2</em>, <em>msj3</em> y <em>msj4</em>.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>El código de este  archivo  es el siguiente:</p>
<div class="igBar"><span id="lactionscript-28"><a href="#" onclick="javascript:showPlainTxt('actionscript-28'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-28">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion();"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">"#FFFFFF"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/EditarBorrarCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"13"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Lista de Clientes"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"75"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"55"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:DataGrid y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"600"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"223"</span> horizontalCenter=<span style="color: #ff0000;">"-14"</span> id=<span style="color: #ff0000;">"clientes_dg"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:columns&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"150"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Nombre"</span> dataField=<span style="color: #ff0000;">"nombre"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"120"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Teléfono"</span> dataField=<span style="color: #ff0000;">"telefono"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"165"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Correo"</span> dataField=<span style="color: #ff0000;">"correo"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"85"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Modificar"</span> dataField=<span style="color: #ff0000;">"modificar"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"editarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.editarCliente(data.id_cliente, data.nombre, data.direccion, data.telefono, data.correo)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/edit.png')"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:DataGridColumn&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Eliminar"</span> dataField=<span style="color: #ff0000;">"eliminar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"borrarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.borrarCliente(data.id_cliente)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/remove.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:DataGridColumn&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:columns&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:DataGrid&gt;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Canvas id=<span style="color: #ff0000;">"Modificar_Cliente"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"true"</span> y=<span style="color: #ff0000;">"324"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"378"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"255"</span> horizontalCenter=<span style="color: #ff0000;">"-15"</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#ADADAD"</span> backgroundAlpha=<span style="color: #ff0000;">"0.0"</span> borderStyle=<span style="color: #ff0000;">"solid"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"guardarBtn"</span> click=<span style="color: #ff0000;">"validaForma();"</span> y=<span style="color: #ff0000;">"221"</span> label=<span style="color: #ff0000;">"Cambiar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> x=<span style="color: #ff0000;">"220"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"10"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Modificar Cliente:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"11"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#31384B"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"213"</span> x=<span style="color: #ff0000;">"10"</span> textDecoration=<span style="color: #ff0000;">"underline"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"cerrarBtn"</span> y=<span style="color: #ff0000;">"1"</span> label=<span style="color: #ff0000;">"X"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"32"</span> x=<span style="color: #ff0000;">"343.3"</span> click=<span style="color: #ff0000;">"Modificar_Cliente.visible = false; reseteaForma();"</span> cornerRadius=<span style="color: #ff0000;">"0"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Text</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> x=<span style="color: #ff0000;">"10"</span> y=<span style="color: #ff0000;">"86"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Por favor introduzca la divisa"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontSize=<span style="color: #ff0000;">"10"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"184"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"33"</span> id=<span style="color: #ff0000;">"msj_nombre"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextArea y=<span style="color: #ff0000;">"81"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"69"</span> id=<span style="color: #ff0000;">"direccion_txt"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"86"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Dirección:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj1"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"82"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj2"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj3"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj4"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:Canvas&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es <strong>&lt;mx:Canvas&gt; </strong>y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio componentes las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show </strong>del <strong>Canvas </strong>le estamos especificando que llame a la función  <em>abreConexion()</em> una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>EditarBorrarCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-29"><a href="#" onclick="javascript:showPlainTxt('actionscript-29'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-29">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/EditarBorrarCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>También presta atención en la forma en que estamos creando los <strong>renderers </strong>para las columnas.</p>
<div class="igBar"><span id="lactionscript-30"><a href="#" onclick="javascript:showPlainTxt('actionscript-30'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-30">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"85"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Modificar"</span> dataField=<span style="color: #ff0000;">"modificar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"editarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.editarCliente(data.id_cliente, data.nombre, data.direccion, data.telefono, data.correo)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/edit.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:DataGridColumn&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro de los tags  <strong>&lt;mx:itemRenderer&gt; </strong>y  <strong>&lt;/mx:itemRenderer&gt; </strong>estamos usando como <em>layout </em>el <strong>HBox </strong>(HorizontalBox), aunque en realidad no afecta mucho ya que sólo estamos poniendo un componente por cada celda (en caso de que pongamos más elementos en esa celda, estos elementos se mostrarán uno tras otro de izquierda a derecha). El componente que estamos insertando en cada celda es un botón; este botón en el momento de hacer <strong>click</strong> sobre él llamará a la función <em>editarCliente</em>, el cual recibe como parámetros el ID, nombre, dirección, teléfono y correo del cliente en cuyo registro hicimos click. La palabra reservada <strong>outerDocument </strong>nos permite acceder a elementos que se encuentran fueran del alcance del item renderer. Además, al botón le estamos asignando el icono edit.png (<img align="absmiddle" src="http://www.codigometropoli.com/images/screens/edit.png" alt="" width="16" height="16" />) que está dentro de nuestra carpeta <em>images</em>. Importante: Observa cómo a esta columna del DataGrid le estamos especificando que no se pueda ordenar (sortable = false). Esto es porque en realidad no le estamos asignando valor alguno a cada celda, por lo tanto si intentáramos ordenar los registros de acuerdo a esta columna, Flex nos desplegaría un error.</p>
<p>El código para la columna que llevará los botones de <em>Eliminar </em>es el siguiente:</p>
<div class="igBar"><span id="lactionscript-31"><a href="#" onclick="javascript:showPlainTxt('actionscript-31'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-31">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Eliminar"</span> dataField=<span style="color: #ff0000;">"eliminar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"borrarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.borrarCliente(data.id_cliente)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/remove.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:DataGridColumn&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El código es similar al mostrado más arriba, lo único que cambia es que en esta ocasión el botón mandará a llamar a la función <em>borrarCliente</em>, pasándole como parámetro el ID del cliente. Además, el icono para este botón es remove.png (<img align="absmiddle" src="http://www.codigometropoli.com/images/screens/remove.png" alt="" width="16" height="16" />).</p>
<p>Antes de ver el código de las funciones <em>editarCliente </em>y <em>borrarCliente</em>, veremos cómo mostrar los registros de nuestra base de datos en el DataGrid. Para eso, el código que pegaré a continuación forma parte del archivo <strong>EditarBorrarCliente.as</strong>.</p>
<p>Primero, importamos las clases y declaramos las variables  que necesitamos. En el arreglo <em>data_provider</em> almacenaremos los datos obtenidos de nuestra consulta y lo asignaremos como <strong>dataProvider </strong>de nuestro DataGrid (<em>clientes_dg</em>). La variable <em>id_selected</em> nos servirá para almacenar el ID del registro seleccionado y posteriormente eliminarlo de la base de datos.</p>
<div class="igBar"><span id="lactionscript-32"><a href="#" onclick="javascript:showPlainTxt('actionscript-32'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-32">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// ActionScript file</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">CloseEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ListEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> data_provider:<span style="color: #0066CC;">Array</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> id_selected:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;color:#800000;">0</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La primera función que es llamada en esta sección es <em>abrirConexion</em>:</p>
<div class="igBar"><span id="lactionscript-33"><a href="#" onclick="javascript:showPlainTxt('actionscript-33'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-33">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; reseteaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; reiniciaVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; clientes_dg.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ListEvent.<span style="color: #006600;">CHANGE</span>, dgChangeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro de <em>abreConexion </em>llamamos a la función <em>reseteaForma</em>, la cual se encarga de borrar los datos de la forma para la modificación de los datos.</p>
<div class="igBar"><span id="lactionscript-34"><a href="#" onclick="javascript:showPlainTxt('actionscript-34'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-34">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> reseteaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Después de llamar a la función <em>reseteaForma</em>, ocultamos el canvas <em>Modificar_Cliente</em> y llamamos a la función <em>reiniciaVariables</em>, la cual se encargará de resetear los arreglos para eliminar su contenido previo.</p>
<div class="igBar"><span id="lactionscript-35"><a href="#" onclick="javascript:showPlainTxt('actionscript-35'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-35">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> reiniciaVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; clientes_dg.<span style="color: #006600;">dataProvider</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;<span style="color: #808080; font-style: italic;">// Reiniciamos el arreglo para eliminar su contenido</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; data_provider = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Reiniciamos el arreglo para eliminar su contenido&nbsp; &nbsp;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Posteriormente le asignamos al datagrid <em>clientes_dg</em> el listener del evento <strong>CHANGE</strong>. Este evento es lanzado cuando el usuario hace click en alguno de los registros del DataGrid. Cuando se genere este evento, el programa se encargará de esconder el cambas <em>Modificar_Cliente</em> (es posible que previamente el usuario le haya dado click al botón de <span style="text-decoration: underline;">Editar</span> en alguno de los registros, es por eso que nos aseguramos de esconder el Canvas). Además, almacenamos en la vaiable <em>id_selected</em> el <strong>ID</strong> del registro seleccionado; y, por último, escondemos los posibles mensajes que se le mostraron al usuario para que, cuando vuelva a darle click al botón <span style="text-decoration: underline;">Editar</span>, no se le muestren.</p>
<div class="igBar"><span id="lactionscript-36"><a href="#" onclick="javascript:showPlainTxt('actionscript-36'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-36">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dgChangeHandler<span style="color: #66cc66;">&#40;</span>event:ListEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = event.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">id_cliente</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El resto del código de la función <em>abreConexion</em> ya lo conoces de las entradas anteriores.<br />
Si no hubo ningún problema en la conexión a la base de datos, llamamos a la función <em>getClientes</em> para llenar el DataGrid con nuestros registros:</p>
<div class="igBar"><span id="lactionscript-37"><a href="#" onclick="javascript:showPlainTxt('actionscript-37'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-37">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getClientes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getClientes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"SELECT * FROM cliente ORDER BY nombre asc"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = queryStatement.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> numResults:<span style="color: #0066CC;">int</span> = result.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">length</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;numResults; i++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> row:<span style="color: #0066CC;">Object</span> = result.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_provider.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>nombre:row.<span style="color: #006600;">nombre</span>, id_cliente:row.<span style="color: #006600;">id</span>, direccion:row.<span style="color: #006600;">direccion</span>, correo:row.<span style="color: #006600;">email</span>, telefono:row.<span style="color: #006600;">telefono</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;clientes_dg.<span style="color: #006600;">dataProvider</span> = data_provider;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código de <em>getClientes</em> haremos la consulta a la tabla <span style="text-decoration: underline;">cliente</span> para obtener todos los registros de nuestra base. Nuestro query es muy sencillo, en él estamos seleccionando (SELECT)  todas las columnas (*) de la tabla <em>cliente </em>y le estamos diciendo que lo ordene (ORDER BY) de forma ascendente (asc)  de acuerdo a la columna <em>nombre</em>.</p>
<div class="igBar"><span id="lsql-38"><a href="#" onclick="javascript:showPlainTxt('sql-38'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-38">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> cliente <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> nombre <span style="color: #993333; font-weight: bold;">ASC</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Una vez que ejecutamos la consulta (queryStatement.execute()) obtenemos el resultado con la función <em>getResult</em>. Comprobamos que el resultado no sea vacío (result.data!= null) y obtenemos el total de registros obtenidos por medio de la propiedad <em>length</em>. Como ya sabemos cuántos registros nos regresó la consulta, haremos un ciclo <strong>for</strong> para almacenar los registros en nuestro arreglo <em>data_provider</em>. Finalmente estamos asignando el arreglo <em>data_provider</em> a la propiedad <strong>dataProvider </strong>del DataGrid. Importante: Si no comprendes esta parte donde llenamos el arreglo y se lo asignamos al DataGrid te recomiendo visitar la entrada sobre el <a href="http://www.codigometropoli.com/componente-datagrid/" target="_blank">Componente DataGrid</a> que publiqué anteriormente.</p>
<p>Hemos terminado la explicación de cómo realizar la consulta a la base de datos y mostrar los resultados en el DataGrid. Ahora veremos las funciones que habíamos dejado pendientes: <em>editarCliente </em>y <em>borrarCliente</em>.<br />
Como lo mencioné anteriormente, cuando el usuario hace click en el botón de Editar de alguno de los registros, la función <em>editarCliente </em>es llamada:</p>
<div class="igBar"><span id="lactionscript-39"><a href="#" onclick="javascript:showPlainTxt('actionscript-39'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-39">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> editarCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span>, nombre:<span style="color: #0066CC;">String</span>, direccion:<span style="color: #0066CC;">String</span>, telefono:<span style="color: #0066CC;">String</span>, correo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = nombre;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = direccion;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = telefono;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = correo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetros el ID del cliente, su nombre, dirección, teléfono y correo, para posteriormente mostrarlo en el formulario del canvas <em>Modificar_Cliente</em>. Si el usuario hace click en el botón de <em>Cambiar</em>, la función es <em>validaForma </em>es ejecutada:</p>
<div class="igBar"><span id="lactionscript-40"><a href="#" onclick="javascript:showPlainTxt('actionscript-40'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-40">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> validaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>direccion_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span> || !mail<span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; updateCliente<span style="color: #66cc66;">&#40;</span>id_selected<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función es similar a la que usamos en la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-ii/" target="_blank">entrada</a> anterior, simplemente estamos verificando que todos los datos fueron llenados y, en caso positivo, llamamos a la función <em>updateCliente</em>.</p>
<div class="igBar"><span id="lactionscript-41"><a href="#" onclick="javascript:showPlainTxt('actionscript-41'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-41">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> updateCliente<span style="color: #66cc66;">&#40;</span>idCliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"UPDATE `cliente` SET nombre = :nombre, direccion = :direccion, telefono = :telefono, email = :correo WHERE id = :idCliente"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = nombre_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = direccion_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = telefono_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":correo"</span><span style="color: #66cc66;">&#93;</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":idCliente"</span><span style="color: #66cc66;">&#93;</span> = idCliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetro el ID del registro seleccionado, crea el query para actualizar los datos del registro y los nuevos valores son pasados como parámetros a la sentencia SQL. Una vez que se ejecuta la sentencia llamamos nuevamente a la función <em>abreConexion </em>para que muestre todos los registros (incluyendo los nuevos) en el DataGrid.</p>
<p>La función <em>borrarCliente </em>es llamada cuando el usuario hace click en el botón de <em>Eliminar</em>:</p>
<div class="igBar"><span id="lactionscript-42"><a href="#" onclick="javascript:showPlainTxt('actionscript-42'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-42">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> borrarCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #006600;">yesLabel</span> = <span style="color: #ff0000;">"Sí"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #006600;">noLabel</span> = <span style="color: #ff0000;">"No"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"¿Desea eliminar este cliente?"</span>, <span style="color: #ff0000;">"Importante"</span>, <span style="color: #cc66cc;color:#800000;">3</span>, <span style="color: #0066CC;">this</span>, alertClickHandler<span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetro el ID del registro seleccionado por el usuario. Además, muestra un mensaje de alerta pidiéndole al usuario que confirme si desea eliminar el registro. Observa que al método <em>show </em>le pasamos como parámetro el manejador de eventos que debe considerar (<em>alertClickHandler</em>). Este manejador de eventos revisa si la respuesta del usuario fue positiva o negativa. En caso de que el usuario haya hecho click en el botón de Sí, llamamos a la función <em>delCliente </em>pasándole como parámetro el ID del registro seleccionado.</p>
<div class="igBar"><span id="lactionscript-43"><a href="#" onclick="javascript:showPlainTxt('actionscript-43'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-43">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> alertClickHandler<span style="color: #66cc66;">&#40;</span>event:CloseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">detail</span> == Alert.<span style="color: #006600;">YES</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; delCliente<span style="color: #66cc66;">&#40;</span>id_selected<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La función <em>delCliente </em>se encarga de ejecutar el query para borrar el registro de la base de datos. A este query le estamos pasando el ID del registro que hay que eliminar. Después de ejecutar la sentencia llamamos nuevamente a la función <em>abreConexion </em>para mostrar todos los registros restantes de la base de datos en el DataGrid.</p>
<div class="igBar"><span id="lactionscript-44"><a href="#" onclick="javascript:showPlainTxt('actionscript-44'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-44">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> delCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"DELETE FROM cliente WHERE id = :id_cliente"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":id_cliente"</span><span style="color: #66cc66;">&#93;</span> = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hemos llegado al final de esta tercera parte; ya nada más nos queda pendiente la cuarta y última entrega.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;">
<p><strong>Enlaces recomendados:</strong></p>
<p>» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte II (Insertar Registros)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 16:47:38 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=312</guid>
		<description><![CDATA[Esta es la segunda parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo crear la base de datos (clientesDB.sqlite), y cómo llenar con algunos registros por default la tabla cliente.
Esta entrada forma parte de un proyecto y los archivos de éste [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la segunda parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">entrada</a> anterior vimos cómo crear la base de datos (<em>clientesDB.sqlite</em>), y cómo llenar con algunos registros por default la tabla cliente.<br />
Esta entrada forma parte de un proyecto y los archivos de éste los encontrarás cuando termine de publicar todas las partes (entradas). Recuerda que para este proyecto estamos usando Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?product=flex" target="_blank">aquí</a>.<br />
<span id="more-312"></span></p>
<p>Como lo comenté en el post <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">anterior </a>, aquí mostraré solamente la información más importante y sobre la cual trata el tema, sin embargo el archivo fuente del proyecto está completo y tiene integrado todo lo que se mostrará en esta entrada, la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">anterior</a> y en las siguientes, para así formar un proyecto completo. Dicho lo anterior, a continuación iniciaré la explicación sobre cómo insertar registros en una base SQLite.</p>
<p><span style="color: #ff0000;"><strong>Parte 2: Insertar registros en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta <em>actionscript</em>. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div id="attachment_270" class="wp-caption aligncenter" style="width: 255px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1" width="245" height="373" /></a><p class="wp-caption-text">Imagen 1</p></div></div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta <em>componentes</em>. La interfaz para dar de alta un nuevo cliente está en el archivo <em>AltaCliente.mxml</em>. Esta interfaz será la siguiente:</p>
<div align="center"><div id="attachment_270" class="wp-caption aligncenter" style="width: 344px"><a href="http://www.codigometropoli.com/images/screens/proy1image3.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/images/screens/proy1image3.jpg" alt="Imagen 1" width="334" height="274" /></a><p class="wp-caption-text">Imagen 2</p></div></div>
<p>Los IDs de cada uno de estos elementos son:</p>
<ul>
<li> nombre_txt</li>
<li>dirección_txt</li>
<li>telefono_txt</li>
<li>correo_txt</li>
</ul>
<p>El código del archivo <em>AltaCliente.mxml</em> es el siguiente:</p>
<div class="igBar"><span id="lactionscript-53"><a href="#" onclick="javascript:showPlainTxt('actionscript-53'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-53">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&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;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion()"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/AltaCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"16"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Alta de Clientes"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextArea y=<span style="color: #ff0000;">"88"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"69"</span> id=<span style="color: #ff0000;">"direccion_txt"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"93"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Dirección:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> y=<span style="color: #ff0000;">"230"</span> label=<span style="color: #ff0000;">"Aceptar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> horizontalCenter=<span style="color: #ff0000;">"104"</span> click=<span style="color: #ff0000;">"{validaForma();}"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj1"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj2"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj3"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj4"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es  <strong>&lt;mx:Canvas&gt;</strong> y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio <em>componentes </em>las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show </strong>del <strong>Canvas </strong>le estamos especificando que llame a la función  <em>abreConexion()</em> una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>AltaCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-54"><a href="#" onclick="javascript:showPlainTxt('actionscript-54'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-54">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/AltaCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Otro punto importante a destacar del código anterior es el botón que tiene de etiqueta “Aceptar”, cuando se produce un click en este botón llamaremos a la función <em>validaForma()</em> para asegurarnos que todos los datos requeridos sean llenados.</p>
<div class="igBar"><span id="lactionscript-55"><a href="#" onclick="javascript:showPlainTxt('actionscript-55'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-55">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:<span style="color: #0066CC;">Button</span> y=<span style="color: #ff0000;">"230"</span> label=<span style="color: #ff0000;">"Aceptar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> horizontalCenter=<span style="color: #ff0000;">"104"</span> click=<span style="color: #ff0000;">"{validaForma();}"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A continuación está la explicación del código del archivo <strong>AltaCliente.as</strong>:</p>
<div class="igBar"><span id="lactionscript-56"><a href="#" onclick="javascript:showPlainTxt('actionscript-56'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-56">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>; <span style="color: #808080; font-style: italic;">/* Haremos uso de los mensajes de alerta, por lo que de una vez añadimos la clase */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection; <span style="color: #808080; font-style: italic;">// Nuestro objeto de la clase SQLConnection</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File; <span style="color: #808080; font-style: italic;">/* Aquí guardaremos la referencia de nuestro archivo .sqlite que es nuestra base de datos */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Creamos una variable de tipo SQLStatement en la cual estableceremos los queries y parámetros de nuestras consultas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Del código anterior, las seis primeras líneas no cambian en nada con respecto al código mostrado en el primer post. Cuando se llame la función <em>abreConexion</em> posicionaremos el cursor dentro del campo de texto nombre_txt, establecemos cuál es el archivo de la base de datos e intentamos abrirla; si existiera algún error es llamada la función dbErrorConexion; en caso contrario, es llamada la función dbErrorConexion.</p>
<p>En esta ocasión, la función <strong>abreConexion</strong> será llamada desde la intefaz que mostré más arriba (desde el archivo <em>AltaCliente.mxml</em>).</p>
<p>Como lo señalé más arriba, una vez que el usuario introduzca los datos y haga click en el botón de Aceptar, la función <em>validaForma()</em> será llamada, el código de esta función te lo presento a continuación:</p>
<div class="igBar"><span id="lactionscript-57"><a href="#" onclick="javascript:showPlainTxt('actionscript-57'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-57">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> validaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>direccion_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span> || !mail<span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; compruebaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código de <em>AltaCliente.mxml</em> están unas etiquetas con IDs <em>msj1</em>, <em>msj2</em>, <em>msj3</em>, etc. y cuyo texto es <strong>(*)</strong>; estas etiquetas nos permitirán mostrarle al usuario qué información le faltó por llenar. Como su nombre lo indica, la función <em>escondeMensajes</em> se encarga de "esconder" (visible = false) éstos mensajes y así mostrar solamente los que son necesarios.</p>
<p>En este ejemplo, tenemos cuatro sentencias <em>if</em> encargadas de verificar que la información en los campos de texto <em>nombre_txt</em>, <em>dirección_txt</em>, <em>telefono_txt</em> y <em>correo_txt</em> sean distintos de vacío. Además, nos aseguramos que el formato del correo electrónico sea correcto creando la función mail.</p>
<p>Finalmente, si ninguna de las cuatro condicionales <em>if</em> se cumple (es decir, toda la información requerida fue introducida) llamamos a la función <em>compruebaCliente</em> y verificar si el correo electrónico proporcionado ya existe en la base de datos.</p>
<p>A continuación, te muestro el código de las funciones <em>escondeMensajes</em>, <em>mail</em> y <em>compruebaCliente</em>:</p>
<div class="igBar"><span id="lactionscript-58"><a href="#" onclick="javascript:showPlainTxt('actionscript-58'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-58">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mail<span style="color: #66cc66;">&#40;</span>email:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> res:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #cc66cc;color:#800000;">0</span> &amp;&amp; email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span> == email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span>&gt;email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span>&lt;email.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> res;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> compruebaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> correo:<span style="color: #0066CC;">String</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"SELECT 1 FROM cliente WHERE email = :correo LIMIT 1"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":correo"</span><span style="color: #66cc66;">&#93;</span> = correo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; query.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = query.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Esa cuenta de correo ya existe"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insertaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: “ + error.toString());</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp; &nbsp;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">} </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que dentro de la función <em>compruebaCliente</em> estamos declarando la variable <em>correo</em> y asignándole el valor del cuadro de texto <em>correo_txt</em>. Esta variable la pasaremos como parámetro a la consulta para verificar que esa cuenta de correo electrónico no exista en la base de datos. Con la función <strong>clearParameters</strong> de nuestro objeto <strong>SQLStatement</strong> estamos eliminando los posibles parámetros que hayamos asignado con anterioridad, de no hacer esto el programa generará un error indicándonos que la cantidad de parámetros establecidos en el query no concuerda con los parámetros del <strong>SQLStatement</strong>. A esta variable le indicamos a su propiedad <em>text</em> el <em>query</em> o la consulta que debe realizar. Además, le especificamos (dentro del query) que llevará el parámetro <em>:correo</em> y le asignamos a ese parámetro el valor de la variable <em>correo</em>.<br />
Por último, realizamos la ejecución de la consulta y verificamos si el resultado obtenido es distinto de vacío (nulo – null). Si el resultado es distinto de vacío quiere decir que sí existe un registro con esa cuenta de correo y por lo tanto mostramos un mensaje de alerta informándole al usuario; en caso contrario, llamamos a la función <em>insertaCliente()</em>:</p>
<div class="igBar"><span id="lactionscript-59"><a href="#" onclick="javascript:showPlainTxt('actionscript-59'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-59">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> insertaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"INSERT INTO `cliente` (nombre, direccion, telefono, email)"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">" VALUES (:nombre, :direccion, :telefono, :email) "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = nombre_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = direccion_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = telefono_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":email"</span><span style="color: #66cc66;">&#93;</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Sus datos han sido almacenados"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; restableceForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Creamos la variable sql y le asignamos un string con nuestra consulta y los parámetros que recibirá (recuerda que los parámetros son especificados con dos puntos - : -). Llamamos a la función <strong>clearParameters</strong> y posteriormente le asignamos al <strong>SQLStatement</strong> los valores de los cuatro parámetros (estos valores son obtenidos de nuestros campos de texto).  Ejecutamos la sentencia, le mostramos un mensaje al usuario informándole que sus datos han sido almacenados y por último llamamos a la función <em>restableceForma</em> para borrar la información de los campos de texto.</p>
<div class="igBar"><span id="lactionscript-60"><a href="#" onclick="javascript:showPlainTxt('actionscript-60'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-60">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> restableceForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hemos llegado al final de esta segunda parte. Si te perdiste la primera <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">parte</a> de este tutorial, te recuerdo que…  como recomendación y para que te asegures de que tu base de datos, la tabla y el registro fueron creados, puedes bajar el complemento para Firefox llamado <a href="https://addons.mozilla.org/es-ES/firefox/addon/5817" target="_blank"><strong>SQLite Manager</strong></a>, el cual es un pequeño y simple administrador de bases SQLite.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;"><strong>Enlaces recomendados:</strong><br />
<br />
» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte I (Crear Base de datos)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-i/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-i/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 01:01:32 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=269</guid>
		<description><![CDATA[Esta es la primera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. Para este proyecto usaremos Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 aquí. Si requieres más información sobre qué es AIR y qué puedes hacer con él [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la primera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. Para este proyecto usaremos Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?product=flex" target="_blank">aquí</a>. Si requieres más información sobre qué es AIR y qué puedes hacer con él visita esta entrada. Los archivos de este proyecto los encontrarás al terminar de publicar todas las partes (entradas) de este proyecto.<br />
<span id="more-269"></span><br />
Para este proyecto, abre Flex Builder 3 y crea un nuevo proyecto de AIR (File -&gt; New -&gt; Flex Project. Como nombre de proyecto (Project name) ponle <strong>Sistema_Clientes</strong>; en la sección de <em>Application type</em> selecciona la opción <strong>Desktop application</strong> (runs in Adobe AIR) y haz click en el botón <em>Finish</em>.<br />
Como lo comenté en la sección de <a href="http://www.codigometropoli.com/proyectos/">Proyectos</a>, aquí mostraré solamente la información más importante y sobre la cual trata el tema, sin embargo el archivo fuente del proyecto está completo y tiene integrado todo lo que se mostrará en esta entrada y en las siguientes, para así formar un proyecto completo. Dicho lo anterior, a continuación iniciaré la explicación sobre cómo crear una base de datos en SQLite.</p>
<p><span style="color: #ff0000;"><strong>Parte 1: Crear Base de Datos en SQLite con AIR<br />
</strong></span><br />
Para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, vamos a dividir el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta <em>actionscript</em>. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center"><div id="attachment_270" class="wp-caption aligncenter" style="width: 255px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1" width="245" height="373" /></a><p class="wp-caption-text">Imagen 1</p></div></div>
<p>Comenzamos con el archivo <strong>CrearBaseDatos</strong>.as:</p>
<p>Necesitamos de las siguientes librerías para poder tener acceso a los métodos de conexión con la base de datos, la ejecución de los queries, etc. Las clases que usaremos son SQLConnection, SQLErrorEvent y SQL Event:</p>
<div class="igBar"><span id="lactionscript-68"><a href="#" onclick="javascript:showPlainTxt('actionscript-68'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-68">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>; <span style="color: #808080; font-style: italic;">/* Haremos uso de los mensajes de alerta, por lo que de una vez añadimos la clase */</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora vamos a crear los objetos de estas clases y las variables que requeriremos a lo largo de este archivo:</p>
<div class="igBar"><span id="lactionscript-69"><a href="#" onclick="javascript:showPlainTxt('actionscript-69'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-69">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection; <span style="color: #808080; font-style: italic;">// Nuestro objeto de la clase SQLConnection</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File; <span style="color: #808080; font-style: italic;">/* Aquí guardaremos la referencia de nuestro archivo .sqlite que es nuestra base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> existeBD:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #808080; font-style: italic;">/* Variable booleana en la cual guardaremos el valor de true si existe la base de datos y false en caso contrario */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Creamos una variable de tipo SQLStatement en la cual estableceremos los queries y parámetros de nuestras consultas */</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para crear las sentencias de SQL, necesitamos de un objeto de la clase <strong>SQLStatement</strong>, a este objeto lo llamamos <em>queryStatement</em>.</p>
<p>La función <strong>abreConexion </strong>(que mostraremos a continuación) será llamada desde la aplicación principal, es decir desde el archivo <em>Sistema_Clientes.mxml</em> (recuerda que al crear un nuevo proyecto, Flex Builder construye automáticamente un archivo MXML con el nombre del proyecto y el cual es el punto de partida de nuestra aplicación). Esta función se encargará de verificar si existe la base de datos la cual la pasamos como parámetro del constructor de la clase <strong>File</strong>.  Si no existiera la base de datos la aplicación se encargará de crearla. En caso contrario, se establecería la conexión con la base de datos.  El nombre de nuestra base de datos será <strong>clientesDB.sqlite</strong>, presta atención a la primera línea de nuestra función:</p>
<div class="igBar"><span id="lactionscript-70"><a href="#" onclick="javascript:showPlainTxt('actionscript-70'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-70">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Asignamos a nuestra variable database el archivo de nuestra base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Inicializamos nuestra variable conexion */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Creamos el listener que será llamado cuando se abra la conexión a la base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Creamos el listener que será llamado cuando exista algún error en la conexión a la bd */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion; <span style="color: #808080; font-style: italic;">/* Le asignamos a su propiedad sqlConnection la variable conexion que creamos al inicio del archivo&nbsp; */</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!database.<span style="color: #006600;">exists</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// Comprobamos si existe o no la base de datos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; existeBD = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #808080; font-style: italic;">// No existe la bd, por lo tanto le asignamos a existeBD el valor de falso</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Abrimos la conexión a la bd&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Abrimos la conexión a la bd</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que al constructor de la clase <strong>File </strong>le estamos pasando como parámetro el URL de donde estará almacenada nuestra base de datos. Para construir este URL estamos usando la propiedad <strong>applicationStorageDirectory</strong>, la cual hace referencia al directorio privado donde se encuentra la aplicación. Además, estamos usando la propiedad <strong>nativePath </strong>la cual nos regresa la ruta completa de acuerdo al sistema operativo donde se encuentra el sistema. A grandes rasgos, esta línea crea un directorio con el nombre de la aplicación (en este caso el directorio se llama <strong>Sistema_Clientes</strong>) dentro de la carpeta de Application Data (Datos de programa). Esta carpeta es donde los programas que tenemos instalados guardan información o las preferencias del usuario de la computadora. En Windows Vista, el directorio donde está almacenada la base de datos es C:\Users\Nombre_Usuario\AppData\Roaming\Sistema_Clientes. En Windows XP, el directorio es: C:\Documents and Settings\Nombre_Usuario\Datos de programa\Sistema_Clientes.</p>
<p>Al hacer la llamada a la función <strong>open</strong>, la función <strong>dbAbrirConexion </strong>será llamada en caso de que no exista error; en caso contrario la función <strong>dbErrorConexion </strong>será llamada. El código de estas funciones se muestra a continuación:</p>
<div class="igBar"><span id="lactionscript-71"><a href="#" onclick="javascript:showPlainTxt('actionscript-71'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-71">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!existeBD<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si no existe la base de datos, llamamos a la función createTBLCliente */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; createTBLCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbErrorConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se pudo conectar a la base de datos"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Mostramos un mensaje de error*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nuestra base de datos estará conformada por solamente una tabla (sólo para fines del ejercicio, ya que no es común que una base de datos esté formada por sólo una tabla). Nuestra tabla se llama <strong>cliente </strong>y sus elementos son los siguientes:</p>
<div align="center"><div id="attachment_272" class="wp-caption aligncenter" style="width: 390px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image2.jpg"><img class="size-full wp-image-272" title="proy1image2" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image2.jpg" alt="Imagen 2" width="380" height="226" /></a><p class="wp-caption-text">Imagen 2</p></div></div>
<p>De la imagen anterior podemos determinar que el query para crear esta tabla es:</p>
<div class="igBar"><span id="lsql-72"><a href="#" onclick="javascript:showPlainTxt('sql-72'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-72">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`cliente`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`id`</span> INTEGER <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>, <span style="color: #ff0000;">`nombre`</span> TEXT, <span style="color: #ff0000;">`direccion`</span> TEXT, <span style="color: #ff0000;">`telefono`</span> TEXT, <span style="color: #ff0000;">`email`</span> TEXT<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este query lo usaremos en la función <strong>createTBLCliente</strong>, el cual es llamado desde <strong>dbAbrirConexion</strong>.</p>
<div class="igBar"><span id="lactionscript-73"><a href="#" onclick="javascript:showPlainTxt('actionscript-73'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-73">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createTBLCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"CREATE TABLE `cliente` "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">"(`id` INTEGER PRIMARY KEY&nbsp; NOT NULL, `nombre` TEXT, `direccion` TEXT "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">", `telefono` TEXT, `email` TEXT)"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; insertDefaultData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al insertar el registro: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para crear las sentencias de SQL, necesitamos de un objeto de la clase <strong>SQLStatement</strong>, a este objeto lo llamamos <em>queryStatement </em>y lo declaramos al inicio del programa. Para asegurarnos de que no tengamos parámetros asignados a este SQLStatement, usamos la función <strong>clearParameters</strong>, de no hacer esto el programa generará un error indicándonos que la cantidad de parámetros establecidos en el query no concuerda con los parámetros del <strong>SQLStatement</strong>. Posteriormente declaramos una variable <em>sql </em>de tipo <em>String</em> que contiene el query de crear la tabla de cliente.<br />
La propiedad <strong>text </strong>de la clase <strong>SQLStatement </strong>nos permite asignarle la sentencia SQL, por lo que le asignamos la variable <em>sql</em>.</p>
<p>Para poder "cachar" cualquier error que ocurra al ejecutar la sentencia, colocamos la llamada a la función <strong>execute </strong>dentro del bloque <strong>try</strong>. Cualquier error que ocurra será detectado y administrador en el bloque <strong>catch</strong>. En caso de que no exista ningún error al llamar a la función <strong>execute</strong>, llamaremos a la función <em>insertDefaultData </em>para insertar algunos registros por default.</p>
<p>A continuación pego el código de la función <em>insertDefaultData:</em></p>
<div class="igBar"><span id="lactionscript-74"><a href="#" onclick="javascript:showPlainTxt('actionscript-74'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-74">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> insertDefaultData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"INSERT INTO `cliente` (nombre, direccion, telefono, email) VALUES (:nombre, :direccion, :telefono, :email)"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Ernesto Trujillo'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Avenida Importante #33'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'55667788'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":email"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'etrujillo@email.com'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al crear la tabla cliente: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este código es similar al de la función <em>createTBLCliente </em>en cuanto a la creación de la variable del <strong>SQLStatement</strong>, la creación del query y su asignación a la propiedad <strong>text</strong>. Sin embargo, presta atención en la forma en cómo se le pasan los valores al query; esto es usando dos puntos seguidos de un nombre cualquiera que quieras asignarle. Posteriormente debes establecer el valor de estos parámetros usando la propiedad <strong>parameters </strong>la cual recibe un arreglo asociativo con los valores del parámetro especificado.</p>
<p>Como recomendación y para que te asegures de que tu base de datos, la tabla y el registro fueron creados, puedes bajar el complemento para Firefox llamado <a href="https://addons.mozilla.org/es-ES/firefox/addon/5817" target="_blank"><strong>SQLite Manager</strong></a>, el cual es un pequeño y simple administrador de bases  SQLite.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;"><strong>Enlaces recomendados:</strong><br />
<br />
» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-i/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
		<item>
		<title>Crear archivo en AIR con Flex Builder 3</title>
		<link>http://www.codigometropoli.com/crear-archivo-en-air-con-flex-builder-3/</link>
		<comments>http://www.codigometropoli.com/crear-archivo-en-air-con-flex-builder-3/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 07:26:52 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[crear archivo en AIR]]></category>
		<category><![CDATA[FileStream]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=18</guid>
		<description><![CDATA[Adobe AIR permite a los desarrolladores web, crear aplicaciones de escritorio con todo lo que una aplicación web puede proveer. Estas aplicaciones pueden ser ejecutadas en cualquier sistema operativo. Para instalar AIR necesitas tener instalado el Flex Builder 3 (o bien bajarte el SDK de Adobe AIR). En esta entrada aprenderemos a crear un archivo [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Adobe AIR permite a los desarrolladores web, crear aplicaciones de escritorio con todo lo que una aplicación web puede proveer. Estas aplicaciones pueden ser ejecutadas en cualquier sistema operativo. Para instalar AIR necesitas tener instalado el Flex Builder 3 (o bien bajarte el SDK de Adobe AIR). En esta entrada aprenderemos a crear un archivo HTML con Adobe AIR.<span id="more-18"></span>Puedes bajarte una versión de prueba del Flex Builder 3 <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?product=flex" target="_blank">aquí</a>. Además, deberás bajar Adobe AIR de <a href="http://get.adobe.com/air/" target="_blank">aquí</a>. Una vez instalado estas dos aplicaciones inicia Flex Builder y haz click en el menú File -&gt; New -&gt; Flex Project. Te aparecerá una ventana en la cual deberás establecer el nombre del proyecto y el tipo de aplicación. En este caso deberás seleccionar la opción de <em>Desktop application (runs in Adobe AIR)</em>. Como nombre de proyecto le pondremos <em>AIRCreateFile</em>. <em></em></p>
<p style="text-align: center;"><a title="Figura 1: Nuevo proyecto de Adobe AIR en Flex" href="../images/screens/ps5sc1.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc1.png" alt="Figura 1: Nuevo proyecto de Adobe AIR en Flex" width="334" height="300" /></a></p>
<p style="text-align: left;">Después de poner los datos anteriores y de hacer click en el botón de <em>Finish</em>, observarás del lado derecho (Flex Navigator) la lista de archivos y proyectos que tenemos dentro de Flex Builder. El icono rojo al lado del nombre del proyecto inidica que se trata de un proyecto de Adobe AIR. Dentro de la carpeta <em>src</em> (source) se almacenarán los archivos de nuestro proyecto, si observas, el programa Flex ya nos creó nuestro primer archivo (el cual será el punto de arranque de la aplicación) el cual se llama igual que nuestro proyecto.</p>
<p style="text-align: left;">Adobe AIR no sólo nos creo el archivo AIRCreateFile.mxml sino que también nos lo abrió (en la ventana grande de la derecha) y está listo para que empecemos a programar.</p>
<p style="text-align: center;"><a title="Figura 2: Nuestro proyecto de AIR en Flex Builder 3" href="../images/screens/ps5sc2.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc2.png" alt="Figura 2: Nuestro proyecto de AIR en Flex Builder 3" /></a></p>
<p>Como puedes observar en el código, el componente <em>WindowedApplication</em> es el componente padre de nuestra aplicación en AIR. Dentro de estos tags &lt;WindowedApplication&gt; y &lt;/WindowedApplication&gt; debemos escribir todo nuestro código. Comenzaremos haciendo unos cambios al diseño de la aplicación, posteriormente veremos el código necesario para crear el archivo y cargarlo con el componente <em>HTML</em> de Adobe AIR.</p>
<p>Si observas la imagen anterior, arriba del editor de código está el botón de <em>Source</em> (Fuente) y el botón de <em>Design</em> (diseño). Ahorita estamos en la vista del código fuente, por lo tanto el botón de <em>Source</em> está activado. Para realizar los cambios en el diseño de la aplicación lo haremos directamente desde la vista <em>Design</em>, por lo tanto da click en ese botón. Al darle click al botón de diseño, los paneles laterales cambian (En esta vista podemos ver del lado derecho el panel <em>Flex Properties</em> (Propiedades de Flex), el panel <em>States</em> (Estados), <em>Components</em> (Componentes), entre otros. En el panel <em>Style</em>, dentro de la sección <em>Fill</em>, al hacer click en el primer botón (el de una cubeta de pintura) podemos cambiar el color de fondo de la aplicación. Para este ejercicio cambia el botón de fondo a blanco (#FFFFFF).</p>
<p>En el panel <em>Components</em> dentro de la sección de <em>Controls</em>, arrastra al área de diseño el item que dice <em>Label</em>. Da click sobre él y escribe "Crear archivo HTML en AIR"; dale el formato que quieras y dentro de la sección <em>Layout</em> del panel de propiedades da click en el botón de enmedio horizontal que está debajo de <em>Constraints</em>. Este botón permite que la etiqueta (Label) que acabamos de poner siempre está centrada horizontalmente cuando se ejecuta la aplicación.</p>
<p style="text-align: center;"><a title="Figura 3: Panel Flex Properties" href="../images/screens/ps5sc4.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc4.png" alt="Figura 3: Panel Flex Properties" width="535" height="423" /></a></p>
<p>En el mismo panel de componentes, se encuentra como penéltima categoría los componentes de Adobe AIR, busca el componente <em>HTML</em> y arrástralo al área de diseño. Selecciona el componente que acabas de arrastrar y pon los siguientes valores en la sección de <em>Layout</em> del panel de propiedades:</p>
<p style="text-align: center;"><a title="Figura 4: Definiendo las propiedades de nuestro componente HTML" href="../images/screens/ps5sc5.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc5.png" alt="Figura 4: Definiendo las propiedades de nuestro componente HTML" width="535" height="423" /></a></p>
<p>Da click en el botón de <em>Source</em> y observa cómo Flex Builder fue creando el código referente a los cambios de layout y diseño del archivo mxml.  Como esta va a ser una pequeña aplicación de ejemplo, vamos a poner todo el código en este archivo; sin embargo, es recomendable para aplicaciones más grandes tener nuestro código organizado en clases y archivos .AS para poder reutilizarlos y para poder actualizarlos fácilmente cuando se requieran cambios. Agrega estos elementos a los siguientes tags:</p>
<div class="igBar"><span id="lactionscript-81"><a href="#" onclick="javascript:showPlainTxt('actionscript-81'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-81">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Una vez que se haya creado la ventana de la aplicación, se mandará a llamar la función init(); */</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:WindowedApplication creationComplete=<span style="color: #ff0000;">"init();"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Le estamos asignando el id de HTMLLoader al componente HTML */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:<span style="color: #0066CC;">HTML</span> id=<span style="color: #ff0000;">"HTMLLoader"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro de los tags &lt;WindowedApplication&gt; introduce esta línea de código y presiona la tecla Enter:</p>
<div class="igBar"><span id="lactionscript-82"><a href="#" onclick="javascript:showPlainTxt('actionscript-82'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-82">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Verás que Flex Builder te completará el código cerrando el tag:</p>
<p style="text-align: center;"><a title="Figura 6: Estableciendo los tags de Script para poner nuestro código ActionScript" href="../images/screens/ps5sc3.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc3.png" alt="Figura 6: Estableciendo los tags de Script para poner nuestro código ActionScript" width="334" height="300" /></a></p>
<p>Dentro del CDATA de nuestro tag <em>Script</em> deberá ir todo nuestro código ActionScript que necesitemos. Para poder crear un archivo desde AIR necesitamos importar la librería File:</p>
<div class="igBar"><span id="lactionscript-83"><a href="#" onclick="javascript:showPlainTxt('actionscript-83'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-83">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// Importar las siguientes librerías:</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filesystem</span>.<span style="color: #006600;">File</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">html</span>.<span style="color: #006600;">HTMLLoader</span>; <span style="color: #808080; font-style: italic;">// Esta librería la usaremos más adelante para mostrar en nuestra aplicación el archivo HTML que generamos </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Además, crearemos estas variables que usaremos más adelante:</p>
<div class="igBar"><span id="lactionscript-84"><a href="#" onclick="javascript:showPlainTxt('actionscript-84'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-84">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _encodeType:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"iso-8859-1"</span>; <span style="color: #808080; font-style: italic;">/* Tipo de codificación para que nos permita acentos en el archivo */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> stream:FileStream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Estamos declarando una variable de tipo FileStream para poder crear y escribir en el archivo */</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Debajo del código anterior escribe las siguientes funciones:</p>
<div class="igBar"><span id="lactionscript-85"><a href="#" onclick="javascript:showPlainTxt('actionscript-85'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-85">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Esta es la primera función que mandamos a llamar en creationComplete */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">this</span>.<span style="color: #006600;">maximize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Cuando ejecutamos la aplicación la ventana estará maximizada */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> htmlFile:File = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/miArchivo.html"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Una referencia al archivo HTML que vamos a crear, en ese caso nuestro archivo se llamará miArchivo.html */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>stream != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si ya existe un stream abierto hay que cerrarlo */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>htmlFile, FileMode.<span style="color: #006600;">WRITE</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Abrimos el archivo en modo de escritura */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, writeIOErrorHandler<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Asignamos un listener al stream para ver si hubo error de lectura o escritura de archivo */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Escribimos en nuestro archivo el texto (que en nuestro caso es el código HTML de nuestro ejemplo) que nos regresa la función getFirstTags() declarada más adelante, con codificación ISO para los acentos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getDataTable<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Escribimos en nuestro archivo el texto que nos regresa la función getDataTable */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;&nbsp; <span style="color: #808080; font-style: italic;">/* Escribimos en nuestro archivo el texto que nos regresa la función getEndTags*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Cerramos nuestro stream */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;HTMLLoader.<span style="color: #006600;">location</span> = File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/miArchivo.html"</span>; <span style="color: #808080; font-style: italic;">/* Mostramos en el componente HTML el archivo que acabamos de crear */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-2&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;title&gt;Crear archivo HTML en Adobe AIR&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'body {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-family:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size:12px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:30px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'hr.Ruler {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:-20px !important;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;border:1px solid #003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;background-color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;width:800px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo3 {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color: #993300;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-weight: bold;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size: 14px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo4 {font-size: 12px; color: #666666;}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'a:hover, a:link, a:visited, a:active {font-size: 12px; color: #666666; text-decoration:none; }<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Tabla_Datos td {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;height:25px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;/body&gt;&lt;/html&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> _texto;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> writeIOErrorHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp;<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al abrir o escribir el archivo"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>¿Te perdiste? No te preocupes, aquí va el código completo:</p>
<div class="igBar"><span id="lactionscript-86"><a href="#" onclick="javascript:showPlainTxt('actionscript-86'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-86">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filesystem</span>.<span style="color: #006600;">File</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">html</span>.<span style="color: #006600;">HTMLLoader</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _encodeType:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"iso-8859-1"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> stream:FileStream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">maximize</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> htmlFile:File = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/miArchivo.html"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>stream != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>htmlFile, FileMode.<span style="color: #006600;">WRITE</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, writeIOErrorHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getDataTable<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; HTMLLoader.<span style="color: #006600;">location</span> = File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/miArchivo.html"</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-2&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;title&gt;Crear archivo HTML en Adobe AIR&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'body {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-family:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size:12px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:30px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'hr.Ruler {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:-20px !important;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;border:1px solid #003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;background-color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;width:800px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo3 {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color: #993300;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-weight: bold;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size: 14px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo4 {font-size: 12px; color: #666666;}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'a:hover, a:link, a:visited, a:active {font-size: 12px; color: #666666; text-decoration:none; }<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Tabla_Datos td {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;height:25px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getDataTable<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;span class=&quot;Estilo3&quot;&gt;Archivo HTML en Adober AIR&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;Estilo4&quot;&gt;&lt;a href=&quot;http://codigometropoli.com&quot;&gt;(http://codigometropoli.com)&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;table class=&quot;Tabla_Datos&quot; width=&quot;700&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td width=&quot;138&quot;&gt;&lt;strong&gt;Nombre:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td width=&quot;237&quot;&gt;Juan Carlos&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td width=&quot;169&quot;&gt;&lt;strong&gt;Fecha de Nacimiento:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td width=&quot;156&quot;&gt;20/03/1981&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Pa&amp;iacute;s:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;M&amp;eacute;xico&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Ciudad:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;Distrito Federal&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;N&amp;uacute;mero de Cliente: &lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;541232&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&amp;nbsp;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/table&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> + </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;hr class=&quot;Ruler&quot; /&gt;'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;/body&gt;&lt;/html&gt;'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> writeIOErrorHandler<span style="color: #66cc66;">&#40;</span>event:Event<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al abrir o escribir el archivo"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El resultado final se muestra en la siguiente imagen:</p>
<p style="text-align: center;"><a title="Figura 7: Nuestra aplicación de Adobe AIR en acción" href="../images/screens/ps5sc6.png" target="_blank"><img style="vertical-align: middle;" src="../images/previews/ps5sc6.png" alt="Figura 7: Nuestra aplicación de Adobe AIR en acción" width="334" height="300" /></a></p>
<div style="margin-top:0px; margin-bottom:20px;" align="center">
<table border="0" cellspacing="0" cellpadding="0" width="180">
<tbody>
<tr>
<td valign="top"><a href="http://www.megaupload.com/?d=RXYN7VI1" target="_blank"><img src="../images/descargar_archivo.jpg" alt="Descargar Archivo" /></a></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-top:0px;" align="center">
<script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
     //-->
</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
</div>
<div style="margin-top:30px; margin-bottom:30px;">
<p><strong>Enlaces recomendados:</strong></p>
<p>» <a href="http://www.adobe.com/devnet/air/flex/quickstart/building_text_editor.html" target="_blank">Building a text-file editor</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/crear-archivo-en-air-con-flex-builder-3/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
