我有以下代码:
//Importorting classes
import flash.events.*;
import flash.display.*;
import flash.net.*;
//Variabile declaration
var source:*; //variabile adresaressing to the source
var loader:Loader;
var loaderIndex:Number = 1; //variabile which remembers the value of the shown image.
function loadIt()
{
// Loading image
loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onLoadingProgress);
loader.contentLoaderInfo.addEventListener(Event.INIT,initHandler);
addChild(loader); //functia adauga pe scena imaginea incarcata
imagine_stepper.addEventListener(Event.CHANGE,changeHandler);
// Loading the first image...
loadImage();//lanseaza procesul de incarcare al primei imagini
}
function initHandler(event:Event):void
{
source = loader.content;
source.alpha = 0;
source.x = zonaAfisare_mc.x;
source.y = zonaAfisare_mc.y;
addEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
function onLoadingProgress(evt:ProgressEvent):void{
var percentage:Number=(evt.bytesLoaded/evt.bytesTotal)*100;
var total_percentage:Number=Math.floor(percentage);
loaded.text=total_percentage.toString()+" %";
loaded_bar.setProgress(total_percentage,100);
}
function changeHandler(event:Event):void
{
loaderIndex = imagine_stepper.value;
loadImage();
}
function enterFrameHandler(event:Event):void
{
if( source.alpha < 1 ){
source.alpha += .1;
}else{
removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
}
}
// Returning the file name path: /"imagine"+value of the variable loaderIndex +file extension
function getPath():String
{
return ("images/image"+loaderIndex+".jpg");
}
function loadImage():void
{
loader.load(new URLRequest(getPath()));
}
loadIt();
它给了我错误#2000。昨天它工作,现在我有这个错误,没有改变任何东西:没有路径,没有照片。 我该怎么办?
我理解:看起来这条线可能是原因: loader.load(new URLRequest(getPath()));
将其分成两三行。
有人可以输入正确的代码吗?