Posts filed under '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:
- mc.onPress = function() {
- startDrag(this);
- }
- mc.onRelease = function() {
- stopDrag();
- }
Así de sencillo.
Ejemplo:
This movie requires Flash Player 8
Descargar >>
April 19th, 2007
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:
- boton.onRelease = function() {
- shared = SharedObject.getLocal(”nombre_shared”);
- shared.data.nombre = texto.text;
- shared.flush();
- };
- boton2.onRelease = function() {
- texto2.text = shared.data.nombre;
- };
- boton3.onRelease = function() {
- shared.clear();
- }
Ejemplo:
This movie requires Flash Player 8
Descargar >>
April 8th, 2007
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:
- import flash.display.*;
- cargar_imagen_bitmapdata(”http://www.forosdeflash.com/blog/wp-content/ferran1129050413.jpg”);
- function cargar_imagen_bitmapdata(imagen) {
- original = _root.createEmptyMovieClip(”original”, _root.getNextHighestDepth());
- original._y = 20;
- cargando = new Object();
- cargando.onLoadInit = function() {
- w = original._width;
- h = original._height;
- bmpData1 = new BitmapData(w, h, true, 0×000000);
- bmpData1.draw(original);
- original.attachBitmap(bmpData1, 2, “auto”, true);
- color.text = (”Color del pixel 10,10 : 0x”+bmpData1.getPixel(10, 10).toString(16));
- };
- imagen_mcl = new MovieClipLoader();
- imagen_mcl.addListener(cargando);
- imagen_mcl.loadClip(imagen, original);
- }
Ejemplo:
This movie requires Flash Player 8
Descargar >>
March 23rd, 2007
En este tuturial explicaré cómo dar formato a un texto de Flash usando un CSS externo.
Este es el codigo flash:
- css_txt.html = true;
- miCSS = new TextField.StyleSheet();
- miCSS.onLoad = function(success) {
- if (success) {
- trace(this.getStyleNames());
- css_txt.styleSheet = miCSS;
- css_txt.htmlText = “Utilizando el formato AnaS!
Esto es un texto rojo
Este es un texto utilizando beatiful!“;
- } else {
- trace(”Lo siento! Ha ocurrido un error!”);
- }
- };
- miCSS.load(”estilo.css”);
Este es el codigo css:
- AnaS {
- color:#000000;
- font-size: 15px;
- }
- red {
- color:#CC0099;
- font-size:20px;
- text-align:center;
- text-decoration:underline;
- }
- beautiful {
- color:#333366;
- font-size:10px;
- text-align:right;
- }
Ver ejemplo>>
Descargar >>
March 14th, 2007
Previous Posts