【问题标题】:scrolling text field help as3滚动文本字段帮助 as3
【发布时间】:2017-01-01 14:08:44
【问题描述】:

目前在舞台下收到文本,我想上台并停在舞台上的某个位置 (97, 233.10)。我对在哪里停止它以及使用什么代码有点困惑?

addEventListener(Event.ENTER_FRAME, mcInfo);

 function mcInfo (e:Event):void {

//check position of logo
//if inside the stage move left to right
//if outside stage reposition

if (info.x<stage.stageWidth) {
    info.x+=30;
    stop();
    } else {
        //reset position
        info.x=-450;
    }
}

干杯!

当我滚动浏览我的其余页面时,Flash 现在似乎也返回了一个输出错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at finaldesign_fla::MainTimeline/mcInfo()

【问题讨论】:

    标签: actionscript-3 flash adobe flash-cs6 flash-cc


    【解决方案1】:

    在 if 语句中,我们检查对象是否超出了目标位置,如果超出则停止循环。否则继续增加对象的位置。

    targetPosition = {x:97, y:233.10};
    
    addEventListener(Event.ENTER_FRAME, mcInfo);
    
    function mcInfo(e:Event) {
       if (info.x >= targetPosition.x) {
          info.x = targetPosition.x;
          removeEventListener(Event.ENTER_FRAME, mcInfo);
       } else {
          info.x += 30;
       }
    }
    

    【讨论】:

    • 谢谢。但是我如何让它停在那个位置(97、233.10)?还在循环那行代码?
    • 如果对象将在 x=97 处停止,则行 if (info.x 似乎没有必要
    • 如何在我的代码中实现它以在 x=97 处停止?还是有点难过。
    【解决方案2】:

    确保信息在舞台上并尝试添加:

    if(info != null && stage != null)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多