由网友(经年之别)分享简介:我有一个按钮,其中它改变一个文本字段以0或100(反之亦然)的值。文本字段调用函数CheckSound I have a button where it changes the value of a text field to 0 or 100 (vice versa). The text field calls t...
我有一个按钮,其中它改变一个文本字段以0或100(反之亦然)的值。文本字段调用函数CheckSound
I have a button where it changes the value of a text field to 0 or 100 (vice versa). The text field calls the function CheckSound
function CheckSound():void
{
if(options_mc.onoff_txt.text == "100")
{
tchannel = theme.play(0,9999);
}
else if(options_mc.onoff_txt.text == "0")
{
tchannel.stop();
}
}
声音停止和戏剧。当我去另一个场景在游戏中,tchannel停止播放和rchannel开始播放。这就是我想要的。我的问题是我怎么能阻止tchannel和rchannel如果该值为0,如果该值是100,我该怎么做tchannel和rchannel播放他们的正确帧?
The sound stops and plays. When I go to another scene in the game, tchannel stops playing and rchannel starts playing. This is what I want. My question is how can I stop tchannel and rchannel if the value is 0. And if the value is 100, how can I make tchannel and rchannel playable at their right frames?
推荐答案
您可以依赖于当前场景名称来决定哪些声音播放。
You can depend on the current scene name to decide which sound to play.
import flash.display.Scene;
// ...
function CheckSound():void
{
if (options_mc.onoff_txt.text == "100")
{
playCurSceneSound();
}
else if (options_mc.onoff_txt.text == "0")
{
stopMySounds();
}
}
function stopMySounds():void
{
tchannel.stop();
rchannel.stop();
}
function playCurSceneSound():void
{
var curScene:Scene = this.currentScene;
trace("We are in scene: "+curScene.name);
// use the Scene name to choose the suitable sound for this scene:
switch (curScene.name)
{
case "Scene 1" :
tchannel = theme.play(0,9999);
break;
case "Scene 2" :
rchannel = rheme.play(0,9999);
break;
default :
trace("No sound for '"+ curScene.name + "' scene! ");
break;
}
}
相关推荐
最新文章