【问题标题】:Animations not working correctly when movieclip is shifted to next keyframe as3动画剪辑转移到下一个关键帧 as3 时动画无法正常工作
【发布时间】:2012-02-03 11:56:21
【问题描述】:

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

 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();

【问题讨论】:

  • 信封_mc和bg_main是否存在于这个框架上?
  • 调试模式设置为 ON 后的输出:frame2:59] 在 flash.display::Sprite/constructChildren() 在 flash.display::Sprite() 在 flash.display::MovieClip() 在 flash .display::Sprite/constructChildren() at flash.display::Sprite() at flash.display::MovieClip() at Flashphotographygallerywebsite10_fla::envolop_3() 我没有收到任何错误消息。

标签: flash actionscript-3


【解决方案1】:

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

解决方案是在这些影片剪辑真正存在时推迟第二个代码。或者让它们在第一帧可见 = false,以便它们始终可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-29
    • 2021-06-11
    相关资源
    最近更新 更多