Posts filed under 'ActionScript'

Drag and Drop, arrastrar y soltar un objeto en actionscript

Este es un pequeño ejemplo de como hacer un arrastrar y soltar de un movieclip en actionscript.

El primer paso será crear en un Movieclip al que colocaremos el nombre de instancia “mc”.

Este es el codigo:

  1. mc.onPress = function() {
  2.       startDrag(this);
  3. }
  4. mc.onRelease = function() {
  5.       stopDrag();
  6. }

Así de sencillo.

Ejemplo:

This movie requires Flash Player 8

Descargar >>

2 comments April 19th, 2007

SharedObject las cookies de flash

El objeto SharedObject viene a tapar un gran vacio en Flash, que era el volcado a disco de los datos que ActionScript manejaba en memoria; en las colecciones “data” ustedes pueden, no solo guardar variables de texto, sino tambien volcar todo un objeto, un Array o una clase; experimentar es la base de la innovación y las nuevas tecnicas. Este es un pequeño ejemplo de la utilización de SharedObject.

Este es el codigo:

  1. boton.onRelease = function() {
  2.       shared = SharedObject.getLocal(”nombre_shared”);
  3.       shared.data.nombre = texto.text;
  4.       shared.flush();
  5. };
  6. boton2.onRelease = function() {
  7.       texto2.text = shared.data.nombre;
  8. };
  9. boton3.onRelease = function() {
  10.       shared.clear();
  11. }

Ejemplo:

This movie requires Flash Player 8

Descargar >>

2 comments April 8th, 2007

Color de un pixel con bitmapdata y getPixel()

Hoy os pongo una función para que podais saber el color de un píxel de una imagen cargada con la clase Bitmapdata. No he comentado el código, pero si teneis alguna duda sobre él escribirme un mail o ponedlo en los comentarios.

Este es el codigo:

  1. import flash.display.*;
  2. cargar_imagen_bitmapdata(”http://www.forosdeflash.com/blog/wp-content/ferran1129050413.jpg”);
  3. function cargar_imagen_bitmapdata(imagen) {
  4.       original = _root.createEmptyMovieClip(”original”, _root.getNextHighestDepth());
  5.       original._y = 20;
  6.       cargando = new Object();
  7.       cargando.onLoadInit = function() {
  8.             w = original._width;
  9.             h = original._height;
  10.             bmpData1 = new BitmapData(w, h, true, 0×000000);
  11.             bmpData1.draw(original);
  12.             original.attachBitmap(bmpData1, 2, “auto”, true);
  13.             color.text = (”Color del pixel 10,10 : 0x”+bmpData1.getPixel(10, 10).toString(16));
  14.       };
  15.       imagen_mcl = new MovieClipLoader();
  16.       imagen_mcl.addListener(cargando);
  17.       imagen_mcl.loadClip(imagen, original);
  18. }

Ejemplo:

This movie requires Flash Player 8

Descargar >>

2 comments March 23rd, 2007

Dar formato a un texto de Flash usando CSS externo

En este tuturial explicaré cómo dar formato a un texto de Flash usando un CSS externo.

Este es el codigo flash:

  1. css_txt.html = true;
  2. miCSS = new TextField.StyleSheet();
  3. miCSS.onLoad = function(success) {
  4.       if (success) {
  5.             trace(this.getStyleNames());
  6.             css_txt.styleSheet = miCSS;
  7.             css_txt.htmlText = “Utilizando el formato AnaS!

    Esto es un texto rojo

    Este es un texto utilizando beatiful!“;

  8.       } else {
  9.             trace(”Lo siento! Ha ocurrido un error!”);
  10.       }
  11. };
  12. miCSS.load(”estilo.css”);

Este es el codigo css:

  1. AnaS {
  2.       color:#000000;
  3.       font-size: 15px;
  4. }
  5. red {
  6.       color:#CC0099;
  7.       font-size:20px;
  8.       text-align:center;
  9.       text-decoration:underline;
  10. }
  11. beautiful {
  12.       color:#333366;
  13.       font-size:10px;
  14.       text-align:right;
  15. }

Ver ejemplo>>

Descargar >>

2 comments March 14th, 2007

Previous Posts


Calendario

August 2008
M T W T F S S
« Sep    
 123
45678910
11121314151617
18192021222324
25262728293031

Posts por Mes

Posts por Categoria

Publicidad

Links