我是flash的新手,我创建了音量滑块,我明确为所有音量功能创建了实例,但它给出了以下错误
TypeError: Error #1010: A term is undefined and has no properties.
以下代码中的确切错误位置是
bgslider.mc.addEventListener(MouseEvent.MOUSE_DOWN,StartDrag);
我的播放器代码是
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.events.Event;
import flash.geom.Rectangle;
btnstop.addEventListener(MouseEvent.MOUSE_OUT,StopOut);
btnstopo.addEventListener(MouseEvent.MOUSE_OVER,StopOver);
function StopOver(evt:MouseEvent):void
{
btnstopo.visible=false;
btnstop.visible=true;
}
function StopOut(evt:MouseEvent):void
{
btnstop.visible=false;
btnstopo.visible=true;
}
btnplay.addEventListener(MouseEvent.MOUSE_OUT,PlayOut);
btnplayo.addEventListener(MouseEvent.MOUSE_OVER,PlayOver);
function PlayOver(evt:MouseEvent):void
{
btnplayo.visible=false;
btnplay.visible=true;
}
function PlayOut(evt:MouseEvent):void
{
btnplay.visible=false;
btnplayo.visible=true;
}
var soundfile:URLRequest = new URLRequest('http://live32.radio.com:80/;stream1.mp3');
var channel:SoundChannel = new SoundChannel();
var sTransform:SoundTransform = new SoundTransform();
var isplay=1;
var myMusic:Sound = new Sound();
myMusic.load(soundfile);
channel=myMusic.play();
btnplay.addEventListener(MouseEvent.CLICK,PlayRadio);
btnstop.addEventListener(MouseEvent.CLICK,StopRadio);
function PlayRadio(evt:Event):void
{
if(isplay==0)
{
isplay=1;
btnplay.removeEventListener(MouseEvent.MOUSE_OUT,PlayOut);
btnplayo.removeEventListener(MouseEvent.MOUSE_OVER,PlayOver);
btnstop.addEventListener(MouseEvent.MOUSE_OUT,StopOut);
btnstopo.addEventListener(MouseEvent.MOUSE_OVER,StopOver);
SoundMixer.soundTransform = new SoundTransform(1);
btnstop.visible=true;
btnplay.visible=false;
}
}
function StopRadio(evt:Event):void
{
if(isplay==1)
{
btnstop.removeEventListener(MouseEvent.MOUSE_OUT,StopOut);
btnstopo.removeEventListener(MouseEvent.MOUSE_OVER,StopOver);
btnplay.addEventListener(MouseEvent.MOUSE_OUT,PlayOut);
btnplayo.addEventListener(MouseEvent.MOUSE_OVER,PlayOver);
SoundMixer.soundTransform = new SoundTransform(0);
isplay=0;
btnstop.visible=false;
btnplay.visible=true;
}
}
/*var bgslider = new MovieClip();
trace(bgslider.name);
for(var i:uint=0;i<bgslider.numChildren;i++){
trace(bgslider.getChildAt(i).name);
}*/
bgslider.mc.addEventListener(MouseEvent.MOUSE_DOWN,StartDrag);
bgslider.mc.addEventListener(MouseEvent.MOUSE_UP,StopDrag);
function StartDrag(event:MouseEvent):void
{
bgslider.mc.startDrag(true,new Rectangle(152,37,182,0));
}
function StopDrag(event:MouseEvent):void
{
bgslider.mc.stopDrag();
}
请先给出正确答案,谢谢提前
答案 0 :(得分:1)
TypeError通常表示您拼错了一个对象引用,或者根本没有给它一个。
在属性检查器中仔细检查bgslider和mc引用。确保它不被称为bg_slider,bgSlider或类似的东西。