网页游戏火影忍者OL里出现ArgumentError: Error #2068香辣虾团购怎么解决?

as3 声音暂停与播放中出现:ArgumentError: Error #2068: 声音无效。_百度知道
as3 声音暂停与播放中出现:ArgumentError: Error #2068: 声音无效。
var sound:Svar sound_channel:SoundChannel=new SoundChannel();var position:.............//鼠标单击事件function onClick(e:MouseEvent):void { var sb:SimpleButton = (e.target as SimpleButton); if (sb==btnPlay) {//播放音乐
playSound(position); } else if (sb == btnPause) {//暂停音乐
Pause(); } else if (sb == btnStop) {//关闭音乐
Stop(); } }function Pause():void {//暂停音乐 if (sound_channel) {
position=sound_channel.//记录暂停的位置
sound_channel.stop();//停止音乐
btnPlay.visible=
btnPause.visible= }}function playSound(position) { sound=new Sound(); sound_channel=sound.play(position); isPlay= btnPlay.visible= btnPause.visible=}点击暂停按钮(btnPause)后声音能暂停,但再点播放按钮(btnPlay)后就会出现如下的错误:ArgumentError: Error #2068: 声音无效。 at flash.media::Sound/play() at ebook111_fla::MainTimeline/playSound() at ebook111_fla::MainTimeline/onClick()便若把function playSound(position) 中的 “sound=new Sound();“去掉后,点击暂停按钮但再点播放按钮(btnPlay)后会出现如下错误:TypeError: Error #1009: 无法访问空对象引用的属性或方法。 at ebook111_fla::MainTimeline/playSound() at ebook111_fla::MainTimeline/onClick()不知问题出在什么地方?急需高手解答!谢谢!
提问者采纳
不用new 多一次,sound = new Sound了之后sound就重新初始了,所以你的参数传进去之后就会报错,你应该在上面new就好了,不要在这个函数里面new。
提问者评价
谢谢提醒!问题解决了!
其他类似问题
按默认排序
其他1条回答
你定义的组件是否 拖到舞台 或者你定义按钮类时没import?你有没有写 按钮。addEventListen(MouseEvent.CLICK,
写了按钮侦听: addEventListener(MouseEvent.CLICK,onClick);而且所有的组件也全拖到了舞台上
SoundChannel
你导入没有呢?
我就在写在帧上了不用导入的类的,测试时没有提示编译器错误,说明语法是没有问题的,运行过程中点击暂停按钮(btnPause)后声音能暂停,但再点播放按钮(btnPlay)后就会出现错误
as3的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁

我要回帖

更多关于 2068香辣虾团购 的文章

 

随机推荐