Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3-索引超出范围(错误#1125)_Actionscript 3 - Fatal编程技术网

Actionscript 3 AS3-索引超出范围(错误#1125)

Actionscript 3 AS3-索引超出范围(错误#1125),actionscript-3,Actionscript 3,我打开了这个文件,通过测试,我得到了这个错误: RangeError:错误#1125索引超出范围 //主BLIT画布 var canvas:BitmapData=新的BitmapData(1024768,false); addChild(新位图(画布)); addChild(sl); //性质 var-ind:int; var偏移量:int; var-rect:矩形; var zp:Point=新点(); var destX:int=0; var currentX:int=0; //从库中加载照

我打开了这个文件,通过测试,我得到了这个错误:

RangeError:错误#1125索引超出范围

//主BLIT画布
var canvas:BitmapData=新的BitmapData(1024768,false);
addChild(新位图(画布));
addChild(sl);
//性质
var-ind:int;
var偏移量:int;
var-rect:矩形;
var zp:Point=新点();
var destX:int=0;
var currentX:int=0;
//从库中加载照片
var照片:Vector.=新向量();
对于(变量i:int=1;i
或

检查ind和ind+1,确保它们小于照片长度

    // MAIN BLIT CANVAS
var canvas:BitmapData = new BitmapData(1024, 768, false);
addChild(new Bitmap(canvas));
addChild(sl);

// PROPERTIES
var ind:int;
var offset:int;
var rect:Rectangle;
var zp:Point = new Point();
var destX:int = 0;
var currentX:int = 0;

// LOAD PHOTOS FROM LIBRARY
var photos:Vector.<BitmapData> = new Vector.<BitmapData>();
for(var i:int=1; i<5; i++)
{
    var ref:Class = getDefinitionByName("p"+i) as Class;
    photos.push(new ref());
}

// LOAD BITMAPDATA INTO MEMORY
for(i=0; i<4;i++)
    canvas.copyPixels(photos[i], new Rectangle(0,0,1,1), zp);

// FIGURE OUT POSITION OF SLIDER AND CALL RENDER
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
                     destX = Math.ceil((sl.thumb.x/908) * 13312);
                     currentX += (destX - currentX) * 0.15;
                     render();
                       });

// RENDER PIXELS TO CANVAS
function render():void
{
    ind = currentX / 1024;
    offset = currentX % 1024;
    rect = new Rectangle(offset, 0, 1024-offset, 768);
    canvas.copyPixels(photos[ind], rect, zp);
    if(currentX < 13312)
        canvas.copyPixels(photos[ind+1], canvas.rect, new Point(1024-offset, 0));
}

//START DRAGGING SLIDER
sl.thumb.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void {
      sl.thumb.startDrag(false, new Rectangle(0, 0, 909, 0));
      });

//START DRAGGING SLIDER
stage.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent):void {
      sl.thumb.stopDrag();
      });
canvas.copyPixels(photos[ind], rect, zp);
canvas.copyPixels(photos[ind+1], canvas.rect, new Point(1024-offset, 0));