0

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

    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.
4

1 回答 1

4

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

Slider从面板中拖动一个组件Components并将其放入其中后,Library您将能够编译而不会出错。

在此处输入图像描述

于 2013-03-16T06:16:20.910 回答