我一直在使用Swiffy很容易地输出。fla文件,但后来我被告知,如果在iPad上以横向模式观看,屏幕会在项目的一半以上交替"闪烁"白色。非常奇怪的行为,我无法在任何其他设备上复制。
所以,我已经开始尝试使用CreateJS来解决这个问题。此时我只知道足够的JS来编辑别人开发的代码,所以到目前为止我的效率非常低。
我已经说到这里了:
/* js
this.stop();
var t=setTimeout(function(){(this.play())}, 1000);
*/
or
/* js
this.stop();
setTimeout(this.play(), 1000);
*/
我没能让动画介意超时,我已经尝试了许多不同的变体,试图让一些神奇的事情发生。它所做的就是立即加载下一帧,它根本不会暂停。我哪里出错了?
这是原来的Actionscript:
stop();
var shortTimer:Timer=new Timer(1000);
shortTimer.addEventListener(TimerEvent.TIMER, timerN1);
shortTimer.start();
function timerN1(e:TimerEvent):void{
play();
shortTimer.reset();
}
任何帮助将是非常感激的,因为我没有得到任何地方我自己试图解决这个问题是在我的休息时间几个星期,我的客户变得越来越生气。更像是一名设计师,但在编程方面仍然没有受过多少教育。再说一次,在这一点上,即使是一个建议也会非常有帮助。好像破解不了
这个语法更正确:
<>之前
/* js
this.stop();
var t=setTimeout(function(){(this.play())}, 1000);
*/
之前然而,你可能会发现"this"是Window,而不是调用它的MovieClip。您可以通过使用局部引用(在本例中是"_this")来解决这个问题。
<>之前
/* js
this.stop();
var _this = this;
var t=setTimeout(function(){
console.log(this, _this);
_this.play();
}, 1000);
*/
之前你可以通过查看你的控制台来测试这一点,看看"this"one_answers"_this"之间的区别是什么。
欢呼。
您是否可以发布更多您正在使用的代码?你有没有试过使用onAnimationEnd函数:
var _this = this;
_this.onAnimationEnd = function() {
_this.stop();
setTimeout(function(){
_this.play();
}, 1000)
}
试着在你的setTimeout
函数中保持你的作用域:
sprite.on('animationend', function(event) {
event.target.stop();
setTimeout(animationend.bind(event.target), 1000);
});
function animationend() {
this.gotoAndPlay('run');
}
通过使用.bind()
,您可以在被调用的函数中传递一个对象作为作用域。