flash AS3.0 制作一个播放器,报错:1046:找不到类型,或者它不是编译时常数:jd_mc。
importflash.media.Sound;importflash.media.SoundChannel;importflash.events.MouseEvent;...
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.events.Event;
var _sound:Sound =new Sound();
var _channel:SoundChannel =new SoundChannel();
var _playList:Array=new Array();
var _index:int=0;
var pos:Number =0;
var B:Boolean ;
var w:Number =jd_mc.jdt_mc.width;
var len:Number =_sound.length ;
_playList=["1.mp3","2.mp3","3.mp3"];
play_btn.addEventListener(MouseEvent.CLICK,play1);
function play1(event:MouseEvent ):void {
if (_index<_playList.length) {
_sound=new Sound ();
_sound.load (new URLRequest (_playList[_index]));
_channel=_sound.play(pos);
_channel.addEventListener (Event.SOUND_COMPLETE,oncomplete);
_index++;
_sound.addEventListener (Event.ID3,onID3);
function onID3(event:Event):void {
var id3Display:TextField =new TextField ();
addChild(id3Display);
id3Display.x=50;
id3Display.y=200;
id3Display.width=120;
id3Display.height=20;
id3Display.background=true;
id3Display.multiline=true;
id3Display.wordWrap=true;
id3Display.appendText(_sound.id3 .songName +"\n");
songname.text=_sound.id3.songName ;
}
var w:Number =jd_mc.jdt_mc.width;
var len:Number =_sound.length;
addEventListener(Event.ENTER_FRAME,jd);
function jd(event:Event):void {
len=_sound.length ;
pos=_channel.position ;
jd_mc.jdk_mc.x=pos/len*w;
}
function oncomplete(event:Event):void {
pos=0;
jd_mc.jdk_mc.x=0;
}
}
}
pause_btn.addEventListener (MouseEvent.CLICK,zt);
function zt(event:MouseEvent):void{
pos=_channel.position ;
_channel.stop();
_index--;
B=false;
}
stop_btn.addEventListener (MouseEvent.CLICK,tz);
function tz(event:MouseEvent):void{
pos=0;
_channel.stop();
_index--;
B=false;
addEventListener(Event.ENTER_FRAME ,jd);
function jd(event:Event ):void {
pos=0;
jd_mc.jdk_mc.x=0;
}
}
next_btn.addEventListener(MouseEvent.CLICK ,xis);
function xis(event:MouseEvent):void {
_index++;
}
back_btn.addEventListener(MouseEvent.CLICK ,qis);
function qis(event:MouseEvent):void {
_index--;
}
kj_btn.addEventListener (MouseEvent.CLICK,kj);
function kj(event:MouseEvent):void{
}
_channel.stop();
pos=pos+2000;
_channel=_sound.play(pos);
kt_btn.addEventListener (MouseEvent.CLICK,kt);
function kt(event:MouseEvent):void{
}
_channel.stop();
pos=pos-2000;
_channel=_sound.play(pos); 展开
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.events.Event;
var _sound:Sound =new Sound();
var _channel:SoundChannel =new SoundChannel();
var _playList:Array=new Array();
var _index:int=0;
var pos:Number =0;
var B:Boolean ;
var w:Number =jd_mc.jdt_mc.width;
var len:Number =_sound.length ;
_playList=["1.mp3","2.mp3","3.mp3"];
play_btn.addEventListener(MouseEvent.CLICK,play1);
function play1(event:MouseEvent ):void {
if (_index<_playList.length) {
_sound=new Sound ();
_sound.load (new URLRequest (_playList[_index]));
_channel=_sound.play(pos);
_channel.addEventListener (Event.SOUND_COMPLETE,oncomplete);
_index++;
_sound.addEventListener (Event.ID3,onID3);
function onID3(event:Event):void {
var id3Display:TextField =new TextField ();
addChild(id3Display);
id3Display.x=50;
id3Display.y=200;
id3Display.width=120;
id3Display.height=20;
id3Display.background=true;
id3Display.multiline=true;
id3Display.wordWrap=true;
id3Display.appendText(_sound.id3 .songName +"\n");
songname.text=_sound.id3.songName ;
}
var w:Number =jd_mc.jdt_mc.width;
var len:Number =_sound.length;
addEventListener(Event.ENTER_FRAME,jd);
function jd(event:Event):void {
len=_sound.length ;
pos=_channel.position ;
jd_mc.jdk_mc.x=pos/len*w;
}
function oncomplete(event:Event):void {
pos=0;
jd_mc.jdk_mc.x=0;
}
}
}
pause_btn.addEventListener (MouseEvent.CLICK,zt);
function zt(event:MouseEvent):void{
pos=_channel.position ;
_channel.stop();
_index--;
B=false;
}
stop_btn.addEventListener (MouseEvent.CLICK,tz);
function tz(event:MouseEvent):void{
pos=0;
_channel.stop();
_index--;
B=false;
addEventListener(Event.ENTER_FRAME ,jd);
function jd(event:Event ):void {
pos=0;
jd_mc.jdk_mc.x=0;
}
}
next_btn.addEventListener(MouseEvent.CLICK ,xis);
function xis(event:MouseEvent):void {
_index++;
}
back_btn.addEventListener(MouseEvent.CLICK ,qis);
function qis(event:MouseEvent):void {
_index--;
}
kj_btn.addEventListener (MouseEvent.CLICK,kj);
function kj(event:MouseEvent):void{
}
_channel.stop();
pos=pos+2000;
_channel=_sound.play(pos);
kt_btn.addEventListener (MouseEvent.CLICK,kt);
function kt(event:MouseEvent):void{
}
_channel.stop();
pos=pos-2000;
_channel=_sound.play(pos); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询