<?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; PHP</title>
	<atom:link href="http://www.codigometropoli.com/category/php/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>Introducción a AMFPHP</title>
		<link>http://www.codigometropoli.com/introduccion-a-amfphp/</link>
		<comments>http://www.codigometropoli.com/introduccion-a-amfphp/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 00:56:21 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[AMFPHP]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=411</guid>
		<description><![CDATA[AMFPHP es una implementación en PHP,  gratuita y de código abierto del AMF (Action Message Format), el cual es un formato binario basado en SOAP. AMF permite la serialización binaria de objetos y tipos nativos de ActionScript 2 y ActionScript 3 para ser enviados a servicios del lado del servidor. AMFPHP permite que aplicaciones [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/flash_sticker.jpg" alt="Flash" width="93" height="93" /><a href="http://www.amfphp.org/" target="_blank">AMFPHP</a> es una implementación en PHP,  gratuita y de código abierto del <a href="http://en.wikipedia.org/wiki/Action_Message_Format" target="_blank">AMF</a> (Action Message Format), el cual es un formato binario basado en SOAP. AMF permite la serialización binaria de objetos y tipos nativos de ActionScript 2 y ActionScript 3 para ser enviados a servicios del lado del servidor. AMFPHP permite que aplicaciones realizadas en Flash, Flex y AIR puedan comunicarse  directamente con objetos de clases de PHP.</p>
<p>Prácticamente, la forma en la que funciona se resume en que podemos crear clases en PHP, acceder a los métodos de esas clases por medio de Flash, Flex o AIR y obtener los datos retornados por esos métodos. Por ejemplo, podemos crear una clase para conectarnos a una base de datos en MySQL. Esta clase podría contener un método para insertar datos a la base, otro método para generar consultas y obtener en nuestra aplicación de Flash, Flex o AIR los registros regresados por la consulta.</p>
<p>En esta entrada veremos cómo está formado el AMFPHP y cómo acceder a él desde Flash CS3. Para una mejor explicación de cómo acceder a AMFPHP haremos una sencilla clase en PHP la cual no accederá a ninguna base de datos (eso lo dejaremos para nuestro próximo tutorial).</p>
<p><span id="more-411"></span></p>
<p><span style="color: #ff0000;"><strong>Tutorial</strong></span></p>
<p>1. Baja el archivo amfphp-1.9.beta.20080120.zip de <a href="http://sourceforge.net/project/showfiles.php?group_id=72483&amp;package_id=72363&amp;release_id=541961" target="_blank">aquí</a>. El amfphp-1.9 lo podemos usar con ActionScript 3 (Flash CS3, Flex y AIR), mientras que la versión anterior puede ser usada con ActionScript 2.</p>
<p>2. Descomprímelo y ponlo en algún directorio de tu servidor Web, en tu directorio <strong>htdocs</strong> o <strong>www</strong> en tu <em>localhost</em>. Si lo deseas, puedes renombrar la carpeta y ponerle AMFPHP1.9.</p>
<p>La estructura del directorio quedaría de la siguiente manera (en mi caso, la carpeta AMFPHP1.9 la puse en la carpeta raíz de mi servidor):</p>
<p>--&gt; root ó carpeta raíz<br />
<span style="padding-left: 30px;">--&gt;AMFPHP1.9 (D)</span><br />
<span style="padding-left: 60px;">--&gt; browser (D)</span><br />
<span style="padding-left: 60px;">--&gt; core (D)</span><br />
<span style="padding-left: 60px;">--&gt; services (D)</span><br />
<span style="padding-left: 60px;">--&gt; gateway.php</span><br />
<span style="padding-left: 60px;">--&gt; globals.php</span><br />
<span style="padding-left: 60px;">--&gt; json.php</span><br />
<span style="padding-left: 60px;">--&gt; phpinfo</span><br />
<span style="padding-left: 60px;">--&gt; xmlrpc</span></p>
<p>Donde (D) indica que se trata de un directorio. Observa la carpeta <em>browser</em>, si accediéramos a él desde el navegador observaremos  una aplicación creada en Flex donde nos muestra la lista de servicios que tenemos en AMFPHP, como se muestra en la siguiente <a href="http://www.codigometropoli.com/AMFPHP1.9/browser/" target="_blank">liga</a>. Si es la primera vez que accedes al <em>browser</em>, aparecerá la siguiente ventana de configuración:</p>
<div align="center"><img title="Imagen 1: Ventana de Configuración de AMFPHP" src="http://www.codigometropoli.com/images/screens/amfphp_configuracion_1.jpg" alt="Imagen 1: Ventana de Configuración de AMFPHP" width="514" height="247" /></div>
<p></p>
<p>En esta ventana de configuración deberás asegurarte que la dirección del <em>Gateway</em> es correcta. Después de hacer click en el botón <em>Save</em> te aparecerá la lista de servicios. Por default y cuando todavía no hemos creado ningún servicio nuevo, solamente aparecerá el servicio <em>DiscoveryService</em>. <strong>Importante:</strong> Cuando tenemos servicios que deben acceder a una base de datos o tratan información importante o crítica, lo mejor será no poner el directorio <em>browser</em> en el servidor. Continuando con nuestra estructura de directorios, como podrás imaginar, todos nuestros servicios (clases en PHP) deberán ir en el directorio <em>services</em>.</p>
<p>3. Vamos a crear una sencilla clase de PHP, la cual simulará las operaciones básicas de una calculadora. Sus métodos serán <em>sumar</em>, <em>restar</em>, <em>multiplicar</em> y <em>dividir</em>. Cada método recibirá como parámetro los dos números sobre los cuales hay que hacer la operación. <strong>Nota:</strong> Este tutorial es solamente para explicar cómo funciona AMFPHP y cómo podemos acceder a él desde Flash. Es por eso que nuestra clase de ejemplo es muy sencilla y muchos de ustedes dirán que no se requiere de PHP para sumar, restar, multiplicar y dividir dos números =0).<br />
En PHP, al igual que en Flash, el nombre del archivo de una clase deberá tener el mismo nombre de la clase; por lo tanto, crea un nuevo archivo PHP, nómbralo <strong>Calculadora.php</strong> y guárdalo dentro del directorio <em>services</em> de nuestra carpeta AMFPHP19. Coloca el siguiente código dentro de Calculadora.php:</p>
<div class="igBar"><span id="lphp-8"><a href="#" onclick="javascript:showPlainTxt('php-8'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-8">
<div class="php">
<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:#000000; font-weight:bold;">&lt;?php</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:#000000; font-weight:bold;">class</span> Calculadora</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Suma dos números pasados por parámetro</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; */</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:#000000; font-weight:bold;">function</span> sumar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> + <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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;">&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:#008000;">/**</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:#008000;">&nbsp; &nbsp;&nbsp; * Resta dos números pasados por parámetro</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</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:#008000;">&nbsp; &nbsp;&nbsp; */</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;">function</span> restar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> - <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Multiplica dos números pasados por parámetro</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&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:#000000; font-weight:bold;">function</span> multiplicar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> * <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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; </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:#008000;">/**</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:#008000;">&nbsp; &nbsp;&nbsp; * Divide dos números pasados por parámetro</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</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:#008000;">&nbsp; &nbsp;&nbsp; */</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;">function</span> dividir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> / <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa los comentarios antes de cada función; estos comentarios nos dan una descripción de qué es lo que hace cada método y además le estamos indicando qué es lo que nos regresa cada método (@returns). Si bien estos comentarios no son obligatorios, nos ayudarán a recordar en el momento en que queramos modificar el archivo. Además, dentro de la lista de servicios en el browser, cuando seleccionamos alguno de estos métodos se nos mostrará esta descripción (Como prueba, ingresa al <a href="http://www.codigometropoli.com/AMFPHP1.9/browser/" target="_blank">navegador</a>, de la lista de la izquierda selecciona la clase Calculadora y posteriormente selecciona de la ventana de la derecha el método <em>dividir</em>. Observarás que antes de los campos de texto para ingresar los números aparece la descripción del método). Ahora ingresa un número dentro del campo de texto <em>$numeroA</em> e ingresa otro número dentro del campo <em>$numeroB</em>, haz click en el botón <strong>Call</strong> y observa cómo en el área de resultados (<em>Results</em>) se muestra el resultado regresado por el método <em>dividir</em> de nuestra clase <em>Calculadora</em> en PHP.</p>
<p>4. Dentro de nuestra clase podemos utilizar métodos privados, los cuales no podrán ser utilizados desde el navegador de servicios (<em>browser</em>) ni desde nuestras aplicaciones en Flash, Flex o AIR. Esto es útil cuando dichos métodos realizan operaciones importantes o críticas y que requieran de mayor seguridad. Para establecer que un método es privado, bastará con agregarle un guión bajo (_) antes del nombre. Para hacer la prueba, agrega el siguiente código a la clase Calculadora.php (Insértalo antes de la última llave (}) y del tag de cierre de PHP (?>):</p>
<div class="igBar"><span id="lphp-9"><a href="#" onclick="javascript:showPlainTxt('php-9'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-9">
<div class="php">
<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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Este método es privado y no aparecerá en el browser de servicios</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa la fecha y tiempo del servidor</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&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:#000000; font-weight:bold;">function</span> _esteMetodoEsPrivado<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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:#0000FF;">$fecha_hoy</span> = <a href="http://www.php.net/date"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"d/m/Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">' '</span> . <a href="http://www.php.net/date"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"H:i:s"</span><span style="color:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#0000FF;">$fecha_hoy</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:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa cómo en el código anterior el nombre de la función empieza con guión bajo _, eso quiere decir que se trata de un método privado. El código de este método privado lo que hace es regresarnos la fecha y el tiempo del servidor (por medio del método date).</p>
<p>Desde nuestra clase de PHP podemos acceder a ese método privado por medio de otro método. Para acceder a este método es necesario utilizar la palabra clave <em>$this</em>. A continuación te muestro cómo:</p>
<div class="igBar"><span id="lphp-10"><a href="#" onclick="javascript:showPlainTxt('php-10'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-10">
<div class="php">
<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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Este método es público y está accediendo a nuestro método privado</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa la fecha y tiempo del servidor</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&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:#000000; font-weight:bold;">function</span> obtenFechaServidor<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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:#0000FF;">$fecha_hoy</span> = <span style="color:#0000FF;">$this</span>-&gt;_esteMetodoEsPrivado<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#0000FF;">$fecha_hoy</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:#006600; font-weight:bold;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El método <em>obtenFechaServidor</em> hace un llamado a la función <em>esteMetodoEsPrivado</em> y almacena en la variable <em>$fecha_hoy</em> el valor regresado por el método privado. Este valor es regresado por el método <em>obtenFechaServidor</em>. </p>
<p>Ingresa a nuestro navegador de <a href="http://www.codigometropoli.com/AMFPHP1.9/browser/" target="_blank">servicios</a>, selecciona la clase Calculadora y observa cómo el método <em>esteMetodoEsPrivado</em> no aparece dentro de los métodos de esta clase. Ahora haz click en el botón <em>obtenFechaServidor</em> y posteriormente en el botón <strong>Call</strong>. En el área de resultados (<em>Results</em>) se mostrará la fecha y hora del servidor.</p>
<p>Antes de pasar a la interfaz y al código ActionScript, te dejo el código completo del archivo <em>Calculadora.php</em></p>
<div class="igBar"><span id="lphp-11"><a href="#" onclick="javascript:showPlainTxt('php-11'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-11">
<div class="php">
<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:#000000; font-weight:bold;">&lt;?php</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:#000000; font-weight:bold;">class</span> Calculadora</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Suma dos números pasados por parámetro</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; */</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:#000000; font-weight:bold;">function</span> sumar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> + <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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;">&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:#008000;">/**</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:#008000;">&nbsp; &nbsp;&nbsp; * Resta dos números pasados por parámetro</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</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:#008000;">&nbsp; &nbsp;&nbsp; */</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;">function</span> restar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> - <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Multiplica dos números pasados por parámetro</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&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:#000000; font-weight:bold;">function</span> multiplicar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> * <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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; </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:#008000;">/**</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:#008000;">&nbsp; &nbsp;&nbsp; * Divide dos números pasados por parámetro</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa un valor numérico</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:#008000;">&nbsp; &nbsp;&nbsp; */</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;">function</span> dividir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span>, <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$numeroA</span> / <span style="color:#0000FF;">$numeroB</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#008000;">/**</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * Este método es privado y no aparecerá en el browser de servicios</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:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa la fecha y tiempo del servidor</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&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:#000000; font-weight:bold;">function</span> _esteMetodoEsPrivado<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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:#0000FF;">$fecha_hoy</span> = <a href="http://www.php.net/date"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"d/m/Y"</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">' '</span> . <a href="http://www.php.net/date"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"H:i:s"</span><span style="color:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#0000FF;">$fecha_hoy</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:#006600; font-weight:bold;">&#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; </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:#008000;">/**</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:#008000;">&nbsp; &nbsp;&nbsp; * Este método es público y está accediendo a nuestro método privado</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; * @returns Regresa la fecha y tiempo del servidor</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:#008000;">&nbsp; &nbsp;&nbsp; */</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;">function</span> obtenFechaServidor<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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:#0000FF;">$fecha_hoy</span> = <span style="color:#0000FF;">$this</span>-&gt;_esteMetodoEsPrivado<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#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:#616100;">return</span> <span style="color:#0000FF;">$fecha_hoy</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:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>5. Crea un nuevo documento de Flash en Flash CS3 ActionScript 3.0. Cambia las dimensiones del área de trabajo por 300px de ancho y 190px de alto. Renombra la única capa que existe y ponle de nombre Forma. Agrega 3 textos, 3 TextInput(s) y 4 botones de tal forma que tu forma quede similar a la de la imagen:</p>
<div align="center"><img title="Imagen 2: Forma de nuestra aplicación" src="http://www.codigometropoli.com/images/screens/amfphp_flashcs3_2.jpg" alt="Imagen 2: Forma de nuestra aplicación" width="310" height="198" /></div>
<p></p>
<p>El nombre de instancia de cada uno de los TextInput(s) es (de arriba a abajo):</p>
<ul>
<li>numeroA_txt</li>
</ul>
<ul>
<li>numeroB_txt</li>
</ul>
<ul>
<li>resultado_txt</li>
</ul>
<p>El nombre de instancia de cada uno de los botones es (de arriba a abajo):</p>
<ul>
<li>mas_btn</li>
</ul>
<ul>
<li>menos_btn</li>
</ul>
<ul>
<li>por_btn</li>
</ul>
<ul>
<li>entre_btn</li>
</ul>
<p>6. Agrega otra capa y ponle de nombre <em>Acciones</em>. Agrega el siguiente código a dicha capa:</p>
<div class="igBar"><span id="lactionscript-12"><a href="#" onclick="javascript:showPlainTxt('actionscript-12'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-12">
<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;">/* Las siguientes librerías son necesarias para hacer las llamadas y conexión a AMFPHP */</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;">net</span>.<span style="color: #0066CC;">NetConnection</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;">net</span>.<span style="color: #006600;">Responder</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: #808080; font-style: italic;">/* Dentro de la variable gateway especificamos la URL completa de donde se encuentra nuestro archivo gateway.php. Si estás trabajando en local, es posible que tu URL sea similar a&nbsp; http://localhost/AMFPHP1.9/gateway.php */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> gateway:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://localhost/AMFPHP1.9/gateway.php"</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;">/* Creamos una variable de tipo NetConnection para poder establecer la conexión. Este objeto funcionará como enlace entre el cliente y el servidor */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> conexion:<span style="color: #0066CC;">NetConnection</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</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;">/* Establecemos una conexión bidireccional entre el Flash Player y el servidor */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span>gateway<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: #808080; font-style: italic;">/* Este objeto de clase Responder se encargará de administrar los valores que son regresados por el servidor, ya sea si la operación fue todo un éxito o si hubo un error */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> responder:Responder;</div>
</li>
<li style="font-family: 'Courier 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;">/* Deshabilitamos el campo de texto donde se mostrará el resultado para que sea sólo de lectura */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">resultado_txt.<span style="color: #0066CC;">enabled</span> = <span style="color: #000000; font-weight: bold;">false</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Revisa con atención el código anterior y los comentarios que están insertados en él. Hasta ahora solamente hemos importado las librerías que necesitamos, hemos declarado e instanciado las variables que usaremos a lo largo del programa.</p>
<p>Coloca el siguiente código debajo del anterior. Aquí estamos declarando cuatro métodos que serán llamados dependiendo de si el usuario hizo click en el botón de mas, menos, por o entre. Observa bien que el código de cada uno de estos métodos sólo cambia en la llamada de los métodos de la clase (la última línea de cada método, antes de }), es por eso que sólo comentaré la primera función (suma).</p>
<div class="igBar"><span id="lactionscript-13"><a href="#" onclick="javascript:showPlainTxt('actionscript-13'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-13">
<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: #000000; font-weight: bold;">function</span> suma<span style="color: #66cc66;">&#40;</span>evento:MouseEvent<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;">/* Obtenemos el valor ingresado en cada uno de los campos de texto&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: #000000; font-weight: bold;">var</span> numeroA:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroA_txt.<span style="color: #0066CC;">text</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: #000000; font-weight: bold;">var</span> numeroB:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroB_txt.<span style="color: #0066CC;">text</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; </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;">/* Le especificamos a la variable responder qué métodos debe llamar en caso de éxito (método respuesta) o en caso de error (método error)&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; responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>respuesta, <span style="color: #0066CC;">error</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; </div>
</li>
<li style="font-family: 'Courier New', Courier, 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: #808080; font-style: italic;">/* Invocamos, por medio del método call, al método sumar que se encuentra en la clase Calculadora (Calculadora.sumar). El segundo parámetro del método call es nuestro objeto de la clase Responder (el que se encargará de gestionar los valores obtenidos de dicha llamada. Por último, le pasamos como cuarto y quinto parámetro los dos números que deberá recibir la función sumar. */</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: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Calculadora.sumar"</span>, responder, numeroA, numeroB<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: #000000; font-weight: bold;">function</span> resta<span style="color: #66cc66;">&#40;</span>evento:MouseEvent<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> numeroA:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroA_txt.<span style="color: #0066CC;">text</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> numeroB:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroB_txt.<span style="color: #0066CC;">text</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; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; operacion_mc.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"menos"</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; responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>respuesta, <span style="color: #0066CC;">error</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; </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: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Calculadora.restar"</span>, responder, numeroA, numeroB<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: #000000; font-weight: bold;">function</span> multiplicacion<span style="color: #66cc66;">&#40;</span>evento:MouseEvent<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> numeroA:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroA_txt.<span style="color: #0066CC;">text</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> numeroB:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroB_txt.<span style="color: #0066CC;">text</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; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; operacion_mc.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"por"</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; responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>respuesta, <span style="color: #0066CC;">error</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; </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: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Calculadora.multiplicar"</span>, responder, numeroA, numeroB<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: #000000; font-weight: bold;">function</span> division<span style="color: #66cc66;">&#40;</span>evento:MouseEvent<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> numeroA:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroA_txt.<span style="color: #0066CC;">text</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> numeroB:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>numeroB_txt.<span style="color: #0066CC;">text</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; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; operacion_mc.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"entre"</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; responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>respuesta, <span style="color: #0066CC;">error</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; </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: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Calculadora.dividir"</span>, responder, numeroA, numeroB<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 del código anterior solamente nos faltan los métodos respuesta y error, además de las acciones de cada uno de nuestros botones:</p>
<div class="igBar"><span id="lactionscript-14"><a href="#" onclick="javascript:showPlainTxt('actionscript-14'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-14">
<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;">/* En caso de éxito tras ejecutar el método call, esta función es llamada pasándole como parámetro un objeto con el resultado regresado. Este resultado lo mostraremos dentro del TextInput resultado_txt. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> respuesta<span style="color: #66cc66;">&#40;</span>resultado:<span style="color: #0066CC;">Object</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; resultado_txt.<span style="color: #0066CC;">text</span> = <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span>resultado<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>
<li style="font-family: 'Courier New', 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: #808080; font-style: italic;">/* En caso de error tras ejecutar el método call, esta función es llamada pasándole como parámetro un objeto con el error generado. Este error lo desplegaremos dentro de un trace. */</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: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">error</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:<span style="color: #0066CC;">Object</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: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #006600;">description</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: #808080; font-style: italic;">/* Establecemos las acciones de nuestros botones */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">mas_btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, suma<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;">menos_btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, resta<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;">por_btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, multiplicacion<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;">entre_btn.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>MouseEvent.<span style="color: #006600;">CLICK</span>, division<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A continuación puedes ver el SWF funcionando. A este archivo le añadí un campo de texto dinámico en el lado inferior derecho en el cual muestro el resultado de hacer una llamada al método <em>obtenFechaServidor</em> de nuestra clase Calculadora. No olvides bajar los archivos de este tutorial que se encuentran al final de esta entrada.</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 align="center" style="margin-top:30px; margin-bottom:20px; border:1px solid #000000; width=300px; height=220px;">
<object width="300" height="220">
<param name="movie" value="http://codigometropoli.com/wp-content/uploads/2008/09/introduccion-a-amfphp.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="300" height="220" src="http://codigometropoli.com/wp-content/uploads/2008/09/introduccion-a-amfphp.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</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=3A3IFW7X" target="_blank"><img src="http://codigometropoli.com/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://www.amfphp.org/" target="_blank">Sitio del AMFPHP</a><br />
» <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetConnection.html" target="_blank">ActionScript 3.0 Language and Components Reference (Clase NetConnection) </a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/introduccion-a-amfphp/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Enviar Formulario de Contacto</title>
		<link>http://www.codigometropoli.com/enviar-formulario-de-contacto/</link>
		<comments>http://www.codigometropoli.com/enviar-formulario-de-contacto/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 05:39:16 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[contacto]]></category>
		<category><![CDATA[formulario]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=21</guid>
		<description><![CDATA[Para poder enviar un formulario de contacto en Flash es necesario utilizar un lenguaje del lado del servidor que permita enviar el correo con los datos que el usuario introdujo en Flash. Algunos ejemplos de estos lenguajes del lado de servidor son PHP, JSP y ASP.
En este ejemplo veremos cómo enviar por mail un formulario [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/flash_php_sticker.jpg" alt="Flash y PHP" width="93" height="93" />Para poder enviar un formulario de contacto en Flash es necesario utilizar un lenguaje del lado del servidor que permita enviar el correo con los datos que el usuario introdujo en Flash. Algunos ejemplos de estos lenguajes del lado de servidor son PHP, JSP y ASP.<br />
En este ejemplo veremos cómo enviar por mail un formulario de contacto usando PHP.</p>
<p style="text-align: left;"><span id="more-21"></span>Para fines de este tutorial, se pondrán en el formulario algunos de los componentes que ya vimos en los post pasados. Estos componentes son <a href="http://www.codigometropoli.com/componente-combobox" target="_blank">ComboBox</a>, <a href="http://www.codigometropoli.com/componente-radiobutton">RadioButton </a>y <a href="http://www.codigometropoli.com/componente-checkbox">CheckBox</a>.</p>
<p style="text-align: left;">Para este tutorial usaremos Flash 8. El ejemplo y los archivos de este tutorial los encuentras al final de esta entrada.</p>
<p style="text-align: left;"><img style="float: left;" src="../images/nota.jpg" alt="Nota" /> Por razones de seguridad, el ejemplo que se encuentra al final de este post no enviará  ningún correo electrónico (para evitar que se llene el buzón o llegue puro correo basura). En lugar de mandar el correo electrónico mostraré el resultado final de cómo se vería el correo electrónico (tanto en formato HTML como en formato de texto plano). Sin embargo, los archivos de esta entrada y el código aquí pegado, sí tienen la instrucción para enviar el correo electrónico.</p>
<p><span style="color: #560e00;"><span style="text-decoration: underline;"><strong>Tutorial<br />
</strong></span></span></p>
<p style="text-align: left;"><strong>I. Haciendo el formulario en <span style="color: #993300;">Flash</span></strong></p>
<p style="text-align: left;">1. Crea un nuevo documento de Flash de 420px por 380px.</p>
<p style="text-align: left;">2. Arrastra al escenario los siguientes componentes (recuerda que estos componentes están dentro de la sección <strong>User Interface</strong> del panel <strong>Components </strong>(Ctrl. + F7) :</p>
<ul>
<li>2 Campos de texto (TextInput)</li>
<li>2 Botones de Radio (RadioButton)</li>
<li>1 ComboBox</li>
<li>5 CheckBoxes</li>
<li>1 TextArea</li>
<li>1 Botón (Button)</li>
</ul>
<p>Además, crea 5 textos dinámicos con el (*) como texto (estos los usaremos para mostrar los campos obligatorios que el usuario debe llenar. Para este ejemplo, haremos que todos los datos sean obligatorios). A estos textos, ponles como nombre de instancia msj1, msj2, msj3, etc.</p>
<p>3. Selecciona cada componente que arrastraste al escenario y ponle los siguientes nombres de instancia (dentro del Panel Propiedades):</p>
<ul>
<li>1er Campo de texto (TextInput)  -&gt; nombre_txt</li>
<li>2do Campo de texto (TextInput)  -&gt; correo_txt</li>
<li>1er Botón de Radio (RadioButton) -&gt; radio1</li>
<li>2do Botón de Radio (RadioButton) -&gt; radio2</li>
<li>ComboBox -&gt; pais_cb</li>
<li>1er CheckBox -&gt; check1, 2do CheckBox -&gt; check2, 3er CheckBox -&gt; check3, 4to CheckBox -&gt; check4, 5to CheckBox -&gt; check5</li>
<li>TextArea -&gt; comentarios_txt</li>
<li>Botón -&gt; enviar_btn</li>
</ul>
<p>4. Además, cambia los siguientes parámetros (tercera pestaña del panel Propiedades) a estos componentes:</p>
<ul>
<li>radio1: <strong>data </strong>= F, <strong>groupName </strong>= sexoGroup, <strong>label </strong>= Femenino</li>
<li>radio2: <strong>data </strong>= M, <strong>groupName </strong>= sexoGroup, <strong>label </strong>= Masculino</li>
<li>check1: <strong>label</strong> = Flash</li>
<li>check2: <strong>label</strong> = Flex</li>
<li>check3: <strong>label</strong> = AIR</li>
<li>check4: <strong>label</strong> = PHP</li>
<li>check5: <strong>label</strong> = Ajax</li>
</ul>
<p>5. Acomoda todos los componentes anteriores para que te queden similar a la siguiente imagen:</p>
<p style="text-align: center;"><img src="http://www.codigometropoli.com/images/screens/ps11sc1.png" alt="" /></p>
<p style="text-align: left;">6. Es momento de escribir el código. A la capa (layer) existente asígnale el nombre de <em>Forma</em>. Crea una nueva capa llamada <em>Acciones</em>. En el panel <strong>Actions</strong> de esta capa escribe lo siguiente:</p>
<div class="igBar"><span id="lactionscript-20"><a href="#" onclick="javascript:showPlainTxt('actionscript-20'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-20">
<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 la librería del componente Alert</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> 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;"><span style="color: #808080; font-style: italic;">// Sólo por estética, cambiamos el color del tema (cambiamos el verde que aparece por default)</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">_global</span>.<span style="color: #006600;">style</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"themeColor"</span>, 0xCCFFFF<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: #808080; font-style: italic;">/* Esta línea es importante para que todo lo que el usuario escriba o seleccione tenga acentos, se muestren de forma correcta y no con caracteres raros (Ej. Ã) */</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;">System</span>.<span style="color: #0066CC;">useCodepage</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;"><span style="color: #808080; font-style: italic;">/* Creamos un arreglo para guardar los temas seleccionados por el usuario (es decir, las opciones de los checkboxes que el usuario seleccionó) */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> temas:<span style="color: #0066CC;">Array</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>;</div>
</li>
<li style="font-family: 'Courier 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;">/* En el arrelgo paises gaurdaremos los datos que aparecerán en el combobox de países */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> paises:<span style="color: #0066CC;">Array</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>;</div>
</li>
<li style="font-family: 'Courier 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;">/* Creamos dos objetos de la clase LoadVars, uno para enviar los datos introducidos por el usuario y el otro para recibir la respuesta enviada por el archivo de PHP */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> enviar_lv:<span style="color: #0066CC;">LoadVars</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">LoadVars</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;"><span style="color: #000000; font-weight: bold;">var</span> resultado_lv:<span style="color: #0066CC;">LoadVars</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">LoadVars</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;"><span style="color: #808080; font-style: italic;">/* Hacemos la llamada a la función initForm, la cual a su vez llamará a otras funciones para, por ejemplo, llenar el combobox de los paises, cambiarle el estilo a los botones de radio, etc. El código de esta función está en el siguiente bloque de código ActionScript. */</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;">initForm<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p style="text-align: left;">El código anterior muestra la declaración variables e importación de clases necesarias (en este caso sólo una clase). Ahora nos enfocaremos en las funciones que escribiremos en nuestro código.</p>
<div class="igBar"><span id="lactionscript-21"><a href="#" onclick="javascript:showPlainTxt('actionscript-21'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-21">
<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 función llama a los métodos encargados de cambiar los estilos de los botones de radio, checkboxes, etc. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> initForm<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; escondeMensajes<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; setEstilosRadioButtons<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; setEstilosCheckBoxes<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; llenaComboPaises<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;"><span style="color: #808080; font-style: italic;">/* Escondemos (no mostramos) los mensajes que le indicarán al usuario qué campos le faltó introducir. Es decir, los campos obligarios marcados por (*). */</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: #000000; font-weight: bold;">function</span> escondeMensajes<span style="color: #66cc66;">&#40;</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; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">7</span>; i++<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: #66cc66;">&#91;</span><span style="color: #ff0000;">"msj"</span> + i<span style="color: #66cc66;">&#93;</span>.<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; <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;"><span style="color: #808080; font-style: italic;">/* Le cambiamos el formato a los botones de radio. Si no entiendes esta parte, por favor revisa el post sobre el componente RadioButton */</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: #000000; font-weight: bold;">function</span> setEstilosRadioButtons<span style="color: #66cc66;">&#40;</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; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">3</span>; i++<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: #66cc66;">&#91;</span><span style="color: #ff0000;">"radio"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"color"</span>, 0x990000<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: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"radio"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"fontWeight"</span>, <span style="color: #ff0000;">"bold"</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: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"radio"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"marginLeft"</span>, <span style="color: #cc66cc;color:#800000;">2</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;"><span style="color: #808080; font-style: italic;">/* Le cambiamos el formato a los checkboxes. Si no entiendes esta parte, por favor revisa el post sobre el componente CheckBox */</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: #000000; font-weight: bold;">function</span> setEstilosCheckBoxes<span style="color: #66cc66;">&#40;</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; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">6</span>; i++<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: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"color"</span>, 0x990000<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: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"fontWeight"</span>, <span style="color: #ff0000;">"bold"</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: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">setStyle</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"marginLeft"</span>, <span style="color: #cc66cc;color:#800000;">2</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;"><span style="color: #808080; font-style: italic;">/* Esta función llena el arreglo países con las opciones que nos interesa mostrar en el combobox de países. Después de llenar el arreglo se lo asignamos como dataProvider al combobox pais_cb y le decimos que ordene las opciones de acuerdo a su etiqueta (label). Si no entiendes esta parte, por favor revisa el post sobre el componente ComboBox */</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: #000000; font-weight: bold;">function</span> llenaComboPaises<span style="color: #66cc66;">&#40;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"-- Selecciona --"</span>, &nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #cc66cc;color:#800000;">0</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"México"</span>, &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"MEX"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"España"</span>, &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"ESP"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Colombia"</span>,&nbsp;&nbsp; &nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"COL"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Argentina"</span>, &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"ARG"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Chile"</span>,&nbsp;&nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"CHI"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Perú"</span>,&nbsp;&nbsp;&nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"PER"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Venezuela"</span>, &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"VEN"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Ecuador"</span>, &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"ECU"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Costa Rica"</span>, &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"COS"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Uruguay"</span>, &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"URU"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Bolivia"</span>, &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"BOL"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Estados Unidos"</span>, &nbsp; &nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"EUA"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Guatemala"</span>, &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"GUA"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Brasil"</span>, &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"BRA"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Cuba"</span>, &nbsp;&nbsp;&nbsp;<span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"CUB"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Panamá"</span>, &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"PAN"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"El Salvador"</span>, &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"SAL"</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Nicaragua"</span>, &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"NIC"</span><span style="color: #66cc66;">&#125;</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; paises.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>label:<span style="color: #ff0000;">"Otro"</span>,&nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">data</span>:<span style="color: #ff0000;">"Otr"</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; pais_cb.<span style="color: #006600;">dataProvider</span> = paises;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; pais_cb.<span style="color: #006600;">sortItemsBy</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"label"</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 style="text-align: left;">Las siguientes funciones son vitales para el tratamiento del formulario:</p>
<div class="igBar"><span id="lactionscript-22"><a href="#" onclick="javascript:showPlainTxt('actionscript-22'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-22">
<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;">/* Asignamos las acciones al botón de Enviar. En este caso, el botón de Enviar hará el llamado a la función validaForma para verificar que el usuario haya llenado los campos obligatorios. Como lo dije anteriormente, para este ejemplo haremos que el usuario tenga que llenar todos los campos. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">enviar_btn.<span style="color: #0066CC;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; validaForma<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;"><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: #808080; font-style: italic;">/* Esta función se encarga de validar que todos los campos obligatorios fueron llenados. Primero hacemos llamamos a la función escondeMensajes para no mostrar los campos dinámicos (msj1, msj2, etc.) en caso de que sea la segunda vez que se llama a la función validaForma. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><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: #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; escondeMensajes<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: #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;">// Vemos si el campo de texto del nombre está vacío</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; msj1.<span style="color: #0066CC;">_visible</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #808080; font-style: italic;">// Como el campo del nombre no fue llenado, mostramos el primer mensaje</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; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Colocamos el foco o cursor en el campo del 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; <span style="color: #66cc66;">&#125;</span> <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> || !esCorreo<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> <span style="color: #808080; font-style: italic;">/* Vemos si el campo del correo está vacío y sí el formato del correo es correcto */</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>; <span style="color: #808080; font-style: italic;">/* Mostramos el segundo mensaje ya que el campo del correo está vacío o bien el formato es incorrecto */</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>; <span style="color: #808080; font-style: italic;">// Ponemos el cursos en el campo del correo</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> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>sexoGroup.<span style="color: #0066CC;">selection</span>.<span style="color: #0066CC;">data</span> == <span style="color: #0066CC;">undefined</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si se cumple esta sentencia quiere decir que el usuario no seleccionó ninguna opción de los botones de radio */</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; msj3.<span style="color: #0066CC;">_visible</span> = <span style="color: #000000; font-weight: bold;">true</span>; <span style="color: #808080; font-style: italic;">// Mostramos el tercer mensaje</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; radio1.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Ponemos el cursor en el primer botón de radio</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> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>pais_cb.<span style="color: #006600;">selectedIndex</span> == <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si se cumple este condicional quiere decir que el usuario no seleccionó ninguna opción del combobox de los países. Si el índice seleccionado (selectedIndex) es igual a 0, entonces la opción seleccionada es la que dice &quot;-- Seleccionar --&quot;, por lo tanto no nos interesa que el usuario use esa opción */</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; pais_cb.<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> <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; temas = buscaChecksSeleccionados<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Guardamos en el arreglo temas los valores de los checkboxes que el usuario seleccionó. La función buscaChecksSeleccionados nos regresa un arreglo con los valores de los checkboxes seleccionados */</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>temas.<span style="color: #0066CC;">length</span> == <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si la longitud del arreglo temas es igual a 0, entonces el usuario no seleccionó ninguna opción; por lo tanto, mostramos el quinto mensaje y ponemos el cursor en el primer checkbox */</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; msj5.<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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; check1.<span style="color: #0066CC;">setFocus</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: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>comentarios_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 la caja de texto de los comentarios está vacía, mostramos el sexto mensaje y posicionamos el cursor en la caja de texto (TextArea) */</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; msj6.<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; &nbsp; &nbsp; comentarios_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; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si ninguno de los condicionales anteriores se cumplió, quiere decir que el usuario llenó todos los campos necesarios. Mandamos a llamar la función enviarCorreo */</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; enviarCorreo<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; <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>
<li style="font-family: 'Courier 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 función regresa un arreglo con los valores de los CheckBox(es) seleccionados. Recorremos todos los componentes checkbox por medio de un ciclo for y vemos el valor de la propiedad &quot;selected&quot; de cada uno de ellos. Si no entiendes esta parte, por favor revisa el post sobre el componente CheckBox&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: #000000; font-weight: bold;">function</span> buscaChecksSeleccionados<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Array</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; <span style="color: #000000; font-weight: bold;">var</span> temp = <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>;</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;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">6</span>; i++<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: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">selected</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; temp.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">label</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; <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;">return</span> temp;</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;"><span style="color: #808080; font-style: italic;">/* Esta función nos permite revisar si el formato del correo electrónico es correcto. Es decir, que contenga @, el punto xxx, etc. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> esCorreo<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>
</ol>
</div>
</div>
</div>
<p></p>
<p style="text-align: left;">El siguiente código muestra el script de la función enviarCorreo.</p>
<div class="igBar"><span id="lactionscript-23"><a href="#" onclick="javascript:showPlainTxt('actionscript-23'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-23">
<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;">/* Explicación: Primero desactivamos el botón de enviar para que el usuario no haga click más de una vez. Al objeto enviar_lv de la clase LoadVars le copiamos el valor de cada uno de los campos del formulario y los enviamos al archivo de PHP (enviar_formulario_de_contacto.php). A la función sendAndLoad del objeto enviar_lv, le pasamos como parámetro el path del archivo que recibirá los datos, el objeto de la clase LoadVars que recibirá la respuesta y el método en cómo se enviarán los datos (POST o GET). Este último parámetro es opcional y por default el valor es de POST.&nbsp; NOTA: Si quieres cargar el resultado del archivo pasado como primer parámetro, deberás usar la función send. En los archivos de este tutorial que encuentras más abajo en un archivo zip, usamos la función sendAndLoad ya que nos interesa mostrar un mensaje de alerta (con el resultado) dentro del mismo Flash y no dentro del PHP. Sin embargo, el ejemplo que se encuentra más abajo utiliza la función send para mostrar dentro del mismo PHP el mensaje del correo electrónico en formato HTML y Texto Plano. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> enviarCorreo<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; enviar_btn.<span style="color: #0066CC;">enabled</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; enviar_lv.<span style="color: #006600;">nombre</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; enviar_lv.<span style="color: #006600;">correo</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; enviar_lv.<span style="color: #006600;">sexo</span> = sexoGroup.<span style="color: #0066CC;">selection</span>.<span style="color: #0066CC;">data</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; enviar_lv.<span style="color: #006600;">pais</span> = pais_cb.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">label</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; enviar_lv.<span style="color: #006600;">temas</span> = temas;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; enviar_lv.<span style="color: #006600;">comentarios</span> = comentarios_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; enviar_lv.<span style="color: #0066CC;">sendAndLoad</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"enviar_formulario_de_contacto.php"</span>, resultado_lv, <span style="color: #ff0000;">"POST"</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;"><span style="color: #808080; font-style: italic;">/* El evento onLoad del objeto resultado_lv es invocado cuando la llamada a los métodos load() o sendAndLoad() ha sido terminada. Asignamos el resultado regresado por el PHP a la variable respuesta. Si la llamada fue exitosa, vemos si la respuesta es igual a 'S', si es así mostramos un mensaje señalando que el mensaje ha sido enviado y llamamos a la función reestablecerForma para borrar los datos ingresados por el usuario. Si la respuesta es distinto a 'S' o bien si la llamada no fue exitosa, mostramos un mensaje señalando que hubo un error en el envío. Por último, volvemos a activar el botón de enviar. */</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;">resultado_lv.<span style="color: #0066CC;">onLoad</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>success:<span style="color: #0066CC;">Boolean</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;"><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: #000000; font-weight: bold;">var</span> respuesta = <span style="color: #0066CC;">this</span>.<span style="color: #006600;">resultado</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;">if</span><span style="color: #66cc66;">&#40;</span>success<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;">&#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: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>respuesta == <span style="color: #ff0000;">"S"</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;">&#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; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Su mensaje ha sido enviado."</span>, <span style="color: #ff0000;">"Gracias"</span>, Alert.<span style="color: #006600;">OK</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #ff0000;">"alerta"</span>, Alert.<span style="color: #006600;">OK</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; reestablecerForma<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: #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; <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; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Hubo un error en el envío del mensaje, por favor intente más tarde."</span>, <span style="color: #ff0000;">"Error"</span>, Alert.<span style="color: #006600;">OK</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #ff0000;">"alerta"</span>, Alert.<span style="color: #006600;">OK</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; <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></div>
</li>
<li style="font-family: 'Courier New', Courier, 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;">"Hubo un error en el envío del mensaje, por favor intente más tarde."</span>, <span style="color: #ff0000;">"Error"</span>, Alert.<span style="color: #006600;">OK</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #ff0000;">"alerta"</span>, Alert.<span style="color: #006600;">OK</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; enviar_btn.<span style="color: #0066CC;">enabled</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;"><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: #808080; font-style: italic;">/* Esta función borra los datos introducidos por el usuario. */</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: #000000; font-weight: bold;">function</span> reestablecerForma<span style="color: #66cc66;">&#40;</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; 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; 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; desactivarSexo<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; desactivarTemas<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; pais_cb.<span style="color: #006600;">selectedIndex</span> = <span style="color: #cc66cc;color:#800000;">0</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; comentarios_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>
<li style="font-family: 'Courier 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;">/* Su función es poner todos los botones de radio como no seleccionados */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> desactivarSexo<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; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">3</span>; i++<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;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"radio"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">selected</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: #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>
<li style="font-family: 'Courier 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;">/* Su función es poner todos los CheckBox(es) como no seleccionados */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> desactivarTemas<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; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;color:#800000;">1</span>; i &lt;<span style="color: #cc66cc;color:#800000;">6</span>; i++<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;">this</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">"check"</span> + i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">selected</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: #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 style="text-align: left;">Ese es todo el código que deberá llevar el documento de Flash.</p>
<p style="text-align: left;"><strong>II. Programando el script en <span style="color: #993300;">PHP</span> para el envío del correo</strong></p>
<p style="text-align: left;">A continuación pegaré todo el código del archivo enviar_formulario_de_contacto.php. Dentro del código están los comentarios para que puedas entender qué hace cada línea de código.</p>
<div class="igBar"><span id="lphp-24"><a href="#" onclick="javascript:showPlainTxt('php-24'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-24">
<div class="php">
<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;html&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;head&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;/head&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;body&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;"><span style="color:#000000; font-weight:bold;">&lt;?php</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">/**</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:#008000;"> * @author Carla Mací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:#008000;"> * @copyright 2008</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:#008000;"> * @url http://codigometropoli.com/</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> */</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:#008000;">/* 1. Recibimos las variables que mandamos por Flash.</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;"> &nbsp; &nbsp;&nbsp; Para recibirlas usaremos la matriz asociativa $_POST, la cual contiene los valores del formulario enviados por medio de LoadVars.</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:#008000;">&nbsp; &nbsp;&nbsp; &nbsp;Importante: Los nombres de variables que recibe $_POST deberán ser</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">&nbsp; &nbsp;&nbsp; &nbsp;iguales a las variables enviadas por Flash. Con lo anterior, me refiero a la variable que está dentro de los [] de $_POST. */</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:#0000FF;">$nombre</span> = <a href="http://www.php.net/stripslashes"><span style="color:#000066;">stripslashes</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"nombre"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#008000;">/* Campo de texto corto (TextField) */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$correo</span> = <span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"correo"</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#008000;">/* Campo de texto corto (TextField) */</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:#0000FF;">$sexo</span>&nbsp; &nbsp;= <span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"sexo"</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#008000;">/* Botón de Radio. Esta variable trae la etiqueta del botón de radio seleccionado por el usuario. Debido a que el usuario solamete puede escoger una opción, basta con recibir el valor por medio de $_POST */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$pais</span>&nbsp; &nbsp;= <span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"pais"</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#008000;">/* ComboBox. Igual que en el anterior, estamos recibiendo el valor de la etiqueta de la opción seleccionada por el usuario; basta con recibirla por medio de $_POST */</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:#0000FF;">$temas</span>&nbsp; = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">','</span>,<span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"temas"</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#008000;">/* CheckBox. Debido a que el usuario pudo haber seleccionado más de una opción, esta variable hay que tratarla de forma distinta. Esta variable trae todos los valores del arreglo (que usamos para guardar los valores de los checkbox seleccionados) separados por comas. Por ejemplo: opcion 1,opcion 2,opcion 3.</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000;">En este ejemplo, vamos a mostrar los temas en forma de lista, por lo que haremos uso del método explode en PHP. Para más información sobre el método explode visita http://www.php.net/manual/es/function.explode.php para más información&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:#0000FF;">$comentarios</span> = <span style="color:#0000FF;">$_POST</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">"comentarios"</span><span style="color:#006600; font-weight:bold;">&#93;</span>; <span style="color:#008000;">/* TextArea. Es posible que la información en este campo introducida por el usuario sea larga y que lleve saltos de línea. Para mostrarlo de igual forma en el correo usaremos la función nl2br (ver 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:#0000FF;">$formatos</span> = <a href="http://www.php.net/array"><span style="color:#000066;">array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"text/html"</span>, <span style="color:#FF0000;">"text/plain"</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#008000;">/* No modificar, solamente estoy declarando un arreglo */</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:#008000;">/* 2. Declaramos las variables sobre el correo electrónico. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$remitente</span> = <span style="color:#FF0000;">"no-reply@codigometropoli.com"</span>; <span style="color:#008000;">/* Cuenta de correo de donde se &quot;manda&quot;&quot; el mail. En este caso no importa que la cuenta de correo exista, ni que sea similar a no-reply@, web@, contacto@, etc ya que este formulario de contacto le estaría llegando al webmaster o los de ventas, relaciones públicas, etc. */</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:#0000FF;">$para</span> = <span style="color:#FF0000;">"msj1@codigometropoli.com,msj2@codigometropoli.com"</span>; <span style="color:#008000;">/* Cuenta de correo a donde se enviarán los mails. Separar por comas en caso de que sean más de uno. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$asunto</span> = <span style="color:#FF0000;">"Mensaje desde Código Metrópoli"</span>; <span style="color:#008000;">/* Asunto que aparecerá en el correo electrónico */</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:#0000FF;">$formato_correo</span> = <span style="color:#CC66CC;color:#800000;">0</span>; <span style="color:#008000;">/* IMPORTANTE: Aquí pon el valor de 0 si quieres que el formato del correo sea HTML y 1 si quieres que sea texto plano. 0 --&gt; HTML,&nbsp; &nbsp; 1 -&gt; Texto Plano */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;p&gt;<span style="color:#008000;">/* 3. Establecemos las cabeceras (headers) del mail. &quot;Bcc: &quot; . $cc . */</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:#0000FF;">$header</span>&nbsp; = <span style="color:#FF0000;">"MIME-Version: 1.0<span style="color:#000099; font-weight:bold;">\r</span><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;"><span style="color:#0000FF;">$header</span> .= <span style="color:#FF0000;">"Content-type: "</span> . <span style="color:#0000FF;">$formatos</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$formato_correo</span><span style="color:#006600; font-weight:bold;">&#93;</span> . <span style="color:#FF0000;">"; charset=iso-8859-1<span style="color:#000099; font-weight:bold;">\r</span><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;"><span style="color:#0000FF;">$header</span> .= <span style="color:#FF0000;">"From: "</span> . <span style="color:#0000FF;">$remitente</span> . <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;"><span style="color:#008000;">/* Nota: Si deseas agregar correos de copia o copia oculta, descomenta las siguientes líneas (es decir, borra las // de las siguientes dos líneas) */</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:#FF9933; font-style:italic;">//$header .= &quot;Cc: copia1@codigometropoli.com,copia2@codigometropoli.com \n&quot;;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">//$header .= &quot;Bcc: copiaoculta1@codigometropoli.com,copiaoculta2@codigometropoli.com \n&quot;;</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:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$nombre</span> != <span style="color:#FF0000;">""</span> &amp;&amp; <span style="color:#0000FF;">$correo</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#FF9933; font-style:italic;">// Siempre es bueno asegurarse que recibimos los datos más importantes para no mandar correos vacíos</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:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$formato_correo</span> == <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#008000;">/* 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; &nbsp; <span style="color:#0000FF;">$mensaje</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:#FF0000;">&lt;style type=&quot;text/css&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;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--</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; .Estilo1 {</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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-family: Arial;</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; font-size: 14px;</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;">&nbsp; &nbsp; &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:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; .Tabla_Contacto td {</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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding:5px 5px 10px 5px;&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:#FF0000;">&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;">&nbsp; &nbsp; &nbsp; &nbsp; .Estilo2 {</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; color: #990000;</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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; font-weight: bold;</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; }</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;">&nbsp; &nbsp; &nbsp; &nbsp; hr {</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; color:#003366;</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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background-color:#003366;</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; height:5px;</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;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width:450px;</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; margin-left:0px;</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;">&nbsp; &nbsp; &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:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; --&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;"><span style="color:#FF0000;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/style&gt;</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;">&lt;p&gt;&nbsp;&nbsp;&lt;span class=&quot;Estilo1&quot;&gt;&lt;span class=&quot;Estilo2&quot;&gt;'</span> . <span style="color:#0000FF;">$asunto</span> . <span style="color:#FF0000;">'&lt;/span&gt;&lt;/span&gt;&lt;/p&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;"><span style="color:#FF0000;">&lt;hr /&gt;</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;">&lt;table width=&quot;438&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;Tabla_Contacto&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td width=&quot;111&quot; class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Nombre:&lt;/strong&gt;&lt;/td&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;"><span style="color:#FF0000;">&lt;td width=&quot;327&quot; class=&quot;Estilo1&quot;&gt;'</span> . <span style="color:#0000FF;">$nombre</span> . <span style="color:#FF0000;">'&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Email:&lt;/strong&gt;&lt;/td&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&gt;'</span> . <span style="color:#0000FF;">$correo</span> . <span style="color:#FF0000;">'&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Sexo:&lt;/strong&gt;&lt;/td&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&gt;'</span> . <span style="color:#0000FF;">$sexo</span> . <span style="color:#FF0000;">'&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Pa&amp;iacute;s:&lt;/strong&gt;&lt;/td&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&gt;'</span> . <span style="color:#0000FF;">$pais</span> . <span style="color:#FF0000;">'&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Temas:&lt;/strong&gt;&lt;/td&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&gt;&amp;nbsp;&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;tr&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&amp;nbsp;&lt;/td&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&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; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span> = <span style="color:#CC66CC;color:#800000;">0</span>; <span style="color:#0000FF;">$i</span> &lt;count<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$temas</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#0000FF;">$i</span>++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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; &nbsp; <span style="color:#0000FF;">$mensaje</span> .= <span style="color:#0000FF;">$temas</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#93;</span> . <span style="color:#FF0000;">"&lt;br /&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; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#0000FF;">$mensaje</span> .=&nbsp; <span style="color:#FF0000;">'&lt;/td&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;"><span style="color:#FF0000;">&lt;/tr&gt;</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;">&lt;tr&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;"><span style="color:#FF0000;">&lt;td class=&quot;Estilo1&quot;&gt;&lt;strong&gt;Comentarios:&lt;/strong&gt;&lt;/td&gt;</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;">&lt;td class=&quot;Estilo1&quot;&gt;&amp;nbsp;&lt;/td&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;"><span style="color:#FF0000;">&lt;/tr&gt;</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;">&lt;tr&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;"><span style="color:#FF0000;">&lt;td colspan=&quot;2&quot; class=&quot;Estilo1&quot;&gt;'</span> . <a href="http://www.php.net/nl2br"><span style="color:#000066;">nl2br</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color:#000066;">stripslashes</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$comentarios</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> . <span style="color:#FF0000;">'&lt;/td&gt;</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;">&lt;/tr&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;"><span style="color:#FF0000;">&lt;/table&gt;</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;">&lt;hr /&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;"><span style="color:#FF0000;">&lt;hr style=&quot;height:10px&quot; /&gt;'</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:#006600; font-weight:bold;">&#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:#616100;">else</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#008000;">/* Texto Plano */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$mensaje</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;"><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;"><span style="color:#FF0000;">Nombre: "</span> . <span style="color:#0000FF;">$nombre</span> . <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;"><span style="color:#FF0000;">Email: "</span> . <span style="color:#0000FF;">$correo</span> . <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;"><span style="color:#FF0000;">Sexo: "</span> . <span style="color:#0000FF;">$sexo</span> . <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;"><span style="color:#FF0000;">País: "</span> . <span style="color:#0000FF;">$pais</span> . <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;"><span style="color:#FF0000;">Temas: "</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:#616100;">for</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span> = <span style="color:#CC66CC;color:#800000;">0</span>; <span style="color:#0000FF;">$i</span> &lt;count<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$temas</span><span style="color:#006600; font-weight:bold;">&#41;</span>; <span style="color:#0000FF;">$i</span>++<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#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:#0000FF;">$mensaje</span> .= <span style="color:#0000FF;">$temas</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#93;</span> . <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:#006600; font-weight:bold;">&#125;</span> <span style="color:#0000FF;">$mensaje</span> .=&nbsp; <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:#FF0000;">Comentarios: "</span> . <span style="color:#0000FF;">$comentarios</span> . <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;"><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; <span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$mensaje</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#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:#006600; font-weight:bold;">&#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:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/mail"><span style="color:#000066;">mail</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$para</span>, <span style="color:#0000FF;">$asunto</span>, <span style="color:#0000FF;">$mensaje</span>, <span style="color:#0000FF;">$header</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#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; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&amp;resultado=S&amp;;'</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:#616100;">else</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; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&amp;resultado=N&amp;'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#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:#616100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span style="color:#000066;">echo</span></a> <span style="color:#FF0000;">'&amp;resultado=N&amp;'</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:#000000; font-weight:bold;">?&gt;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/body&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;/html&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p style="text-align: left;">Hemos llegado al final de este largo tutorial. No olvides ver el ejemplo y bajar el archivo.</p>
<p style="text-align: left;"><img style="float: left;" src="../images/nota.jpg" alt="Nota" />Como lo dije al principio del tutorial, por razones de seguridad, el ejemplo que se encuentra a continuación no enviará  ningún correo electrónico (para evitar que se llene el buzón o llegue puro correo basura). En lugar de mandar el correo electrónico mostraré el resultado final de cómo se vería el correo electrónico (tanto en formato HTML como en formato de texto plano). Sin embargo, los archivos de esta entrada y el código pegado anteriormente, sí tienen la instrucción para enviar el correo electrónico.</p>
<div 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 align="center" style="margin-top:30px; margin-bottom:20px;">
<object width="420" height="380">
<param name="movie" value="http://codigometropoli.com/wp-content/uploads/2008/07/Enviar_Correo.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="420" height="380" src="http://codigometropoli.com/wp-content/uploads/2008/07/Enviar_Correo.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</div>
<div align="center" style="margin-top:30px; margin-bottom:20px;">
<table border="0" cellspacing="0" cellpadding="0" width="180">
<tbody>
<tr>
<td valign="top"><a href="http://www.megaupload.com/?d=AX90OBE0"><img src="../images/descargar_archivo.jpg" alt="Descargar Archivo" /></a></td>
</tr>
</tbody>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/enviar-formulario-de-contacto/feed/</wfw:commentRss>
		<slash:comments>111</slash:comments>
		</item>
	</channel>
</rss>
