LeoBaraldi – Ejemplos Flash, Ejemplos actionscript, Tutoriales Flash, Tutoriales actionscript, actionscript 3, curso de actionscript

Recursos y ejemplos de actionscript, Flash, AIR, Flex, CSS y HTML. Tutoriales de actionscript 2 y actionscript 3

Operando con Numbers primera parte

| 0 comments

Como siempre los datos de tipo Numbers o numéricos son aquellos que están compuesto por un valor numérico y no literal.
Ejemplo:

Actionscript:
  1. <span id="gtbmisp_31" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> edad:<span id="gtbmisp_32" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = 30 //correcto
  2. <span id="gtbmisp_33" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> edad:<span id="gtbmisp_34" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = "30" //incorrecto

Como podemos observar a simple vista los datos de tipos números carecen de comillas dobles o simples, pueden ser un entero o decimal y siempre el Flash player nos va a devolver como máximo 15 dígitos en pantalla, pero en el podrá operar con mas dígitos.

En el caso de que una variable que debe almacenar un dato de tipo numérico o una operación nos deba devolver un resultado y este no es un numero, el Flash player no dará como resultante NaN (not a number), digamos que el resultado o el tipo de dato no es un numero.

Como todos sabemos con los números no solo podemos representar cantidades sino la posibilidad mas grande es realizar operaciones entre diferentes valores, sean sumas restas a cosas mas complejas como seno y cosenos de un numero. Flash cuenta con todas las herramientas para ello ya que cuenta con una clase nativa para los datos de tipo Number (clases veremos mas adelante).

Es importante recordar algunas cositas básicas para aquellos como yo que hace bastante tiempo nos alejamos de los libros del secundario o nivel medio, así que las reglas que rigen en Flash para las operaciones de suma, resta, multiplicacion y división son las mismas que las tradicionales así que recordemos que los signos + y - separan términos y los () agrupan las operaciones a evaluar.
Ejemplo:

Actionscript:
  1. <span id="gtbmisp_47" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> a:<span id="gtbmisp_48" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = 56;
  2. <span id="gtbmisp_49" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> b:<span id="gtbmisp_50" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = 4;
  3. suma = a+b; //el resultado es la suma de ambos números (60)
  4.  
  5. <span id="gtbmisp_51" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> a:<span id="gtbmisp_52" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = 56;
  6. <span id="gtbmisp_53" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">var</span> b:<span id="gtbmisp_54" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: red; text-decoration: underline; cursor: pointer;">Number</span> = 4;
  7. suma = (a+b)/2; //el resultado es la suma de ambos números divididos por 2 (30), como podemos ver agrupamos la suma usando <span id="gtbmisp_55" style="border: 0pt none; margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: serif; font-style: normal; font-variant: normal; font-weight: bold; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none; position: static; text-align: left; text-indent: 0pt; text-transform: none; color: green; text-decoration: underline; cursor: pointer;">paréntesis</span> y luego dividimos por 2

Author: LeoBaraldi

Diseñador gráfico y programador en Web, con experiencia profesional en el rubro desde 1998. Experto en diseño de interfaces Frontend y Backend, sitios, portales y dispositivos móviles. Experto en estándares, CSS y HTML, amplios conocimientos en CEO. Desarrollador de sitios multi plataformas, HTML5, CSS3 y JQuery. Experto programador en Adobe Flex, AIR y ActionScript 3.0. Conocimientos en lenguajes como PHP, Javascript y bases de datos MySQL. Profesor de Diseño y Diseño Web en la Escuela Superior de Diseño Aguas de la Cañada, asesor y colaborador para medios gráficos, editoriales y revistas afines. Actualmente Jefe de Producción en Manifesto solutions.

Deja un comentario

Required fields are marked *.

*