我正在尝试为我工作的公司开发一个数字标牌应用程序,使用 flash cs6。它实际上由两个应用程序组成,一个是服务器端,另一个安装在具有运行 windows xp 的集成计算机的电视显示器上。服务器应用程序只不过是管理员用来输入通过某些 php 存储在 mysql 数据库中的数据的表单。那工作正常。
我的问题是在显示器中运行的客户端。该应用程序实际上非常简单:它应该从 mysql 表中加载不同种类的信息的“部分”,因此加载所有存储在服务器中的文本、图像和视频。事情是加载器与计时器并行运行。计时器负责调用影片剪辑和帧,这样我就不需要为时间轴中的所有内容设置动画,并且应用程序会在循环中从一个部分到另一个部分继续运行。我在哪里发现问题。我无法找到一种合适的方法来以与计时器配合良好的方式对此类加载程序进行编程。所以最终结果是图像和视频被部分加载或从未加载,使客户端应用程序以奇怪的方式运行。这是应用程序部分之一的示例:
import flash.utils.Timer;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.TimerEvent;
import fl.transitions.*;
import fl.transitions.easing.*;
var randomNumber:Number = Math.random();
var xAnivItemRef:Number = 75;
var yAnivItemRef:Number = 140;
var anivArray:Array = new Array ;
var endingTimer:Timer = new Timer(10000);
var loopTimer:Timer = new Timer(500);
var counter:uint = 0;
var fotosURL:String = "http://www.maxionline.com.br/maxi_sds/server/img/aniversariantes/";
var current_time = new Date();
var i:uint = 0;
var alphaTween:Tween;
var aniversariante_mc:MovieClip;
var numAniversariantes:uint;
endingTimer.addEventListener(TimerEvent.TIMER, leaveEvents);
loopTimer.addEventListener(TimerEvent.TIMER, loadAniv);
function setTitleMonth(event:Event = null)
{
var month:String = current_time.getMonth();
switch (month)
{
case "0" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "janeiro!";
break;
case "1" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "fevereiro!";
break;
case "2" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "março!";
break;
case "3" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "abril!";
break;
case "4" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "maio!";
break;
case "5" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "junho!";
break;
case "6" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "julho!";
break;
case "7" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "agosto!";
break;
case "8" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "setembro!";
break;
case "9" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "outubro!";
break;
case "10" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "novembro!";
break;
case "11" :
anivTitle_mc.anivTitlePt2_mc.month_txt.text = "dezembro!";
break;
default :
break;
}
}
function anivSetup(event:Event = null):void
{
var anivLoader:URLLoader = new URLLoader();
anivLoader.dataFormat = URLLoaderDataFormat.TEXT;
anivLoader.load(new URLRequest("http://www.maxionline.com.br/maxi_sds/client/dataRecoverAniv.php?_rand =" + randomNumber));
anivLoader.addEventListener(Event.COMPLETE, getAnivData);
}
function getAnivData(evt:Event = null):void
{
var anivDataStr:String = evt.target.data;
var anivDataArray:Array = anivDataStr.split("&");
var numItemsStr:String = anivDataArray[anivDataArray.length - 1].substr(5);
var numItems:Number = Number(numItemsStr) * 4;
numAniversariantes = numItems/4;
anivDataArray.splice(anivDataArray.length - 1, 1);
for (var i:uint=0; i<numItems; i++)
{
anivArray.push(anivDataArray[i]);
}
loadAniv();
anivMask_mc.gotoAndPlay("on");
endingTimer.start();
loopTimer.start();
}
function loadAniv(event:Event = null):void
{
var aniversariante:anivItem_mc = new anivItem_mc();
aniversariante.name = "aniversariante" + counter;
if (numAniversariantes > 12)
{
if (counter < 4)
{
aniversariante.y = yAnivItemRef + (220 * counter);
aniversariante.x = xAnivItemRef;
}
if (counter >= 4 && counter < 8)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 4));
aniversariante.x = xAnivItemRef + 1355;
}
if (counter >= 8 && counter < 12)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 8));
aniversariante.x = xAnivItemRef + 250;
}
if (counter >= 12 && counter < 16)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 12));
aniversariante.x = xAnivItemRef + 895;
}
}
if (numAniversariantes > 8 && numAniversariantes <= 12)
{
if (counter < 4)
{
aniversariante.y = yAnivItemRef + (220 * counter);
aniversariante.x = xAnivItemRef;
}
if (counter >= 4 && counter < 8)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 4));
aniversariante.x = xAnivItemRef + 1355;
}
if (counter >= 8 && counter < 12)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 8));
aniversariante.x = xAnivItemRef + 250;
}
}
if (numAniversariantes > 0 && numAniversariantes <= 8)
{
if (counter < 4)
{
aniversariante.y = yAnivItemRef + (220 * counter);
aniversariante.x = xAnivItemRef + 200;
}
if (counter >= 4 && counter < 8)
{
aniversariante.y = yAnivItemRef + (220 * (counter - 4));
aniversariante.x = xAnivItemRef + 1150;
}
}
anivLoader_mc.addChild(aniversariante);
aniversariante_mc = MovieClip(root).aniv_mc.anivLoader_mc.getChildByName("aniversariante" + counter);
aniversariante_mc.anivName_txt.text = anivArray[i];
aniversariante_mc.day_mc.anivDay_txt.text = anivArray[i + 1];
var imgLoader:Loader = new Loader();
imgLoader.load(new URLRequest(fotosURL + anivArray[i + 3]));
imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGR ESS,imageLoading);
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,imag eLoaded);
var fadein:TransitionManager = new TransitionManager(aniversariante_mc);
fadein.startTransition({type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});
counter++;
i = i + 4;
if (i >= anivArray.length)
{
loopTimer.stop();
loopTimer.removeEventListener(TimerEvent.TIMER, loadAniv);
}
}
function leaveEvents(event:TimerEvent):void
{
endingTimer.removeEventListener(TimerEvent.TIMER, leaveEvents);
endingTimer.stop();
anivMask_mc.gotoAndPlay("off");
play();
}
function imageLoading(evt:ProgressEvent):void
{
var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
updateProgress(loaded);
}
function updateProgress(vl:Number)
{
aniversariante_mc.photo_mc.preloader_mc.loadingBar_mc.width = vl * aniversariante_mc.photo_mc.preloader_mc.loadingBar_mc.width;
}
function imageLoaded(event:Event):void
{
var loadInfo:LoaderInfo = (event.target as LoaderInfo);
aniversariante_mc.photo_mc.photoLoader_mc.addChild(loadInfo.cont ent);
}
anivSetup();
setTitleMonth();
stop();
.fla 可以在这里下载:
http://www.maxionline.com.br/maxi_sds/sds_client.fla
任何建议将不胜感激!