<?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>digilabs.com.ar &#187; AS2</title>
	<atom:link href="http://digilabs.com.ar/category/as2/feed" rel="self" type="application/rss+xml" />
	<link>http://digilabs.com.ar</link>
	<description>Let's code!!!</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:14:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Generar columnas en Flash</title>
		<link>http://digilabs.com.ar/2010/09/actionscript/generar-columnas-en-flash</link>
		<comments>http://digilabs.com.ar/2010/09/actionscript/generar-columnas-en-flash#comments</comments>
		<pubDate>Fri, 24 Sep 2010 11:00:10 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=1180</guid>
		<description><![CDATA[Aca dejo un pequeño tip de como generar columnas en flash facilmente. La idea en usar un for pero no necesitar de hacer for añidados o usar contadores sino hacer todo en una sola línea usando el símbolo %. Con este &#8220;truquico&#8221; cada vez que i es divisible por 10 la vuelve cero de forma [...]]]></description>
			<content:encoded><![CDATA[<p>Aca dejo un pequeño tip de como generar columnas en flash facilmente.<br />
La idea en usar un for pero no necesitar de hacer for añidados o usar contadores sino hacer todo en una sola línea usando el símbolo %. Con este &#8220;truquico&#8221; cada vez que i es divisible por 10 la vuelve cero de forma que el contador en x de este ejemplo decrementa desde -250 de 50 en 50. Lo único valores que peude tomar x son entre -250 y 250  y varía de 50 en 50. Usando este método es muy fácil generar una grilla donde posicionamos elementos.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i : <span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span> <span style="color: #cc66cc;">100</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'x: '</span>+<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">%</span>10<span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'y: '</span>+ <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">/</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>-<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #808080; font-style: italic;">//los traces de este ejemplo sería:</span>
<span style="color: #808080; font-style: italic;">/*
x: -250
y: -250
x: -200
y: -245.00000000000003
x: -150
y: -240
x: -100
y: -235
x: -50
y: -229.99999999999997
x: 0
y: -225
x: 50
y: -220.00000000000003
x: 100
y: -215
x: 150
y: -210
x: 200
y: -204.99999999999997
x: -250
y: -200
x: -200
y: -195
x: -150
y: -190
x: -100
y: -185
x: -50
y: -180
x: 0
y: -175
x: 50
y: -170
x: 100
y: -165
x: 150
y: -160
x: 200
...*/</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2010/09/actionscript/generar-columnas-en-flash/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Detectar dirección con ActionScrip 2</title>
		<link>http://digilabs.com.ar/2010/09/actionscript/detectar-direccion-con-actionscrip-2</link>
		<comments>http://digilabs.com.ar/2010/09/actionscript/detectar-direccion-con-actionscrip-2#comments</comments>
		<pubDate>Thu, 09 Sep 2010 02:03:50 +0000</pubDate>
		<dc:creator>Eduardo Martin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Tendencias]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=1088</guid>
		<description><![CDATA[Si lo que intentan es detectar hacia que dirección va el cursor del mouse utilizando ActionScript2, les recomiendo utilizar un método que poco conocía que es nativo de Flash, su nombre es &#8220;watch&#8220;. Esta función analizar una variable y devuelve dos valores uno nuevo &#8220;newVal&#8221; y otro viejo &#8220;oldVal&#8220;,  lo cual nos facilita el trabajo [...]]]></description>
			<content:encoded><![CDATA[<p>Si lo que intentan es detectar hacia que dirección va el cursor del mouse utilizando ActionScript2, les recomiendo utilizar un método que poco conocía que es nativo de Flash, su nombre es &#8220;<a title="Funcion watch" href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001435.html" target="_self"><strong>watch</strong></a>&#8220;. Esta función analizar una variable y devuelve dos valores uno nuevo &#8220;<strong>newVal</strong>&#8221; y otro viejo &#8220;<strong>oldVal</strong>&#8220;,  lo cual nos facilita el trabajo si tenemos que desarrollar una pelicula que detecte si el mouse va hacia la derecha o hacia izquierda, arriba o abajo, este método es muy interesante ya que nos permitiría saber si los valores en <strong>x</strong> e <strong>y</strong> se incrementan o disminuye lo cual con un simple if podríamos saber hacia donde se dirige el cursor. Esta función también puede servir para activar alertas, cuando una variable cambia, se analiza con watch y cuando se cumple una condición se activa una alarma, se ejecuta una función o simplemente se activa una animación.</p>
<p>Esto también se puede hacer con listeners, pero es mas complejo ya que hay que armar la función que permite comparar el valor viejo con el valor nuevo de la variable mientras cambia. No les aconsejo utilizar onEnterFrame ya que consume muchos recursos.</p>
<p><strong>Ejempo:</strong></p>
<p>
<object width="450" height="400">
<param name="movie" value="http://digilabs.com.ar/wp-content/uploads/2010/09/detectar-direccion.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="opaque"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#00000"></param>
<embed type="application/x-shockwave-flash" width="450" height="400" src="http://digilabs.com.ar/wp-content/uploads/2010/09/detectar-direccion.swf" quality="high" bgcolor="#00000" wmode="opaque" menu="false" ></embed>
</object>
</p>
<p><strong>Codigo:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">Mouse</span>.<span style="color: #0066CC;">hide</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
posX = <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>dx, oldVal, newVal<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>oldValnewVal<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Izquierda&quot;</span><span style="color: #66cc66;">&#41;</span>;
        avion_mc.<span style="color: #0066CC;">_rotation</span> = -<span style="color: #cc66cc;">90</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">return</span> newVal;
<span style="color: #66cc66;">&#125;</span>;
posY = <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #66cc66;">&#40;</span>dy, oldVal, newVal<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>oldValnewVal<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;rriba&quot;</span><span style="color: #66cc66;">&#41;</span>;
        avion_mc.<span style="color: #0066CC;">_rotation</span> = <span style="color: #cc66cc;">360</span>;
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #b1b100;">return</span> newVal;
<span style="color: #66cc66;">&#125;</span>;
&nbsp;
<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">watch</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;dirx&quot;</span>,posX<span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">watch</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;diry&quot;</span>,posY<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">onMouseMove</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>
    avion_mc.<span style="color: #0066CC;">_x</span> = <span style="color: #0066CC;">_xmouse</span>;
    avion_mc.<span style="color: #0066CC;">_y</span> = <span style="color: #0066CC;">_ymouse</span>;
    dirx = <span style="color: #0066CC;">_xmouse</span>;
    diry = <span style="color: #0066CC;">_ymouse</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span>;</pre></div></div>

<p>Para los que estan trabajando con <strong>As3</strong>, el método watch no existe mas, por lo cual les dejo una solución <a href="http://www.myriamspitz.com/2009/01/where-is-the-watch-object-in-as3/" target="_self">AQUI</a></p>
<p><strong>Clase:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;
   <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">EventDispatcher</span>;
   <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Model <span style="color: #0066CC;">extends</span> EventDispatcher
   <span style="color: #66cc66;">&#123;</span>
       <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const VALUE_CHANGED:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'value_changed'</span>;
       <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _number:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Number</span>;
       <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Model<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
       <span style="color: #66cc66;">&#123;</span>
           <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'The model was instantiated.'</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span>
       <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">set</span> <span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#40;</span>newNb:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
       <span style="color: #66cc66;">&#123;</span>
          _number=newNb;
          <span style="color: #0066CC;">this</span>.<span style="color: #006600;">dispatchEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Event<span style="color: #66cc66;">&#40;</span>Model.<span style="color: #006600;">VALUE_CHANGED</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span>
       <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> <span style="color: #0066CC;">number</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span>
      <span style="color: #66cc66;">&#123;</span>
          <span style="color: #b1b100;">return</span> _number;
&nbsp;
      <span style="color: #66cc66;">&#125;</span>
   <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p><strong>Modo de uso:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> objectToWatch:Model = <span style="color: #000000; font-weight: bold;">new</span> Model<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
objectToWatch.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Model.<span style="color: #006600;">VALUE_CHANGED</span>, onValuedChanged<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> onValuedChanged<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:Event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">//do what you need here</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Espero que les sea útil, la próxima me gustaría completar la pelicula de arriba con algo de trigonometría para simular 100% la dirección.</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2010/09/actionscript/detectar-direccion-con-actionscrip-2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Libreria para carga de archivos externos en flash.</title>
		<link>http://digilabs.com.ar/2010/01/actionscript/casa-lib</link>
		<comments>http://digilabs.com.ar/2010/01/actionscript/casa-lib#comments</comments>
		<pubDate>Wed, 27 Jan 2010 14:34:58 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=587</guid>
		<description><![CDATA[me encantan la librerías de cualquier lenguaje sobre todo las de Flash. Tweenlite es mi librería por defecto que utilizo en el 90 por ciento de mis proyectos. Esta semana empecé a usar una nueva librería que tiene mas utilidades y no se especializa en animaciones si no que se utiliza para hacer la carga [...]]]></description>
			<content:encoded><![CDATA[<p>me encantan la librerías de cualquier lenguaje sobre todo las de Flash. Tweenlite es mi librería por defecto que utilizo en el 90 por ciento de mis proyectos. Esta semana empecé a usar una nueva librería que tiene mas utilidades y no se especializa en animaciones si no que se utiliza para hacer la carga de archivos externos. Lo que más me gustó de esta librería es que permite hacer optimizaciones de memoria en cualquier momento, cosa que nos podría ser útil en caso de estar desarrollando alguna aplicación para dispositivos móviles donde la memoria es acotada. Otra ventaja es que viene en dos gustos para los clásicos AS2 y para aquellos más atrevidos AS3.</p>
<p>Más información en:</p>
<p>http://as3.casalib.org/releases/1.2.1/docs/</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2010/01/actionscript/casa-lib/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>más formulas útiles.</title>
		<link>http://digilabs.com.ar/2009/12/actionscript/mas-formulas-utiles</link>
		<comments>http://digilabs.com.ar/2009/12/actionscript/mas-formulas-utiles#comments</comments>
		<pubDate>Sat, 12 Dec 2009 07:55:33 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=508</guid>
		<description><![CDATA[Siguiendo con formulas útiles de mi post anterior y estudiando un poco algoritmos Euclidianos, cree un par de funciones para saber cual es la relación de aspecto de una imagen. function getMCD&#40;w:int, h:int&#41;:int&#123; return &#40;&#40;h != 0&#41; ? arguments.callee&#40;h, w % h&#41;: w&#41;; &#125; &#160; function getAspectRatio&#40;w:uint, h:uint&#41;:String&#123; var mcd:Number = getMCD&#40;w, h&#41;; return &#91;&#40;w [...]]]></description>
			<content:encoded><![CDATA[<p>Siguiendo con formulas útiles de mi post anterior y estudiando un poco algoritmos Euclidianos, cree un par de funciones para saber cual es la relación de aspecto de una imagen.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> getMCD<span style="color: #66cc66;">&#40;</span>w:<span style="color: #0066CC;">int</span>, h:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#123;</span> 
<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>h <span style="color: #66cc66;">!</span>= <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #0066CC;">arguments</span>.<span style="color: #0066CC;">callee</span><span style="color: #66cc66;">&#40;</span>h, w <span style="color: #66cc66;">%</span> h<span style="color: #66cc66;">&#41;</span>: w<span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getAspectRatio<span style="color: #66cc66;">&#40;</span>w:uint, h:uint<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#123;</span> 
<span style="color: #000000; font-weight: bold;">var</span> mcd:<span style="color: #0066CC;">Number</span> = getMCD<span style="color: #66cc66;">&#40;</span>w, h<span style="color: #66cc66;">&#41;</span>;
<span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#40;</span>w <span style="color: #66cc66;">/</span> mcd<span style="color: #66cc66;">&#41;</span>, <span style="color: #66cc66;">&#40;</span>h <span style="color: #66cc66;">/</span> mcd<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>y estos son algunos testeos:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span>getAspectRatio<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">320</span>, <span style="color: #cc66cc;">240</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 4:3 </span>
<span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span>getAspectRatio<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">540</span>, <span style="color: #cc66cc;">480</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 9:8 </span>
<span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span>getAspectRatio<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">550</span>, <span style="color: #cc66cc;">400</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 11:8</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/12/actionscript/mas-formulas-utiles/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Numero aleatorio dentro de un rango</title>
		<link>http://digilabs.com.ar/2009/08/actionscript/numero-aleatorio-dentro-de-un-rango</link>
		<comments>http://digilabs.com.ar/2009/08/actionscript/numero-aleatorio-dentro-de-un-rango#comments</comments>
		<pubDate>Fri, 14 Aug 2009 11:31:25 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=247</guid>
		<description><![CDATA[Math.random() es una función super utilizada dentro de flash. Pero mucho más versátil es poder elegir el rango en el que nos devuelve dicho numero aleatorio, por ejemplo: si queremos un numero aleatorio entre el 5 y el 13. Eso se Puede solucionar fácil haciendo min + (max &#8211; min) * Math.random(); function randomMinMax&#40; min:Number, [...]]]></description>
			<content:encoded><![CDATA[<p>Math.random() es una función super utilizada dentro de flash. Pero mucho más versátil es poder elegir el rango en el que nos devuelve dicho numero aleatorio, por ejemplo: si queremos un numero aleatorio entre el 5 y el 13. Eso se Puede solucionar fácil haciendo min + (max &#8211; min) * Math.random();</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> randomMinMax<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">min</span>:<span style="color: #0066CC;">Number</span>, <span style="color: #0066CC;">max</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #b1b100;">return</span> <span style="color: #0066CC;">min</span> + <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">max</span> - <span style="color: #0066CC;">min</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">random</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; 
<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> miNumeroAleatorio:<span style="color: #0066CC;">Number</span>=randomMinMax<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">13</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>miNumeroAleatorio<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Se que no es una maravilla pero es muy útil y la utilizo aunque sea una vez por semana en mis proyectos.</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/08/actionscript/numero-aleatorio-dentro-de-un-rango/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formulario de contacto</title>
		<link>http://digilabs.com.ar/2009/08/actionscript/formulario-de-contacto</link>
		<comments>http://digilabs.com.ar/2009/08/actionscript/formulario-de-contacto#comments</comments>
		<pubDate>Tue, 11 Aug 2009 10:43:00 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=237</guid>
		<description><![CDATA[Dejo acá un formulario de contacto bonito  y que ocupa poco espacio para aquellos sitios con restricción de espacio. Es para AS2 y el campo de texto se ajusta a lo que escribas, lo único que le faltaría es que onfocus borre el texto inicial, pero eso es fácil de cambiar. http://www.flashuser.net/flash-components/freebie-good-looking-flash-contact-form.html]]></description>
			<content:encoded><![CDATA[<p>Dejo acá un formulario de contacto bonito  y que ocupa poco espacio para aquellos sitios con restricción de espacio. Es para AS2 y el campo de texto se ajusta a lo que escribas, lo único que le faltaría es que onfocus borre el texto inicial, pero eso es fácil de cambiar.</p>
<p>http://www.flashuser.net/flash-components/freebie-good-looking-flash-contact-form.html</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/08/actionscript/formulario-de-contacto/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limite permitidos de caracteres dentro de un Dynamic Text</title>
		<link>http://digilabs.com.ar/2009/08/actionscript/limite-permitidos-de-caracteres-dentro-de-un-dynamic-text</link>
		<comments>http://digilabs.com.ar/2009/08/actionscript/limite-permitidos-de-caracteres-dentro-de-un-dynamic-text#comments</comments>
		<pubDate>Sat, 08 Aug 2009 19:11:42 +0000</pubDate>
		<dc:creator>Eduardo Martin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=218</guid>
		<description><![CDATA[Supongamos que estamos desarrollando un kiosco interactivo,y queremos implementar un teclado virtual para utilizar una pantalla touch screen.  Si lo programamos en ActionScript y necesitamos  limitar la cantidad de caracteres permitidos en algunas cajas de textos dinámicos, hay una manera muy sensilla utilizando la siguiente funcion propia de ActionScript 2  &#8220;Length(nombre:variable)&#8220;. Ejemplo: var contenido_texto = [...]]]></description>
			<content:encoded><![CDATA[<p>Supongamos que estamos desarrollando un kiosco interactivo,y queremos implementar un teclado virtual para utilizar una pantalla touch screen.  Si lo programamos en ActionScript y necesitamos  limitar la cantidad de caracteres permitidos en algunas cajas de textos dinámicos, hay una manera muy sensilla utilizando la siguiente funcion propia de ActionScript 2  &#8220;<strong>Length(nombre:variable)</strong>&#8220;.</p>
<p>Ejemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> contenido_texto = cual_txt.<span style="color: #0066CC;">text</span>;
<span style="color: #000000; font-weight: bold;">var</span> caracteres_n:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">4</span>; <span style="color: #808080; font-style: italic;">//Definimos la longitud permitida</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Esta condición iría en el momento en que se tipea.</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Length</span><span style="color: #66cc66;">&#40;</span>contenido_texto<span style="color: #66cc66;">&#41;</span> == caracteres_n<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;DynamicText bloqueado&quot;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">// codigo que indica el fin de la estructura</span>
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">trace</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;DynamicText desbloqueado&quot;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #808080; font-style: italic;">// Código de escritura normal</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Esta función no esta documentada en el Help Reference de Flash CS3, cuantas mas habrá?</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/08/actionscript/limite-permitidos-de-caracteres-dentro-de-un-dynamic-text/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>machete de actionscrip 2.0 y 3.0</title>
		<link>http://digilabs.com.ar/2009/07/actionscript/machete-de-actionscrip-2-0-y-3-0</link>
		<comments>http://digilabs.com.ar/2009/07/actionscript/machete-de-actionscrip-2-0-y-3-0#comments</comments>
		<pubDate>Tue, 21 Jul 2009 10:05:53 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=147</guid>
		<description><![CDATA[Genial para no tener que acordarse como iniciar objetos, array, preloaders, etc. Un buen machete fácil de usar con ejemplos. http://www.weberdesignlabs.com/cheatsheet/]]></description>
			<content:encoded><![CDATA[<p>Genial para no tener que acordarse como iniciar objetos, array, preloaders, etc. Un buen machete fácil de usar con ejemplos.</p>
<p>http://www.weberdesignlabs.com/cheatsheet/</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/07/actionscript/machete-de-actionscrip-2-0-y-3-0/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formulas útiles</title>
		<link>http://digilabs.com.ar/2009/06/actionscript/formulas-utiles</link>
		<comments>http://digilabs.com.ar/2009/06/actionscript/formulas-utiles#comments</comments>
		<pubDate>Fri, 19 Jun 2009 22:32:42 +0000</pubDate>
		<dc:creator>Andrés Argüello Pitt</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=30</guid>
		<description><![CDATA[La idea de este post es publicar formulas que son súper útiles para hacer cálculos de MCs con respecto el mouse. Por ejemplo mover hacia un lado u otro un mc según la distancia del puntero del mouse al centro de escenario o mover una lista de thumbnails según la posición del mouse con respecto [...]]]></description>
			<content:encoded><![CDATA[<p>La idea de este post es publicar formulas que son súper útiles para hacer cálculos de MCs con respecto el mouse. Por ejemplo mover hacia un lado u otro un mc según la distancia del puntero del mouse al centro de escenario o mover una lista de thumbnails según la posición del mouse con respecto distancia al centro del movieclip contenedor.<br />
Lo anterior lo podríamos hacer por trigonometría sacando la distancia, pero también hay formulas útiles para calcular circunferencias y con ellas dibujar tortas para estadísticas incluso animarlas en tiempo de ejecución.</p>
<p><strong>Distancias</strong></p>
<p>La distancia entre dos puntos (x1,y1) y (x2,y2) es representada por la siguiente formula:<br />
<span style="font-family: Arial;" lang="ES-PR"><img src="http://bc.inter.edu/facultad/edavila/PRECALCULO%20%20ARCHIVOS/DISTancia_files/image005.gif" alt="" width="254" height="32" /></span></p>
<p>Como sacar la distancia del mouse al centro del escenario en AS3:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">   <span style="color: #000000; font-weight: bold;">var</span> x1=<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageWidth</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
    <span style="color: #000000; font-weight: bold;">var</span> x2=mouseX;
    <span style="color: #000000; font-weight: bold;">var</span> y1=<span style="color: #0066CC;">stage</span>.<span style="color: #006600;">stageHeight</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span>;
    <span style="color: #000000; font-weight: bold;">var</span> y2=mouseY;
    <span style="color: #000000; font-weight: bold;">var</span> distx:<span style="color: #0066CC;">Number</span>=<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">sqrt</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">pow</span><span style="color: #66cc66;">&#40;</span>x2-x1,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>+<span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">pow</span><span style="color: #66cc66;">&#40;</span>y2-y1,<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>y si necesitamos esa distancia en porcentaje:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> porcentage=<span style="color: #66cc66;">&#40;</span>distx<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span>x1</pre></div></div>

<p>La única aclaración sería que el método con el cual saco la mitad al centro del escenario en AS3 es: stage.stageWidth y AS2 sólo cambiaría por Stage.width . Cambiando sólo eso debiran andar sin problemas en AS2.</p>
]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/06/actionscript/formulas-utiles/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cortar parte de un texto</title>
		<link>http://digilabs.com.ar/2009/06/actionscript/cortar-parte-de-un-texto</link>
		<comments>http://digilabs.com.ar/2009/06/actionscript/cortar-parte-de-un-texto#comments</comments>
		<pubDate>Sat, 06 Jun 2009 16:36:46 +0000</pubDate>
		<dc:creator>Eduardo Martin</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://digilabs.com.ar/?p=15</guid>
		<description><![CDATA[Se habrán encontrado varias veces con la necesidad de mostrar un resumen del texto de una noticia, esta función les va a facilitar la tarea sin necesidad de tener que poner  en la base de datos un campo con el resumen de la noticia, salvo que esta sea necesaria. texto_completo = es la variable que [...]]]></description>
			<content:encoded><![CDATA[<p>Se habrán encontrado varias veces con la necesidad de mostrar un resumen del texto de una noticia, esta función les va a facilitar la tarea sin necesidad de tener que poner  en la base de datos un campo con el resumen de la noticia, salvo que esta sea necesaria.</p>
<p><strong>texto_completo</strong> = es la variable que contiene texto de la noticia completa<br />
<strong>resumen</strong> = es la nueva variable que contendrá 80 caracteres de  la noticia completa</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> resumen = texto_completo.<span style="color: #0066CC;">substring</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">80</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://digilabs.com.ar/2009/06/actionscript/cortar-parte-de-un-texto/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

