[英]HTML5 flash canva can't stop my sound with “mouseout” function
I found on the Adobe forum an answer to some of my questions about coding MouseOver in "flash html5 mycanva.fla" to trigger a sound when hovering a button. 我在Adobe论坛上找到了一些有关在“ flash html5 mycanva.fla”中编码MouseOver以在悬停按钮时触发声音的问题的答案。 see here
看这里
The thing is, i'm stuck with the "MouseOut function" when it comes to stop the sound played when you MouseOut the button ! 关键是,当您停下MouseOut按钮时播放的声音时,我会卡住“ MouseOut功能”!
The cherry on top would be to pause the sound on mouseout and playit from the point it was paused when mouseover again. 最重要的是从再次悬停鼠标时暂停播放的位置开始暂停鼠标和播放声音。 But i don't want to appear too greedy ;-)
但是我不想显得太贪心;-)
Here's the code i used in my_flash_canva.fla: 这是我在my_flash_canva.fla中使用的代码:
var frequency = 3;
stage.enableMouseOver(frequency);
this.mybutton.addEventListener("mouseover", fl_MouseOverHandler);
function fl_MouseOverHandler(){
playSound("monstres");
//linked sound from library by dble clicking on it and named a link in the blank area.Indeed, the action script panel in "mysound" properties panel is greyed..
//works like a charm
}
this.mybutton.addEventListener("mouseout", fl_MouseOutHandler);
function fl_MouseOutHandler() {
stopSound("monstres");
// doesn't work
}
Using flash pro cc 2014. I guess i must be missing something or bad syntaxing but in my mind what does work with playSound("xxx") should work with stopSound("xxx") . 使用Flash Pro CC2014。我想我肯定缺少某些内容或语法错误,但在我看来playSound(“ xxx”)可以使用stopSound(“ xxx”)。 But apparently it 's not that simple.
但是显然这并不那么简单。 Any clue is welcome, I would be grateful.
任何线索都欢迎,我将不胜感激。 Thanx a lot.
非常感谢。
Olivier. 奥利维尔。
You can not stop a sound that way. 您不能那样停止声音。 What is
stopSound()
? 什么是
stopSound()
? If you look at your exported HTML, the playSound
is a function that plays a sound using an ID. 如果您查看导出的HTML,则
playSound
是使用ID播放声音的功能。 It should return an instance that you can control. 它应该返回一个您可以控制的实例。 You have to store that instance, and call
stop()
on it. 您必须存储该实例,然后在其上调用
stop()
。
var sound;
function fl_MouseOverHandler(){
sound = playSound("monstres");
}
this.mybutton.addEventListener("mouseout", fl_MouseOutHandler);
function fl_MouseOutHandler() {
sound.stop();
}
You will have to modify the generated playSound
method in the HTML to return the instance that is played, since it currently does not: 您将必须在HTML中修改生成的
playSound
方法以返回所播放的实例,因为该实例当前不执行以下操作:
function playSound(id, loop) {
return createjs.Sound.play(id, createjs.Sound.INTERRUPT_EARLY, 0, 0, loop);
}
This is a good thing to report to Adobe, as it should do that already. 向Adobe报告这是一件好事,因为它应该已经这样做了。 I have logged a bug to do that.
我已经记录了一个错误来做到这一点。 https://github.com/CreateJS/SoundJS/issues/218
https://github.com/CreateJS/SoundJS/issues/218
[Edit: This fix was included in Adobe Animate] [编辑:此修复程序已包含在Adobe Animate中]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.