0
我在同一帧上有两个动画片段,但位于动画片段内的不同图层上。第一个电影剪辑玩的很好。但是,第二个即使是一个单一的框架也不会提前。我在下面提到的代码位于包含背景图像的第二个动画片段。我认为这段代码导致了这个问题,因为当我删除它时,它的播放效果非常好。此代码的功能是自动重新调整浏览器尺寸的背景图像大小。整个代码在主要时间线上工作得很好。但是,当我将它移入一个动画片段时,它引发了一个问题。2动画片段不能同时播放位于同一帧上的动画片段嵌套在动画片段as3中
//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/1000;
bg_main.y = stage.stageHeight/1000;
}
// 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();
为什么这样? stage.stageWidth/1000; – vulkanino 2012-01-30 11:07:45
它被设置为stage.stageWidth/2;最初但它导致bg图像不正确对齐。整个代码在主要时间线上工作得很好。但是,当我将它移入一个动画片段时,它引发了一个问题。 – 2012-01-30 11:18:12
你不应该写影片剪辑(主要是为了维护目的)。 'bg_main'将不存在于您的动画片段中,并可能产生错误,请检查您的输出控制台。 – Kodiak 2012-01-30 11:26:03