当movieclip转移到下一个关键帧as3时,动画无法正常工作

时间:2012-02-03 11:56:22

标签: flash actionscript-3

默认情况下,我在主时间轴的第一帧上有2个动画片段。前两个动画片段的动作脚本代码。它们保存在每个单独的图层上。他们工作得很好但是当我在maintime线上将所有三个关键帧从第一帧移到第二帧时。它不能正常工作。我将它们转移到下一个关键帧的原因是因为我不想在第一帧上插入预加载器。这是我得到的输出消息:

 at Flashphotographygallerywebsite10_fla::MainTimeline/frame2()
          at flash.display::Sprite/constructChildren()
          at flash.display::Sprite()
          at flash.display::MovieClip()
          at flash.display::Sprite/constructChildren()
          at flash.display::Sprite()
          at flash.display::MovieClip()
          at Flashphotographygallerywebsite10_fla::envolop_3()

这是动作脚本代码:

/*Re-sizeable background*/
//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();




/*envelope align to center*/
function resizeHandler(e:Event):void
{
  envelope_mc.x = (envelope_mc.stage.stageWidth / 2) - (envelope_mc.width / 1.15);
  envelope_mc.y = (envelope_mc.stage.stageHeight / 2) - (envelope_mc.height / 1.15);
}

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);

stage.dispatchEvent(new Event(Event.RESIZE));



stop();

1 个答案:

答案 0 :(得分:0)

您收到此错误是因为您的第一帧是空的,这意味着您在运行程序时未定义2个动画片段。确保这是问题的最简单方法是在第一帧上使alpha = 0,在第二帧上使alpha = 1。如果您没有错误,那么这将确认在第一帧上未定义这些动画片段。

解决方案是在这些影片剪辑确实存在的情况下为第二代码提供代码。或者在第一帧上使它们可见= false,以便它们始终可用。