我有这个.fla文件,在你点击射击按钮之前,它不会播放狙击手射击的声音。现在,它在游戏播放时播放3-4次,甚至没有播放应该与它一起播放的电影剪辑。
请帮帮我!
我刚刚遇到了这个问题,并检查了我所知道的所有可能的解决方法。我不知道这是不是一个bug,但我需要马上修复它,否则这个游戏,我们的论文,就完了!(
链接的download:名称是sample_1,几乎8mb的大小,保存在闪存PRO6格式。
按照@musefan的要求编写示例代码。
这是第一个阶段。正如您注意到的,它不需要播放任何音乐。
function shootfired():void{
if(sample_1.reloading == 0 && sample_1.GamePlaying == true){
if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian1)){//if fired on target
if(mission.civillian1.currentLabel != "death"){
mission.civillian1.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian2)){//if fired on target
if(mission.civillian2.currentLabel != "death"){
mission.civillian2.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian3)){//if fired on target
if(mission.civillian3.currentLabel != "death"){
mission.civillian3.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian4)){//if fired on target
if(mission.civillian4.currentLabel != "death"){
mission.civillian4.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian5)){//if fired on target
if(mission.civillian5.currentLabel != "death"){
mission.civillian5.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian6)){//if fired on target
if(mission.civillian6.currentLabel != "death"){
mission.civillian6.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.civillian7)){//if fired on target
if(mission.civillian7.currentLabel != "death"){
mission.civillian7.gotoAndPlay("death");
trace("target hit!");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.target1)){//if fired on target
if(mission.target1.currentLabel != "death"){
mission.target1.gotoAndPlay("death");
}
}
else if(MC_SniperGun.MC_Sniper.MC_SniperScope.RedDot.hitTestObject(mission.target2)){//if fired on target
if(mission.target2.currentLabel != "death"){
mission.target2.gotoAndPlay("death");
}
}
MC_SniperGun.MC_Sniper.gotoAndPlay(2);
}
}接下来,这是狙击枪的代码,再一次没有要播放的音乐。
import flash.events.*;
import flash.geom.Rectangle;
SniperFunction();
function SniperFunction():void{
stop();
MC_SniperGun.addEventListener(TouchEvent.TOUCH_BEGIN, Tdrag);
MC_SniperGun.addEventListener(TouchEvent.TOUCH_END, Tdrop);
function Tdrag(e:TouchEvent){
MC_SniperGun.MC_Sniper.startTouchDrag(e.touchPointID, false, boundArea);
}
function Tdrop(e:TouchEvent) {
MC_SniperGun.MC_Sniper.stopTouchDrag(e.touchPointID);
}
MC_SniperGun.addEventListener(MouseEvent.MOUSE_DOWN, drag);
MC_SniperGun.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(event:MouseEvent):void {
MC_SniperGun.MC_Sniper.startDrag(false,boundArea);
}
function drop(event:MouseEvent):void {
MC_SniperGun.MC_Sniper.stopDrag();
}
gotoAndPlay("mission" + sample_1.MissionNumber);
}最后是电影片段中的代码,其中包含了狙击枪的动画。
SniperShot();
function SniperShot():void{
sample_1.reloading = 1;
trace("Sniper Shot");
}包含狙击枪动画的电影剪辑有一个帧,它有一个声音属性,当播放特定帧时,狙击手音乐文件将被播放,但当我玩该游戏时,动画不会播放,但狙击手音乐文件会播放3-4次,而不是按下射击按钮。
发布于 2013-01-11 11:11:46
将my.mp3替换为保存到库中的声音
var snd:Sound = new Sound();
snd.load(new URLRequest("my.mp3"));
snd.play();然后让它转到狙击手动画
https://stackoverflow.com/questions/14263600
复制相似问题