如何应用该调整大小方法?

发布于 2024-09-02 17:14:54 字数 2820 浏览 1 评论 0 原文

我注意到这个完整的 Flash 网站和 Wonderring 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;

}

}

I noticed this full flash site and wonderring
http://www.houseoforange.nl/site/#/Photographers/Philip%20Riches/editorial%20women/

How can I apply the resize method like the way they did?

Any examples might help me a lot.

I have one main.swf and page.swf which loads within main.swf.
My page.swf contains thumbnail images, and it's already position in middle of stage.

When handleResizeObjectOnStage is triggered, it's start to center again on stage. But it's not the same center applied of page.swf

I want to be able to do resize like the example I have posted.

Here's what I did so far:

  // 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);
}

I also tried using scaleX/scaleY, got awkward result

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;

}

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见 2024-09-09 17:14:54

看一下这篇文章,它是针对 Flex 的,但您应该获得一些有关如何调整 Web 应用程序大小的信息:

提高 Flex 中的感知布局性能

我在我的应用程序中使用了它,可以在以下位置正确调整大小: http://www.tdteam.com/ontime/

希望有帮助
拉季斯拉夫

Take a look at this article, it is for Flex, but you should get some info on how to resize a web application:

Improving Perceived Layout Performance in Flex

I used this in my application that resizes correctly found on: http://www.tdteam.com/ontime/

hope it helps
Ladislav

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文