您好我正在使用Flash动作脚本。图像以1秒的间隔从互联网上显示。但这是在眨眼。我怎么能停止闪烁,以便我可以持续看到图像。
var my_pb:mx.controls.ProgressBar;
my_pb.mode = "manual";
this.createEmptyMovieClip("img_mc", 999);
var my_mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
my_pb.label = "loading: "+target_mc._name;
};
mclListener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
var pctLoaded:Number = Math.ceil(100*(numBytesLoaded/numBytesTotal));
my_pb.setProgress(numBytesLoaded, numBytesTotal);
};
var myInterval = setInterval(testInterval, 1000);
function testInterval() {
my_mcl.addListener(mclListener);
my_mcl.loadClip("https://www.google.co.in/logos/doodles/2015/holi-festival-2015-5124794139803648-hp.gif", img_mc);
//my_mcl.loadClip("https://www.google.co.in/logos/doodles/2015/holi-festival-2015-5124794139803648-hp.gif", img_mc);
}
答案 0 :(得分:0)
为了避免您可以使用两个MovieClip,每次将图像加载到其中一个并隐藏另一个,如下所示:
var images:Array = [
'https://cdn3.iconfinder.com/data/icons/inficons/128/stackoverflow.png',
'https://cdn3.iconfinder.com/data/icons/inficons/128/joomla.png',
'https://cdn3.iconfinder.com/data/icons/inficons/128/bitcoin.png',
'https://cdn3.iconfinder.com/data/icons/inficons/128/wordpress.png',
'https://cdn3.iconfinder.com/data/icons/inficons/128/github.png'
];
var current_loader:Number = 1;
var current_img:Number = 0;
var progress_bar:mx.controls.ProgressBar;
progress_bar.mode = 'manual';
this.createEmptyMovieClip('img_01', 999);
this.createEmptyMovieClip('img_02', 998);
img_01._x = img_01._y = img_02._x = img_02._y = 20;
var loader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadStart = function(target_mc:MovieClip) {
progress_bar.visible = true;
}
listener.onLoadProgress = function(target_mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) {
progress_bar.setProgress(numBytesLoaded, numBytesTotal);
}
listener.onLoadComplete = function(target_mc:MovieClip) {
// hide the last image loader
if(target_mc._name == 'img_01'){
img_02._visible = false;
} else {
img_01._visible = false;
}
// init the progress bar and hide it
progress_bar.setProgress(0, 100);
progress_bar.visible = false;
}
var interval:Number = setInterval(load_image, 1000);
function load_image() {
loader.addListener(listener);
loader.loadClip(images[current_img], _root['img_0'+current_loader]);
// set the next loader
current_loader = current_loader == 1 ? 2 : 1;
// set next image
current_img = current_img == images.length - 1 ? 0 : current_img + 1;
}
// load the first image
load_image();
您可以看到此代码正常工作here。
有时,我们无法看到进度条,因为图像加载速度非常快,当然如果要使用大图像,则必须增加间隔。
希望可以提供帮助。