esta es la clase del personaje principal.
Código ActionScript :
package {
import flash.display.MovieClip;
import flash.events.Event;
public class Personaje extends MovieClip {
//Variables.
public var velLateral:Number=3;
public var friccion:Number=0.8;
public var friccionAire:Number=0.8;
public var gravedad:Number=-3;
public var tiempoSalto:Number=4;
public var salto:Number=30/tiempoSalto;
public var velMaxima:Number=20;
public var puntoIzq:Number=-15;
public var puntoDer:Number=15;
public var puntoBajo:Number=25;
public var puntoArriba:Number=-25;
public var dx:Number;
public var dy:Number;
public var vel:Number;
public var saltando:Boolean;
public var empezoSalto:Number;
//Constructor.
public function Personaje():void {
trace("personaje creado");
addEventListener(Event.ENTER_FRAME,aplicarMovimiento);
}
function inicializarPersonaje():void {
if (this.dx!=0) {
this.dx=0;
this.dy=0;
this.saltando=true;
this.empezoSalto=0;
}
this.friccion=friccion;
this.vel=velLateral;
this.salto=salto;
}
public function aplicarMovimiento(evt:Event):void{
var mc:MovieClip = evt.currentTarget as MovieClip;
mc.x+=mc.dx;
mc.dx*=mc.friccion;
if(mc.dx>velMaxima){
mc.dx=velMaxima;
}else if(mc.dx<-velMaxima){
mc.dx=-velMaxima;
}
mc.y+=mc.dy;
if(!mcSuelo.hitTestPoint(mc.x,mc.y+puntoBajo+1,true)){
mc.saltando = true;
}
if(mc.saltando){
mc.suelo = 0;
mc.dy-=gravedad;
if(mc.dy>salto*tiempoSalto){
mc.dy = salto*tiempoSalto;
}
}
checarColisiones(this);
}
public function checarColisiones(mc:MovieClip):void {
//pega abajo
while (mcSuelo.hitTestPoint(mc.x,mc.y+mc.puntoBajo,true)) {
mc.saltando=false;
mc.y--;
mc.dy=0;
}
//pega arriba
while (mcSuelo.hitTestPoint(mc.x,mc.y+mc.puntoArriba,true)) {
mc.y++;
mc.dy=Math.abs(mc.dy);
}
//pega izq
while (mcSuelo.hitTestPoint(mc.x+mc.puntoIzq+1,mc.y,true)) {
mc.x++;
mc.dx=0;
}
while (mcSuelo.hitTestPoint(mc.x+mc.puntoIzq+1,mc.y+mc.puntoBajo/2,true)) {
mc.x++;
mc.dx=0;
}
//pega der
while (mcSuelo.hitTestPoint(mc.x+mc.puntoDer-1,mc.y,true)) {
mc.x--;
mc.dx=0;
}
while (mcSuelo.hitTestPoint(mc.x+mc.puntoDer-1,mc.y+mc.puntoBajo/2,true)) {
mc.x--;
mc.dx=0;
}
}
}
}EL erro es el siguiente
Accseso a una propiedad mcSuelo no definida origen : while (mcSuelo.hitTestPoint(mc.x+mc.puntoDer-1,mc.y,true)) {
resulta.. q mcSuelo.. es un movieClip q esta en el stage con ese nombre de instancia... ya probe escribiendo
origen : while (parent.mcSuelo.hitTestPoint(mc.x+mc.puntoDer-1,mc.y,true)) {
pero el error es el mismo Auxiiiilio
y
Gracias de antemano
