首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >背景图像在闪存cs5.5 AS3中自动调整大小/缩放问题

问背景图像在闪存cs5.5 AS3中自动调整大小/缩放问题
EN

Stack Overflow用户
提问于 2012-01-29 01:02:17
回答 1查看 2.2K关注 0票数 1

背景图像影片剪辑元件的名称为bg_main。这里的问题是img在浏览器窗口之外的最右下角对齐,而不是居中。这里是屏幕截图链接:http://i40.tinypic.com/29cklds.jpg

代码如下:

代码语言:javascript
复制
//set stage for FBF
stage.align = "TL";
stage.scaleMode = "noScale";

//define dynamic aspect ratios
var bg_mainHeight = bg_main.height / bg_main.width;
var bg_mainWidth = bg_main.width / bg_main.height;

//add event listener to the stage
stage.addEventListener(Event.RESIZE, sizeListener);

//conditional statement to account for various initial browswer sizes and proportions
function scaleProportional():void {
    if ((stage.stageHeight / stage.stageWidth) < bg_mainHeight) {
        bg_main.width = stage.stageWidth;
        bg_main.height = bg_mainHeight * bg_main.width;
    } else {
        bg_main.height = stage.stageHeight;
        bg_main.width = bg_mainWidth * bg_main.height;
    };  
}

//center bg_mainture on stage
function centerbg_main():void {
    bg_main.x = stage.stageWidth / 2;
    bg_main.y = stage.stageHeight / 2;
}

// make listener change bg_mainture size and center bg_mainture on browser resize
function sizeListener(e:Event):void {
    scaleProportional();
    centerbg_main();
}

//run initial locations and size
scaleProportional();
centerbg_main();
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-29 01:04:17

你看过电影剪辑的锚点在哪里了吗?这可能是你的问题..。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9047080

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档