滚动文本字段帮助as3

时间:2016-08-25 08:27:50

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

目前我的舞台上有文字,我想登上舞台并停在舞台上的某个位置(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()

2 个答案:

答案 0 :(得分: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;
   }
}

答案 1 :(得分:0)

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

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.min.js"></script>
<canvas id="myChart" width="400" height="400"></canvas>