我有一个简单的Flash登陆页面,它有2个动态旋转图像的区域和2个动态文本区域。所有区域都由单个XML文件控制。
当我更改XML文件中的文本内容或者更新文件夹中的图像并在我的adobe flash编辑器中进行测试时,更改是即时的。当我打开firefox或IE时,带有flash文件的页面不会反映更新。我删除了我的历史,告诉adobe flash不允许任何闪存存储在我的计算机上,关闭并重新加载页面但无济于事。我可以获取要刷新的内容的唯一方法是重命名文件,保存在新文件夹中并重命名它绘制的xml页面。我甚至在最后添加了kiosk.swf?id =#randrange(10000,99999)#ctring,看看它是否让浏览器认为它是一个新文件。没有重命名和移动文件/文件夹将使浏览器显示新内容。
这个简单的Flash页面可以作为自助服务终端的目标网页。
<style type="text/css" media="screen">
body { margin:0; padding:0; overflow:hidden;background-color:#153d6f; }
#myID { height:100%;background-color:#153d6f; }
</style>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="swffit.js"></script>
<cfoutput>
<script type="text/javascript">
swfobject.embedSWF("kiosk.swf?id=#randrange(10000,99999)#", "myID", "100%", "100%", "9.0.0", "expressInstall.swf");
swffit.fit("myID");
</script>
</cfoutput>
</head>
<body>
<div id="myID"></div>
</body>
................... 根据您的要求,actionscript3将动态图像拉到两个区域之一 ...................
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var my_speed:Number;
var my_total:Number;
var my_images:XMLList;
var my_loaders_array:Array = [];
var my_success_counter:Number = 0;
var my_playback_counter:Number = 0;
var my_slideshow:Sprite = new Sprite();
var my_image_slides:Sprite = new Sprite();
var my_timer:Timer;
var my_prev_tween:Tween;
var my_xml_loader:URLLoader = new URLLoader();
my_xml_loader.load(new URLRequest("content.xml"));
my_xml_loader.addEventListener(Event.COMPLETE, processXML);
function processXML (e:Event):void{
var my_xml:XML = new XML(e.target.data);
my_speed=my_xml.option2.slideShow2.@SPEED;
my_images=my_xml.option2.slideShow2.IMAGE;
my_total=my_images.length();
loadImages();
}
function loadImages():void{
for (var i:Number = 0; i < my_total; i++){
var my_url:String = my_images[i].@URL;
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(my_url));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
my_loaders_array.push(my_loader);
}
}
function onComplete(e:Event):void{
my_success_counter++;
if (my_success_counter == my_total){
startShow();
}
}
function startShow():void{
addChild(my_slideshow);
my_slideshow.addChild(my_image_slides);
setChildIndex(my_slideshow,0);
nextImage();
my_timer = new Timer(my_speed*1000);
my_timer.addEventListener(TimerEvent.TIMER, timerListener);
my_timer.start();
}
function nextImage():void{
var my_image:Loader = Loader(my_loaders_array[my_playback_counter]);
my_image_slides.addChild(my_image);
//my_image.x = (stage.stageWidth - my_image.width)/2;
//my_image.y = (stage.stageHeight - my_image.height)/2;
if (my_image.width == my_image.height) {
my_image.width = 305;
my_image.height = 305;
} else if( my_image.width > my_image.height ) {
var newWidth = (my_image.width *(305 / my_image.height));
my_image.height = 305;
my_image.width = newWidth;
} else if( my_image.width < my_image.height ) {
var newHeight = (my_image.height *(305 / my_image.width));
my_image.width = 305;
my_image.height = newHeight;
}
my_image.x = 80;
my_image.y = -140;
new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);
}
function timerListener (e:TimerEvent):void{
hidePrev();
my_playback_counter++;
if (my_playback_counter == my_total){
my_playback_counter =0;
}
nextImage();
}
function hidePrev():void{
var my_image:Loader=Loader(my_image_slides.getChildAt(0));
my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut)
new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
}
function onFadeOut(e:TweenEvent):void{
my_image_slides.removeChildAt(0);
}
答案 0 :(得分:2)
要避免在actionscript中缓存,请添加“?”然后在你正在加载的项目的URL末尾有一些独特的字符(无论是图像,swfs,xml等等)。例如:
var cacheBuster:String = "?"+(new Date()).time.toString();
my_loader.load(new URLRequest(my_url+cacheBuster));
new Date()。time返回自1-1-1970以来的毫秒数,因此它是生成唯一字符串的不错选择。
如果它的kiosk.swf即缓存,则javascript非常相似:
var cacheBuster = "?"+(new Date()).getTime().toString();
swfobject.embedSWF("kiosk.swf"+cacheBuster, ....
答案 1 :(得分:0)