Comunidad de diseño web y desarrollo en internet online

drag and drop que no me funciona

Citar            
MensajeEscrito el 13 Jun 2009 05:33 pm
Hola a todos,
Resulta que tengo un movieclip en el que se carga una imagen vía el método loadMovie. El caso es que el MovieClip tiene definido un startDrag y stopDrag al presionar y soltar respectivamente y sólo me funcionan si el movieClip no tiene la imagen jpg cargada. Si la tiene cargada, no hay forma de que funcione.
Sugerencias? Tiene que tener algo especial la película una vez cargada la imagen para que pueda funcionar el drag and drop?

Por pixmaniac

30 de clabLevel



 

msie7
Citar            
MensajeEscrito el 13 Jun 2009 05:43 pm
Al cargar algo en un clip se "borran" las acciones que estaban asignadas a ese clip
Asignale las acciones cuando se complete la carga de la imagen.

saludos

Por webgeri

58 de clabLevel



Genero:Masculino  

montevideo

opera
Citar            
MensajeEscrito el 13 Jun 2009 05:49 pm
Siento pedir tanto pero es lo que nos pasa a los novatos,
Me puedes poner un mini ejemplo de cómo lo puedo hacer?
Mil gracias

Por pixmaniac

30 de clabLevel



 

msie7
Citar            
MensajeEscrito el 13 Jun 2009 06:06 pm
no hay problema nadie nace sabiendo
¿supongo estas cargando el archivo con loadMovie no?
si cargas el archivo con loadMovie debes usar un loop para consultar si el archivo se cargo y ahi asignarle las acciones

ej. el clip donde se carga la imagen con el nombre de instancia clip_mc

puedes crear una función para carga la imagen asi:

Código ActionScript :

function cargar() {
   clip_mc.loadMovie("imagen.jpg");
   delete this.onEnterFrame;
   this.onEnterFrame = function() {
      if (clip_mc.getBytesTotal()>10 && clip_mc.getBytesLoaded()>=clip_mc.getBytesTotal()) {
         clip_mc.onPress = function() {
            startDrag(this);
         };
         clip_mc.onRelease = clip_mc.onReleaseOutside=function () {
            stopDrag();
         };
         delete this.onEnterFrame;
      }
   };
}


al llamar a la función cargar();

se carga el archivo
y se realiza un onEnterFrame para consultar si se empezo y si se termino a cargar el archivo
cuando se termina de cargar el archivo le asginas las acciones

puedes llamar a la función por ejempo al presionar un objeto

Código ActionScript :

objeto.onRelease=function(){
cargar();
}


todo sobre loadMovie

en lugar de loadMovie se puede usar loadClip y MovieClipLoader un objeto que te permite consultar los diferentes estados de carga
loadClip link

saludos

Por webgeri

58 de clabLevel



Genero:Masculino  

montevideo

opera
Citar            
MensajeEscrito el 13 Jun 2009 07:00 pm
No hay forma, he probado lo que me dices y sigue haciendo lo mismo. Te pego el código así verás exactamente lo que estoy haciendo. Estoy cargando una imagen de un xml en un movieclip, esta es la imagen que debe hacer caso al drag and drop. A ver si así puedo arreglarlo definitivamente.
Saludos!
[code]
var schoolXML:XML = new XML();
var length, i: Number;
var imagen: String;
schoolXML.ignoreWhite = true;
schoolXML.load("./xml/nuevo.xml");
i = 0;
function cargar_registro(ordinal:Number) {
length = schoolXML.firstChild.childNodes.length;
imagen = schoolXML.firstChild.childNodes[i].attributes.imagen;
foto_field.loadMovie(imagen);
name_field1.text = schoolXML.firstChild.childNodes[i].firstChild.firstChild.nodeValue;
surname_field1.text = schoolXML.firstChild.childNodes[i].firstChild.nextSibling.firstChild.nodeValue;
address_field1.text = schoolXML.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild.nodeValue;
job_field1.text = schoolXML.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
date_field1.text = schoolXML.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.firstChild.nodeValue;
comment_field1.text = schoolXML.firstChild.childNodes[i].lastChild.firstChild.nodeValue;
}


schoolXML.onLoad = function(success) {
if (success) {
cargar_registro(i);
}
}

/*foto_field.onPress = function() {
foto_field.startDrag(true);
}
foto_field.onRelease = function() {
foto_field.stopDrag();
}*/

back_btn.onPress = function() {
i -= 1;
if (i >= 0){
cargar_registro(i)
}
else {
i += 1;
}
}
next_btn.onPress = function() {
i += 1;
if (i < length){
cargar_registro(i);
}
else {
i -= 1;
}
}
[/code]

Por pixmaniac

30 de clabLevel



 

msie7
Citar            
MensajeEscrito el 13 Jun 2009 07:08 pm
cambia esta parte de tu codigo

Código ActionScript :

foto_field.loadMovie(imagen);


por

Código ActionScript :

cargar(imagen);


y luego pega esta función

Código ActionScript :

function cargar(archivo:String) { 
   foto_field.loadMovie(archivo); 
   delete this.onEnterFrame; 
   this.onEnterFrame = function() { 
      if (foto_field.getBytesTotal()>10 && foto_field.getBytesLoaded()>=foto_field.getBytesTotal()) { 
         foto_field.onPress = function() { 
            startDrag(this); 
         }; 
         foto_field.onRelease = foto_field.onReleaseOutside=function () { 
            stopDrag(); 
         }; 
         delete this.onEnterFrame; 
      } 
   }; 
}


saludos

Por webgeri

58 de clabLevel



Genero:Masculino  

montevideo

opera
Citar            
MensajeEscrito el 13 Jun 2009 07:16 pm
al fin!
Habia probado lo mismo antes y no me habia funcionado!
Muchas gracias!

Por pixmaniac

30 de clabLevel



 

msie7

 

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