我注意到这个完整的Flash网站并且很奇怪 http://www.houseoforange.nl/site/#/Photographers/Philip%20Riches/editorial%20women/
如何像他们一样应用调整大小的方法?
任何例子都可能对我有所帮助。
我有一个main.swf和page.swf在main.swf中加载。 我的page.swf包含缩略图,它已经位于舞台中间位置。
当触发handleResizeObjectOnStage时,它会再次开始在舞台上居中。但它与page.swf应用的中心不同
我希望能像我发布的例子一样调整大小。
这是我到目前为止所做的:
// Constructor
public function Gallery()
{
addEventListener(Event.ADDED_TO_STAGE, handleOnStage, false, 0, true);
}
private function handleOnStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, handleOnStage);
tabSWFLoader = Vector.<String>([INTRO_SWF, ...]);
loader = new Loader();
nextMC = new Sprite(); // uses to load next page
currentMC = new Sprite();
initObjectsOnStage(event);
initIntro();
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, handleResizeObjectsOnStage, false, 0, true);
}
private function handleResizeObjectsOnStage(event:Event=null):void
{
removeEventListener(Event.RESIZE, handleResizeObjectsOnStage);
initObjectsOnStage(event);
}
private function initObjectsOnStage(event:Event):void
{
initBackground();
initMenu();
var definedWidth:Number = stage.stageWidth;
var definedHeight:Number = stage.stageHeight;
if (event.type == Event.RESIZE) {
var tempMC:Sprite = getCurrentMC();
tempMC.x = (definedWidth - tempMC.width) * 0.5;
addChild(tempMC);
}
}
private function initIntro():void
{
loader.load(new URLRequest(tabSWFLoader[currentIndexSWF]));
loader.contentLoaderInfo.addEventListener(Event.OPEN, handleDisplayIntroImage, false, 0, true);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleCompletedIntroImage, false, 0, true);
}
private function handleDisplayIntroImage(event:Event):void
{
currentMC.alpha = 0;
TweenLite.to(currentMC, DELAY, { alpha:1, ease:Linear.easeIn });
addChild(currentMC);
}
private function handleCompletedIntroImage(event:Event):void
{
// Add into currentMC
currentMC.addChild(loader);
}
我也尝试过使用scaleX / scaleY,得到了尴尬的结果
private function initObjectsOnStage(event:Event):void
{ ... var definedWidth:Number = stage.stageWidth; var definedHeight:Number = stage.stageHeight;
if (event.type == Event.RESIZE) {
var tempMC:Sprite = getCurrentMC();
addChild(tempMC);
var scaleX:Number = definedWidth/tempMC.width;
var scaleY:Number = definedHeight/tempMC.height;
(scaleX > scaleY) ? scaleX = scaleY : scaleY = scaleX;
tempMC.scaleX = scaleX;
tempMC.scaleY = scaleY;
}
}
答案 0 :(得分:0)
看看这篇文章,它适用于Flex,但是你应该获得一些关于如何调整Web应用程序大小的信息:
Improving Perceived Layout Performance in Flex
我在我的应用程序中使用了这个,正确调整了大小:http://www.tdteam.com/ontime/
希望它有所帮助 拉吉斯拉夫