未定义变量cmodule.shine :: CLibInit。 AS3

时间:2013-05-17 07:50:30

标签: actionscript-3 flash actionscript

我在Flash上​​使用AS3 ...我正在尝试修改.fla文件,这是音频录制并使用ShineMP3Encoder添加mp3转换,但是当我运行程序时,记录和转换我总是以此错误结束< / p>

<!-- Flash output - read from bottom to top
ReferenceError: Error #1065: Variable cmodule.shine::CLibInit is not defined. // this is the error
at fr.kikko.lab::ShineMP3Encoder/start()
at Main/encodeToMP3()
at Main/recordComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.bytearray.micrecorder::MicRecorder/stop()
at Main/stopRecording()
-->

这是我的代码:

package 
{
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.net.*; 
    import flash.media.*;
    import flash.utils.*;

    import flash.display.Sprite;
    import flash.media.Microphone;
    import flash.system.Security;
    import org.bytearray.micrecorder.*;
    import org.bytearray.micrecorder.events.RecordingEvent;
    import org.bytearray.micrecorder.encoder.WaveEncoder;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.ActivityEvent;
    import fl.transitions.Tween;
    import fl.transitions.easing.Strong;
    import flash.net.FileReference;
    import flash.utils.ByteArray;

    import fr.kikko.lab.ShineMP3Encoder;

    public class Main extends Sprite
    {
        private var mic:Microphone;
        private var waveEncoder:WaveEncoder = new WaveEncoder();
        private var recorder:MicRecorder = new MicRecorder(new WaveEncoder());
        private var recBar:RecBar = new RecBar();
        private var tween:Tween;
        private var fileReference:FileReference = new FileReference();

        private var mp3Encoder:ShineMP3Encoder;

        public function Main():void
        {
            recButton.stop();
            activity.stop();

            mic = Microphone.getMicrophone();
            mic.setSilenceLevel(0);
            mic.gain = 100;
            mic.setLoopBack(true);
            mic.setUseEchoSuppression(true);
            Security.showSettings("2");

            addListeners();
        }

        private function addListeners():void
        {
            recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);
            recorder.addEventListener(RecordingEvent.RECORDING, recording);
            recorder.addEventListener(Event.COMPLETE, recordComplete);
            activity.addEventListener(Event.ENTER_FRAME, updateMeter);
        }

        private function startRecording(e:MouseEvent):void
        {
            if (mic != null)
            {
                recorder.record();
                e.target.gotoAndStop(2);

                recButton.removeEventListener(MouseEvent.MOUSE_UP, startRecording);
                recButton.addEventListener(MouseEvent.MOUSE_UP, stopRecording);

                addChild(recBar);

                tween = new Tween(recBar,"y",Strong.easeOut, -  recBar.height,0,1,true);
            }
        }

        private function stopRecording(e:MouseEvent):void
        {
            recorder.stop();

            mic.setLoopBack(false);
            e.target.gotoAndStop(1);

            recButton.removeEventListener(MouseEvent.MOUSE_UP, stopRecording);
            recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);

            tween = new Tween(recBar,"y",Strong.easeOut,0, - recBar.height,1,true);
        }

        private function updateMeter(e:Event):void
        {
            activity.gotoAndPlay(100 - mic.activityLevel);
        }

        private function recording(e:RecordingEvent):void
        {
            var currentTime:int = Math.floor(e.time / 1000);

            recBar.counter.text = String(currentTime);

            if (String(currentTime).length == 1)
            {
                recBar.counter.text = "00:0" + currentTime;
            }
            else if (String(currentTime).length == 2)
            {
                recBar.counter.text = "00:" + currentTime;
            }
        }

        private function recordComplete(e:Event):void
        {
            //trace(recorder.output.bytesAvailable)
            encodeToMP3(recorder.output)
            //fileReference.save(recorder.output, "recording.wav");
        }

            //this is the function I added
        private function encodeToMP3(wavData:ByteArray):void {
            mp3Encoder = new ShineMP3Encoder(wavData);
            mp3Encoder.addEventListener(Event.COMPLETE, mp3EncodeComplete);


            mp3Encoder.start();
        }


        private function mp3EncodeComplete(event : Event) : void {

                trace("Done !", mp3Encoder.mp3Data.length);
        }

    }
}

谢谢.... :)

1 个答案:

答案 0 :(得分:0)

将* shineMP3_alchemy.swc *的链接类型从“外部”添加到“ 合并到代码 ”,您可以在其中设置库路径for ActionScript 3.0文件