Comunidad de diseño web y desarrollo en internet online

como posicionar por medio de actionscript

Citar            
MensajeEscrito el 05 Oct 2009 07:58 pm
Hola, que tal.

Estoy tratando de crear un efecto de maquina de escribir y tengo un script en el que coloco el texto y le puedo dar formato para mostrarlo, el problema es que necesito establecer el alto y el ancho de ese texto, pero no doy con como hacerlo.

Aca dejo el codigo, espero alguien me pueda ayudar

Código ActionScript :

//
texto = "Lorem ipsum dolor sit amet, orci at, feugiat nonummy. Ipsum eget tristique ea suspendisse aliquam, elementum et, consequat aliquam libero libero bibendum ut, wisi tincidunt aliquam, parturient id magna. Est fusce odio commodo sit. Rutrum nec duis sit ut diam aliquam, penatibus officiis et placerat quam lectus. Sem nunc non venenatis suspendisse, euismod magnis vel ante fusce, maecenas fermentum nec faucibus consequat. Lorem ut, ut cum condimentum dolore eu convallis libero, magna tincidunt lacus erat, cursus porta cupiditate quis volutpat sit, vitae commodo eleifend blandit. Neque ornare vel libero sapien nunc.Lorem ipsum dolor sit amet, orci at, feugiat nonummy. Ipsum eget tristique ea suspendisse aliquam, elementum et, consequat aliquam libero libero bibendum ut, wisi tincidunt aliquam, parturient id magna. Est fusce odio commodo sit.";
//
var myformat:TextFormat = new TextFormat();
myformat.font = 'Verdana';
myformat.size = 10;
myformat.align = 'justify';
myformat.color = 423687;
// 
velocidad = 90;
margiz = 10;
margder = 10;
alto = Stage.height;
margentotal = margiz+margder;
_root.createTextField("mytext", 1, margiz, margder, Stage.width-margentotal, alto);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.setNewTextFormat(myformat);
// 
var tpw:Typewriter = new Typewriter(mytext, texto, velocidad);

Por maryflash

65 de clabLevel



Genero:Femenino  

El Fondo del Mar...

firefox
Citar            
MensajeEscrito el 06 Oct 2009 02:42 pm
Hola de nuevo

Consegui otro codigo, que para mi es un poco mas sencillo de entender, ya logre poscionar el cuadro de texto donde queria, pero ahora no se como hacer para que cuando ya termino de escribir el texto, este se borre del Stage y yo pueda seguir con mis otras animaciones, segun lei hay que modificar la clase que hace funcionar el script, pero de plano ni idea, dejo los codigos a ver si alguien me puede ayudar.

Este es el script

Código ActionScript :

mystring = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis lectus nisi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer mi tortor, vehicula condimentum ultricies ut, congue in tellus. Vivamus id quam turpis. Suspendisse libero mi, imperdiet eget vulputate vitae, consequat at arcu.";
// --
var myformat:TextFormat = new TextFormat();
myformat.font = 'Verdana';
myformat.size = 10;
myformat.align = 'justify';
myformat.color = 0x659156;
// --
_root.createTextField("mytext",1,20,40,350,200);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.setNewTextFormat(myformat);
// --
var tpw:Typewriter = new Typewriter(mytext, mystring, 87);


Esta es la clase

Código ActionScript :

import mx.utils.Delegate;
class Typewriter  {
   private var interval:Number;
   private var string:String;
   private var speed:Number;
   private var textfield:TextField;
   private var index:Number;
   public function Typewriter (textfield:TextField, string:String, speed:Number) {
      this.textfield = textfield;
      this.string = string;
      this.speed = speed;
      index = 0;
      interval = setInterval(Delegate.create(this, exec), this.speed);
   }
   private function exec() {
      this.textfield.text = this.string.substr(0, index);
      index++;
      if (index > this.string.length) {
         clearInterval(interval);
      }
   }
}

Por maryflash

65 de clabLevel



Genero:Femenino  

El Fondo del Mar...

firefox
Citar            
MensajeEscrito el 07 Oct 2009 08:36 pm
Bueno en tu clase puedes agregar alguna funcion que ejecute algo despues de terminar el de escribir texto (eso lo hace private function exec, en la condicion if)

Prueba cambiando esto en tu clase:

Código ActionScript :

import mx.utils.Delegate;
class Typewriter  { 
   private var interval:Number; 
   private var string:String; 
   private var speed:Number; 
   private var count:Number; 
   private var textfield:TextField; 
   private var index:Number; 
   public function Typewriter (textfield:TextField, string:String, speed:Number) { 
      this.textfield = textfield; 
      this.string = string; 
      this.speed = speed; 
     count = 0;
      index = 0; 
      interval = setInterval(Delegate.create(this, exec), this.speed); 
   } 
   private function exec() { 
      this.textfield.text = this.string.substr(0, index); 
      index++; 
      if (index > this.string.length) { 
     // AQUI INICIA UN DELAY
     count++;
       if(count>50) {
      // AL TERMINAR HACE ALGO EN TU SWF
      hazAlgo();
        clearInterval(interval); 
      }
      } 
   } 
   private function hazAlgo(){
      this.textfield.removeTextField();
      // aqui removio el txt creado
      trace('Siguiente animacion ...');
      // quizas un gotoAnd, loadMovie, etc
   }
} 


A lo mejor la funcion hazAlgo este de mas y solo con poner la sentencia al terminar el delay, bueno es la idea ;)

Salu2!

Por comicSans

Claber

151 de clabLevel



 

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.