这里是整个项目的链接,包括所有依赖项(如果需要)。 https://www.dropbox.com/sh/3d3towtkhb4c38r/AADdxDJq9ix7bK9hTkt_VTSAa?dl=0
基本上试图清理一些我要处理的脚本,并且一直在撞墙,为什么这不起作用。我没有得到任何调试错误,所有内容似乎都与需要链接的地方相关联。我的字体似乎是嵌入的,我的所有实例名称似乎都是正确的...我唯一能想到的是我在代码中遗漏了一些愚蠢的东西。任何帮助将非常感激!没有什么比得上一团糟而且不得不修理它。
基本上,文本框应该具有基于比赛接近的倒数计时器(例如比赛X在xxx分钟内),如果没有比赛接近,它应该显示一些默认文本。目前,它似乎根本不想改变动态文本!
编辑:我还提到包含文本的RaceRibbon Movieclip也会将as3导出到com.RaceRibbon类。
package {
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.ui.Mouse;
import flash.utils.Timer;
import com.boo.CustomDate;
import com.boo.ScreensaverSimple;
import com.RaceRibbon;
// This sections is for the image slides and Hour Of Power setting.
public class Generic extends MovieClip {
// This is where you can set the Hour of Power time start and end time (in 24 hour format e.g. 1330 for 1:30pm)
// If there is no hour of power, simply set both numbers to 0
private var HourOfPowerStartTime:Number = 0;
private var HourOfPowerEndTime:Number = 0;
private var HourOfPower1StartTime:Number = 0;
private var HourOfPower1EndTime:Number = 0;
public var race_ribbon:RaceRibbon;
private var ss:ScreensaverSimple;
public var time_check_timer:Timer;
public var is_race_time:Boolean;
public var current_state:String;
public var next_race:Date;
public var race_time_arr:Array;
public var race_num:int;
private var ss_time_arr:Array;
private var delay_add_timer:Timer;
//Set default text
private var default_ribbon_text:String = "THERACES.COM.AU";
// Set Race Times
private var r1:Date = new Date(2017,5,5,12,15);
private var r2:Date = new Date(2017,5,5,12,50);
private var r3:Date = new Date(2017,5,5,13,25);
private var r4:Date = new Date(2017,5,5,14,00);
private var r5:Date = new Date(2017,5,5,14,35);
private var r6:Date = new Date(2017,5,5,15,15);
private var r7:Date = new Date(2017,5,5,15,55);
private var r8:Date = new Date(2017,5,5,16,35);
private var r9:Date = new Date(2017,5,5,17,15);
// Hide the mouse
public function Generic() {
Mouse.hide();
// Set Race Ribbon
race_ribbon = new RaceRibbon;
race_ribbon.x = 1109;
race_ribbon.y = 983;
race_time_arr = [r1,r2,r3,r4,r5,r6,r7,r8,r9];
// Display Slideshow
ss = new ScreensaverSimple;
ss.setScreensaver(screens);
// Make sure Hour of Power is not visible
HOP1.visible = false;
HOP2.visible = false;
time_check_timer = new Timer(1000);
time_check_timer.addEventListener(TimerEvent.TIMER, checkTime);
delay_add_timer = new Timer(1,1);
delay_add_timer.addEventListener(TimerEvent.TIMER, addAllChildren);
delay_add_timer.start();
}
public function addAllChildren(evt:TimerEvent=null):void {
delay_add_timer.removeEventListener(TimerEvent.TIMER, addAllChildren);
delay_add_timer.stop();
delay_add_timer = null;
addChild(race_ribbon);
time_check_timer.start();
checkTime();
}
public function checkTime(evt:TimerEvent=null):void {
setDatesToCurrent(race_time_arr);// This makes every day race day
setDatesToCurrent(ss_time_arr);// This makes all screensaver dates current
checkNextRace();
if(next_race != null && is_race_time == false)// If it isn't race time
{
setCountdown();
}
if(next_race == null && is_race_time == true)// If it's race time
{
setDefaultText();
}
checkHOP1();
checkHOP2();
}
//Call to make Hour Of Power 1 visible/invisible based on set times
private function checkHOP1():void {
HOP1.visible = (HourOfPowerStartTime || HourOfPowerEndTime);
if (!HOP1.visible) return;
var CurrentTime:Number = CustomDate.return24HourNumber();
HOP1.visible = (CurrentTime >= HourOfPowerStartTime && CurrentTime <= HourOfPowerEndTime);
}
//Call to make Hour Of Power 2 visible/invisible based on set times
private function checkHOP2():void {
HOP2.visible = (HourOfPower1StartTime || HourOfPower1EndTime);
if (!HOP2.visible) return;
var CurrentTime:Number = CustomDate.return24HourNumber();
HOP2.visible = (CurrentTime >= HourOfPower1StartTime && CurrentTime <= HourOfPower1EndTime);
}
public function setDatesToCurrent(arr:Array):void {// This makes every day race day
var cd:Date = new Date();// Current Date
for(var i:int=0;i<arr.length;i++){
arr[i].fullYear = cd.fullYear;
arr[i].month = cd.month;
arr[i].date = cd.date;
}
}
public function checkNextRace():void {
var ct:Date = new Date();// Current Time as a Date
next_race = null;
is_race_time = false;
// FOR LOOP THIS... one day
if(ct < r1) {
next_race = r1;
} else if(raceTimeSpan(r1) == true) {
is_race_time = true;
race_num = 1;
} else if(ct > raceTimeSpan(r1) && ct < r2) {
next_race = r2;
} else if(raceTimeSpan(r2) == true) {
is_race_time = true;
race_num = 2;
} else if(ct > raceTimeSpan(r2) && ct < r3) {
next_race = r3;
} else if(raceTimeSpan(r3) == true) {
is_race_time = true;
race_num = 3;
} else if(ct > raceTimeSpan(r3) && ct < r4) {
next_race = r4;
} else if(raceTimeSpan(r4) == true) {
is_race_time = true;
race_num = 4;
} else if(ct > raceTimeSpan(r4) && ct < r5) {
next_race = r5;
} else if(raceTimeSpan(r5) == true) {
is_race_time = true;
race_num = 5;
} else if(ct > raceTimeSpan(r5) && ct < r6) {
next_race = r6;
} else if(raceTimeSpan(r6) == true) {
is_race_time = true;
race_num = 6;
} else if(ct > raceTimeSpan(r6) && ct < r7) {
next_race = r7;
} else if(raceTimeSpan(r7) == true) {
is_race_time = true;
race_num = 7;
} else if(ct > raceTimeSpan(r7) && ct < r8) {
next_race = r8;
} else if(raceTimeSpan(r8) == true) {
is_race_time = true;
race_num = 8;
} else if(ct > raceTimeSpan(r8) && ct < r9) {
next_race = r9;
} else if(raceTimeSpan(r9) == true) {
is_race_time = true;
race_num = 9;
} else if(ct > raceTimeSpan(r9)) {// If all races are finished
setDefaultText();
}
}
public function raceTimeSpan(d:Date):Boolean {
var race_mins:int = 2;
var race_on:Boolean = false;
var ct:Date = new Date();
if(ct.hours == d.hours) {
var max_mins:int = d.minutes + race_mins;
if(ct.minutes >= d.minutes && ct.minutes < max_mins) {
race_on = true;
}
}
return race_on;
}
public function setCountdown():void {
var hours_left:int = int(String(CustomDate.countdownTime(next_race)).split(":")[0]);
var mins_left:int = int(String(CustomDate.countdownTime(next_race)).split(":")[1]);
mins_left = (60*hours_left)+mins_left;
is_race_time = false;
if(mins_left > 2) {
race_ribbon.setText("NEXT RACE IN <font color='#000000' letterspacing='-1'>"+(mins_left+1)+" MINUTES</font>");
race_ribbon.setBG(0);
} else if(mins_left < 3) {
if((mins_left+1) <= 1) {
race_ribbon.setText("NEXT RACE IN <font color='#fdb913' letterspacing='-1'>"+(mins_left+1)+" MINUTE</font>");
} else {
race_ribbon.setText("NEXT RACE IN <font color='#fdb913' letterspacing='-1'>"+(mins_left+1)+" MINUTES</font>");
}
race_ribbon.setBG(1);
}
}
public function setDefaultText():void {
race_ribbon.setText("<font color='#fdb913' letterspacing='-1'>"+default_ribbon_text+"</font>");
race_ribbon.setBG(1);
}
}
}
如果您不想单独浏览文件,请参阅com.RaceRibbon代码
package com {
import flash.display.MovieClip;
import fl.motion.Color;
import flash.display.Sprite;
import flash.text.*;
public class RaceRibbon extends MovieClip {
private var c1:Color;
private var c2:Color;
public function RaceRibbon() {
c1 = new Color();
c1.setTint(0xfdb913,1);
c2 = new Color();
c2.setTint(0x000000,1);
}
public function setText(str:String=""):void {
str = str.toUpperCase();
this.tb.htmlText = str;
}
public function setBG(p:int=0):void {
switch(p){
case 0:
bg.transform.colorTransform = c1;
break;
case 1:
bg.transform.colorTransform = c2;
break;
}
}
}
}
答案 0 :(得分:1)
我没有机会测试你的项目文件,只是关于消除的建议:
手动触发setDefaultText();
或直接定位 RaceRibbon 的textField(所以只需评论//
另外两个你不测试的Update test
从那些显示3行代码的那些)。
如果以下任何function setCountdown():
正常更新文字,那么您的真正问题在于:
if(mins_left > 2)
的陈述(在trace ("minutes left: " + mins_left);
之前> 2
对金额的评价是什么?看起来它可能变为< 3
或+1 <= 1
或function checkNextRace()
?如果没有,那么您的文字也不会更新。)next_race = null;
(特别是如果您设置next_race = r1;
,那么肯定会跟ctrl+shift_+enter
一起使用,应该给出调试器错误,例如&#34;无法将值设置为变量是NULL(不存在)&#34; 但是你说你没有错误所以我很困惑为什么我会这样做。Test Movie
调试不是{ {1}}选项)。无论如何代码......
public function Generic() {
Mouse.hide();
// Set Race Ribbon
race_ribbon = new RaceRibbon;
race_ribbon.x = 1109; race_ribbon.y = 983;
// Update test #1
setDefaultText(); //did via Function work?
// Update test #2
race_ribbon.tb.htmlText = "testing123"; //did via Direct Targeting work?
race_ribbon.tb.htmlText = "<font color='#fdb913' letterspacing='-1'>" + "testing123" + "</font>"; //maybe works with HTML?
// Temp disable other code for above elimination tests
/*
race_time_arr = [r1,r2,r3,r4,r5,r6,r7,r8,r9];
// Display Slideshow
ss = new ScreensaverSimple; ss.setScreensaver(screens);
// Make sure Hour of Power is not visible
HOP1.visible = false; HOP2.visible = false;
time_check_timer = new Timer(1000);
time_check_timer.addEventListener(TimerEvent.TIMER, checkTime);
delay_add_timer = new Timer(1,1);
delay_add_timer.addEventListener(TimerEvent.TIMER, addAllChildren);
delay_add_timer.start();
*/
}