我做了一个照片库,我使用 Flash cs5 As3 UILoader 组件,如何在中心加载所有不同尺寸的照片?左上角的Uiloader组件注册,需要make to中间吗?舞台宽 1000 像素,高 420 像素。
我的照片大小不一,有的803x400,有的580x400,uiLoader注册点在左上角,就是这个问题,如果我把580x400放在中间,803x400px的手机会在右边很远.
有没有办法解决这个问题?
[www.bradmarkel.net] 点击野生动物,你就会明白我的意思。
这是我的画廊代码,感谢您的时间!
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import fl.containers.UILoader;
import flash.text.TextField;
import flash.display.SimpleButton;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
stage.colorCorrection = ColorCorrection.ON;
var myImage:String = "smallNews/resized web news photos/00.jpg";
var request:URLRequest = new URLRequest(myImage);
uiLoader.addEventListener(Event.COMPLETE, completeHandler);
uiLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
uiLoader.load(request);
function progressHandler(event:ProgressEvent):void
{
status_txt.text = "Percentage Loaded: " + Math.round(event.target.percentLoaded);
}
function completeHandler(event:Event):void
{
var spr = new Sprite();
// Place spr anywhere on the stage
spr.x = stage.stageWidth / 6 - uiLoader.content.width / 6;
spr.y = stage.stageHeight / 235 - uiLoader.content.height / 235;
spr.addChild( uiLoader );
addChild( spr );
// Center uiLoader in spr
uiLoader.x = - uiLoader.width / 500;
uiLoader.y = - uiLoader.height / 235;
new Tween(spr,"rotationX",Elastic.easeOut,45,0,4,true);
}
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
//variable is a container that holds some value...;
var imageNumber:Number = 0;
function checkNumber():void
{
next_btn.visible = true;
back_btn.visible = true;
//If the imageNumber is = 47, then do something...
if (imageNumber == 24)
{
trace(imageNumber);
next_btn.visible = false;
}
//if the imageNumber is = 1, then don't show the back button
if (imageNumber == 0)
{
trace(imageNumber);
back_btn.visible = false;
}
}
checkNumber();
function nextImage(evtObj:MouseEvent):void
{
//Adding to the current value +1
imageNumber++;
uiLoader.source = "smallNews/resized web news photos/0" + imageNumber + ".jpg";
checkNumber();
}
back_btn.addEventListener(MouseEvent.CLICK, backImage);
function backImage(evtObj:MouseEvent):void
{
//Subtract 1 from the current value
imageNumber--;
uiLoader.source = "smallNews/resized web news photos/0" + imageNumber + ".jpg";
checkNumber();
}
stop();