gracias xavi, enrealidad de lo q trato es trastear en esto de las
clases para ver si consigo entender algo, y ya puestos aprovecho y para
preguntar otra cosilla, ya he conseguido cargar imagenes,
posicionarlas, incluso ponerles un borde (estoy q me salgo ;)), pero
(siempre hay un pero), no consigo asignarle un evento OnRelease, os
pongo el c�digo:
<code>
_global.Imagen = function(nombre, x, y) {
this.width = 83;
this.height = 100;
this.nombre = nombre;
this.x = x;
this.y = y;
this.colorBorder = "0x990000";
this.lineBorder = 2;
this.alfaBorder = 100;
this.clip = null;
};
//
Imagen.prototype.cargar = function(mc, prof) {
this.clip = mc.createEmptyMovieClip("tHolder"+prof, prof);
this.clip.loadMovie(this.nombre);
this.clip._x = this.x;
this.clip._y = this.y;
//Siguiendo con el ejemplo q puso Joseba en su d�a he a�adido esto
this.clip.useHandCursor = true;
this.clip.onRelease = function() {
this.instancia.onClick();
};
};
Imagen.prototype.borde = function(mc, prof) {
this.clip = mc.createEmptyMovieClip("borde"+prof,prof);
this.clip.lineStyle( this.lineBorder, this.colorBorder,
this.alfaBorder );
this.clip.moveTo( this.x, this.y );
this.clip.lineTo( this.x + this.width, this.y );
this.clip.lineTo( this.x + this.width, this.y + this.height );
this.clip.lineTo( this.x , this.y + this.height );
this.clip.lineTo( this.x , this.y );
this.clip.instancia = this;
}
//
</code>
y la llamada
<code>
var img1 = new Imagen("imagen.jpg",10,10);
img1.cargar(_root,1);
img1.onClick = function(){
trace('hola');
}
</code>
pero no lo consigo, asi q si me lo permitis sigo abusando de vosotros y
os pido sopitas
gracias
saludos
----- Mensaje Original -----
De: "Xavi Beumala" <[EMAIL PROTECTED]>
Fecha: Martes, Octubre 21, 2003 6:05 pm
Asunto: RE: [ASNativos] novato creando clases
> Totalmente de acuerdo con la soluci�n de Joseba. Pero personalmente
> suelo evitar tener que cargar im�genes externas y hacer un
> redimensionado de tama�o. A esto le veo un par de problemillas:
> � el pixelado excesivo que sufren las im�genes en flash cuando se
> var�a su tama�o.
> � En el caso de cargar una imagen m�s grande de lo necesario
> estamosgenerando un tr�fico tambi�n innecesario.
>
>
> Mi granito de arena...
> Xavi Beumala
> http://www.code4net.com
>
> > -----Mensaje original-----
> > De: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] En nombre de Joseba Alonso
> > Enviado el: martes, 21 de octubre de 2003 17:49
> > Para: [EMAIL PROTECTED]
> > Asunto: Re: [ASNativos] novato creando clases
> >
> >
> > no, con loadMovie pides que cargue la imagen, pero es una
> > operacion asincrona, esto es, la accion no se ejecuta
> > inmediatamente sino que ocurre en un tiempo no determinado.
> > Puedes utilizar un peque�o preloader para comprobar cuando la
> > imagen ha cargado realmente y entonces aplicar la redimension.
> >
> > algo asi:
> >
> > <code>
> > _global.Imagen = function(nombre, x, y, w, h) {
> > this.x = x;
> > this.y = y;
> > this.w = w;
> > this.h = h;
> > this.nombre = nombre;
> > this.clip = null;
> > this._int = null;
> > };
> > Imagen.prototype.cargar = function(mc, prof) {
> > this.clip = mc.createEmptyMovieClip("tHolder"+prof, prof);
> > this.clip.loadMovie(this.nombre, prof); this.clip._x =
> > this.x; this.clip._y = this.y; this.clip.instancia = this;
> > this.clip._alpha = 0; clearInterval(this._int); this._int =
> > setInterval(this,"_comprobar",100);
> >
> > };
> > Imagen.prototype._comprobar = function(){
> >
> > if(this.clip.getBytesLoaded()==this.clip.getBytesTotal()&&this
> > .clip.getBytes
> > Loaded()>0){
> > this.redimensionar();
> > this.clip._alpha = 100;
> > clearInterval(this._int);
> > }
> > }
> > Imagen.prototype.redimensionar = function(){
> > this.clip._width = this.w;
> > this.clip._height = this.h;
> > }
> > </code>
> >
> >
> > un saludo
> >
> > Joseba Alonso
> > www.sidedev.net
> > ----- Original Message -----
> > From: "ugly-naked" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, October 21, 2003 4:44 PM
> > Subject: Re: [ASNativos] novato creando clases
> >
> >
> > gracias Joseba
> >
> > te refieres a esto?
> >
> > <code>
> > Imagen.prototype.cargar = function(mc, prof) {
> > this.clip = mc.createEmptyMovieClip("tHolder"+prof, prof);
> > this.clip.instancia = this; this.clip.loadMovie(this.nombre,prof);
> > this.clip._x = this.x;
> > this.clip._y = this.y;
> > this.clip._width = this.w;
> > this.clip._height = this.h;
> > };
> > </code>
> >
> > espero q no, pq sigue sin funcionar :(
> >
> > gracias por tu tiempo
> >
> > saludos
> >
> > ----- Mensaje Original -----
> > De: "Joseba Alonso" <[EMAIL PROTECTED]>
> > Fecha: Martes, Octubre 21, 2003 3:43 pm
> > Asunto: Re: [ASNativos] novato creando clases
> >
> > > Yo veo 2 cosas:
> > >
> > > 1)
> > >
> > > this.loadMovie(this.nombre,prof);
> > >
> > > deberia ser:
> > > this.clip.loadMovie(this.nombre,prof);
> > >
> > > 2)
> > >
> > > No apliques la redimension hasta que hayas cargado la foto.
> > >
> > > un saludo
> > >
> > > Joseba Alonso
> > > www.sidedev.net
> > > ----- Original Message -----
> > > From: "ugly-naked" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Tuesday, October 21, 2003 10:56 AM
> > > Subject: [ASNativos] novato creando clases
> > >
> > >
> > > hola,
> > >
> > > estoy empezando con esto de las clases y me he basado
> > (bueno, m�s bien
> > > lo he copiado y he ido modificando) en un minitutorial de
> > Joseba para
> > > hacer botones din�micamente.
> > >
> > > lo q quiero es una clase para cargar jpgs indic�ndoles el
> nombre,
> > > tama�o y en q posici�n deben cargarse. la verdad es q estoy
> > demasiado
> > > pez, os pongo el c�digo por si alguno me puede dar algo de luz
> > >
> > > <code>
> > >
> > > _global.Imagen = function(nombre, x, y, w, h) {
> > > this.width = 83;
> > > this.height = 100;
> > > this.x = x;
> > > this.y = y;
> > > this.w = w;
> > > this.h = h;
> > > this.nombre = nombre;
> > > this.clip = null;
> > > };
> > >
> > > Imagen.prototype.cargar = function(mc, prof) {
> > > this.clip = mc.createEmptyMovieClip("tHolder"+prof, prof);
> > > this.clip._x = this.x; this.clip._y = this.y;
> > > this.clip._width = this.w;
> > > this.clip._height = this.h;
> > > this.clip.instancia = this;
> > > this.loadMovie(this.nombre,prof);
> > > };
> > >
> > > </code>
> > >
> > > y luego la llamo
> > >
> > > <code>
> > >
> > > var img = new Imagen("imagen1.jpg",10,10,83,100);
> > > img.cargar(_root,1);
> > >
> > > </code>
> > >
> > > gracias
> > >
> > >
> > > <!-------------------------------
> > > Lista ASNativos:
> > > subscripciones/desubscripciones
> > > http://www.sidedev.ne
> > > -------------------------------->
> > >
> > > <!-------------------------------
> > > Lista ASNativos:
> > > subscripciones/desubscripciones
> > > http://www.sidedev.ne
> > > -------------------------------->
> > >
> >
> >
> > <!-------------------------------
> > Lista ASNativos:
> > subscripciones/desubscripciones http://www.sidedev.ne
> > -------------------------------->
> >
> > <!-------------------------------
> > Lista ASNativos:
> > subscripciones/desubscripciones http://www.sidedev.ne
> > -------------------------------->
> >
>
> <!-------------------------------
> Lista ASNativos:
> subscripciones/desubscripciones
> http://www.sidedev.ne
> -------------------------------->
>
<!-------------------------------
Lista ASNativos:
subscripciones/desubscripciones
http://www.sidedev.net/asnativos
-------------------------------->