会动画AS 2.0编程的进来看看
呵呵,会动画AS20.编程的进来看看,我自己做了小的音乐播放功能的动画
现在的问题是我想要显示当前的播放时间,但是里面却显示为0,
下面是全部的代码程序:
MP3.rar
(4.1 MB)
程序代码:
var mysound:Sound = new Sound(); mysound.attachSound("偏偏爱上你.mp3"); mysound.setVolume(50); mysound.start(0,99); t=(mysound.duration-mysound.duration%1000)/1000; t=(t-t%60)/60+t%60*0.01; n=mysound.position;//这行就是显示当前播放时间的代码,大家看看 jia_da.onRelease = function() { if(mysound.getVolume()<=100) { mysound.setVolume(mysound.getVolume()+10); } } jian_xiao.onRelease=function() { if(mysound.getVolume()>=10) { mysound.setVolume(mysound.getVolume()-10); } } var music = true; start_btn.onRelease=function(){ if(music) { mysound.stop(); music=false; SecondsOffset = mysound.position/1000; _root.num1_mc.stop(); _root.num2_mc.stop(); _root.num3_mc.stop(); _root.num4_mc.stop(); _root.num5_mc.stop(); _root.num6_mc.stop(); _root.num7_mc.stop(); _root.num8_mc.stop(); _root.num9_mc.stop(); _root.num10_mc.stop(); _root.num11_mc.stop(); _root.num12_mc.stop(); _root.num13_mc.stop(); _root.num14_mc.stop(); } else{ mysound.start(SecondsOffset,99); _root.num1_mc.play(); _root.num2_mc.play(); _root.num3_mc.play(); _root.num4_mc.play(); _root.num5_mc.play(); _root.num6_mc.play(); _root.num7_mc.play(); _root.num8_mc.play(); _root.num9_mc.play(); _root.num10_mc.play(); _root.num11_mc.play(); _root.num12_mc.play(); _root.num13_mc.play(); _root.num14_mc.play(); music=true; } } var reverse = foward = false; onEnterFrame = function () { if (reverse && mysound.position > 0) { mysound.stop(); SecondsOffset -= 3; mysound.start(SecondsOffset, 0); } if (foward && mysound.position <= mySound.duration) { mysound.stop(); SecondsOffset += 3; mysound.start(SecondsOffset, 0); } tui.onPress = function() { SecondsOffset = mysound.position/1000; reverse = true; }; tui.onRelease = function() { reverse = false; } jin.onPress = function() { SecondsOffset = mysound.position/1000; foward = true; }; jin.onRelease = function() { foward = false; } };