2013-03-16 50 views
0

无论我尝试过什么,此代码拒绝编译。我经常得到这个编译错误。我试图在我的Flash动画中制作一个音量滑块。据我所知,我正在导入所有正确的东西,而且我的代码与我查看过的众多示例完全相同。为什么这不起作用?Flash/AS3拒绝导入

Layer 'Sounds AS', Frame 1, Line 50 1046: Type was not found or was not a compile-time constant: SliderEvent. 
  

import flash.media.Sound; 
    import fl.controls.Slider; 
    import fl.events.SliderEvent; 

    var curSound = 0; 
    var lastSound = 0; 

    var _A1:Sound = new A1(); 
    var _A2:Sound = new A2(); 
    var _A3:Sound = new A3(); 
    var _A4:Sound = new A4(); 
    var _A5:Sound = new A5(); 
    var _A6:Sound = new A6(); 
    var _A7:Sound = new A7(); 
    var _A8:Sound = new A8(); 
    var _A9:Sound = new A9(); 
    var _A10:Sound = new A10(); 
    var _A11:Sound = new A11(); 
    var _A12:Sound = new A12(); 

    var voiceVolume:SoundTransform = new SoundTransform(); 
    voiceVolume.volume = .4; 

    var voiceChannel:SoundChannel = new SoundChannel(); 

    var volSlider:Slider = new Slider(); 
    volSlider.minimum = 0; 
    volSlider.maximum = 1; 
    volSlider.value = .5; 
    volSlider.snapInterval = .1; 
    volSlider.liveDragging = true; 
    volSlider.addEventListener(SliderEvent.CHANGE, volChange); 
    volSlider.move(10, 10); 
    addChild(slider); 

    function volChange(ev:SliderEvent):void{ 
     voiceVolume.volume = ev.value; 
     voiceChannel.soundTransform = voiceVolume; 
    } 

编辑:事实上,如果我的评论有问题的线路输出,它无法找到任何我试图导入。有没有搞错?

Preloader, Layer 'Sounds AS', Frame 1, Line 2 1172: Definition fl.controls:Slider could not be found. 
Preloader, Layer 'Sounds AS', Frame 1, Line 3 1172: Definition fl.events:SliderEvent could not be found. 
Preloader, Layer 'Sounds AS', Frame 1, Line 2 1172: Definition fl.controls:Slider could not be found. 
Preloader, Layer 'Sounds AS', Frame 1, Line 3 1172: Definition fl.events:SliderEvent could not be found. 
Preloader, Layer 'Sounds AS', Frame 1, Line 26 1046: Type was not found or was not a compile-time constant: Slider. 
Preloader, Layer 'Sounds AS', Frame 1, Line 26 1180: Call to a possibly undefined method Slider. 
Preloader, Layer 'Sounds AS', Frame 1, Line 32 1120: Access of undefined property SliderEvent. 
Preloader, Layer 'Sounds AS', Frame 1, Line 32 1120: Access of undefined property volChange. 
Preloader, Layer 'Sounds AS', Frame 1, Line 34 1120: Access of undefined property slider. 
+0

你用FlashDevelop编译? – Vesper 2013-03-16 05:38:25

+0

不在Flash CS6 Actionscript编辑器中。 – Zeke 2013-03-16 05:55:33

回答

4

当使用Flash组件(fl.*)您需要的组件拖放到Flash Professional中的库面板。这样做会创建与要使用的特定组件的链接。

Components面板中的Slider组件拖动到Library中后,您将能够无误地进行编译。

enter image description here

+0

愚蠢的限制恕我直言,但很高兴知道。谢谢。 – Vesper 2013-03-16 17:10:31