Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/12/2005, 13:01
jorgelujanm
 
Fecha de Ingreso: abril-2005
Ubicación: Ramos Mejía
Mensajes: 113
Antigüedad: 19 años, 7 meses
Puntos: 0
Aca va el código fuente completo de mi clase botón que no puede generar un evento!!
import mx.events.EventDispatcher;
[Event("onClick")]
class boton {
private var _padre:MovieClip;
private var _texto:TextField;
private var _cara:MovieClip;
private var n:Number;
private var h:Number;
private var w:Number;
private var ch:Number;
private var cw:Number;

//declare the dispatchEvent, addEventListener and removeEventListener methods that EventDispatcher uses (Step2)
function dispatchEvent() {};
function addEventListener() {};
function removeEventListener() {};

function boton(mcName:String, texto_str:String, padre_mc:MovieClip, n:Number){
mx.events.EventDispatcher.initialize(this);
this.n=n;
this._padre=padre_mc;
this._padre.attachMovie(mcName,"cara"+n+"_mc",n+11 00);
this._cara=_padre["cara"+n+"_mc"];
this._cara.createTextField("texto_txt",this._cara. getNextHighestDepth(),2,2,this._cara._width-4,this._cara._height-4);
this._cara.texto_txt.text=texto_str;

this._cara.onRollOver=function(){
this._alpha=50;
};

this._cara.onRollOut=fuera;
this._cara.onReleaseOutside=fuera;

function fuera(){
this._alpha=100;
}

this._cara.onRelease=function(){
// raiseonRelease;
var eventObject:Object = {target:_parent, type:'onClick'};
//dispatch the event (Step5)
this._padre.dispatchEvent(eventObject);
};
}

public function raiseonRelease(){
trace("hola soy la clase boton");
//define the event object that is passed to any listeners when the event is broadcast (Step4)
// You must specify a target property and then name of the event or the event “type” property in the event object

var eventObject:Object = {target:this, type:'onClick'};
//dispatch the event (Step5)
_parent.dispatchEvent(eventObject);
}

function get _mc():MovieClip{
return this._cara;
}

function set _x(t:Number){
this._cara._x=t;
}
function get _x():Number{
return this._cara._x;
}
function set _y(t:Number){
this._cara._y=t;
}

function get _y():Number{
return this._cara._y;
}

function set _height(t:Number){
this._cara._height=t;
}

function get _height():Number{
return this._cara._height;
}

function set _width(t:Number){
this._cara._width=t;
}

function get _width():Number{
return this._cara._width;
}

//--------------------------------------------------------------------
}


---------------------------------------------------
en el fla.
//esto no funciona
var b1:boton=new boton("boton1", "Inicio", _root,0);
var myListener:Object=new Object;

b1._x=20;
b1._y=50;

b1.addEventListener("onClick", myListener);

myListener.onClick=function(evtObj){
trace("Hola soy yo");
}