Se que lo que voy a pedir será muy evidente para muchos pero aún estoy aprendiendo y un empujón me vendría bien para no frustrarme totalmente
Quiero comunicar dos clases, desde la clase principal envio unos datos a la suclase pero me salen un montón de errores y no se que estoy haciendo mal. Gracias!
CLASE PRINCIPAL
Código ActionScript :
package {
import flash.display.MovieClip;
import clases.Timerbar;
public class Main extends MovieClip {
public function Main() {
colocarTemp(70, 100, 0, 0);
}
private function colocarTemp(tiempo: Number, tamaño: Number, xPos: Number, yPos: Number): void {
var temp: Timerbar = new Timerbar();
temp.nCount = tiempo;
temp.totalBarWidth = tamaño;
temp.timerxpos = xPos;
temp.timerypos = yPos;
addChild(temp);
}
}
}SUBCLASE
Código ActionScript :
package clases {
import flash.display.MovieClip;
import flash.events.TimerEvent;
import fl.transitions.Tween;
import fl.transitions.easing.None;
import flash.text.TextField;
import flash.display.Shape;
import flash.utils.Timer;
public class Timerbar extends MovieClip {
public var nCount;
public var totalBarWidth;
public var timerxpos;
public var timerypos;
private var myTimer: Timer = new Timer(1000, nCount);
private var bar: Shape = new Shape();
private var timtxt: TextField = new TextField();
public function Timerbar() {
addChild(timtxt);
addChild(bar);
updateBar();
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, fadeOut);
function countdown(e: TimerEvent): void {
nCount--;
if (nCount == 10) {
timtxt.textColor = 0xFF0000;
}
updateBar();
var segundos = nCount % 60 + "s";
var minutos = Math.floor(nCount / 60) + "m";
if (nCount > 59) {
trad = minutos + " " + segundos;
}
if (nCount < 60) {
var trad = segundos;
}
if (nCount == 60) {
trad = "60" + "s";
}
timtxt.text = trad.toString();
}
function updateBar(): void {
bar.graphics.clear();
bar.graphics.beginFill(nCount > 10 ? 0x00FF00 : 0xFF0000);
bar.graphics.drawRect(timerxpos, timerypos, totalBarWidth * (nCount / myTimer.repeatCount), 20);
bar.graphics.endFill();
}
function fadeOut(e: TimerEvent): void {
var t: Tween = new Tween(timtxt, "alpha", None.easeNone, 1, 0, .5, true);
}
}
}
} 