0

我是 Flash 和 AS3 的新手,我正在尝试制作一个图片库。出于某种原因,它..没有做任何事情。

我有 2 个按钮:返回和下一步以及用于加载进度的动态文本字段。zonaAfisare_mc 是图像的容器。它不加载任何图像,这是代码:

import flash.events.*;
import flash.display.*;
import flash.net.*;

var source:*; 
var loader:Loader; 
var loaderIndex:Number = 1; 

next.addEventListener(MouseEvent.CLICK, loadNext);
back.addEventListener(MouseEvent.CLICK, loadPrev);

function loadIt()
    {

        loader = new Loader();
        loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onLoadingProgress); 
        loader.contentLoaderInfo.addEventListener(Event.INIT,initHandler);          
        addChild(loader);           
        loadImage();
    }


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()+" %";
    }

function loadNext(event:Event):void
    {
        if (loaderIndex = 5) {
            loaderIndex = 1
            loadImage();
        } else {            
            loaderIndex = loaderIndex + 1; 
            loadImage();
        }
    }
function loadPrev(event:Event):void
    {
        if (loaderIndex = 1) {
            loadImage();
        } else {
            loaderIndex = loaderIndex - 1; 
            loadImage();
        }
    }



function enterFrameHandler(event:Event):void
    {
        if( source.alpha < 1 ){ 
            source.alpha += .1;
        }else{
            removeEventListener(Event.ENTER_FRAME,enterFrameHandler);
        }
    }

function getPath():String
    {
        return ("images/image"+loaderIndex+".jpg");
    }
function loadImage():void
    {
        loader.load(new URLRequest(getPath()));
    }
loadIt();
4

0 回答 0