闪烁麦克风事件大小调整

Flash Microphone Event Resize

本文关键字:调整 事件 麦克风 闪烁      更新时间:2023-09-26

我最近一直在学习Flash AC3,我的目的是为我的网站制作一个小型录音机。我一直在使用谷歌和搜索引擎,并在这里和那里得到不同的答案,但它仍然不能正常工作。

我遇到的问题是,Flash 插件是 215x50 像素。我知道除非它是215x138像素,否则Flash Player安全面板将自动无法打开。

我设计了一个解决方法,即如果调用安全性打开,我会使用名为 ResizeFlash 的 JavaScript 函数将 Flash 对象所在的 DIV 调整为 215x138 的大小,然后在用户选择是否允许麦克风后再次恢复到 215x50。

现在我已经挠头几天了,因为我确实让以下代码工作,并且它确实调整了 DIV 的大小,但它不会调整 DIV 的大小。我想我可能在错误的地方调用了 ResizeFlash(???)。我不够熟悉,不知道哪里可能出错。

我一直在重新排列代码以查看它是否有效,并且我会得到它确实调整为 215x138 的时间,打开安全面板,然后调整回 215x50,但随后录制不会开始,就好像我被困在循环中的某个地方。

我希望有人可以花一些时间看一眼这段代码,并向我展示处理此问题的正确方法。谢谢!

这是代码:

public function Main():void
{
    recButton.stop();
    submitButton.enabled = false;  // These reset everything, maybe in wrong place?? 
    activity.stop(); 
    addListeners();
        mic = Microphone.getMicrophone();
        if (mic == null)
        {
            // no camera is installed
        }
        else if (mic.muted)
        {
            // user has disabled the access in security settings
            mic.addEventListener(StatusEvent.STATUS, onMicStatus, false, 0, true); // listen out for their new decision
            Security.showSettings('2'); // show security settings window to allow them to change security settings
        }
        else
        {
            // you have access
            mic.setUseEchoSuppression(true); //... also this might be in wrong place?
            // .. I would like this to always be on
        }
    }
    private function addListeners():void
    {
        recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);
        submitButton.addEventListener(MouseEvent.MOUSE_UP, onSend);
        recorder.addEventListener(RecordingEvent.RECORDING, recording);
        recorder.addEventListener(Event.COMPLETE, recordComplete);
        activity.addEventListener(Event.ENTER_FRAME, updateMeter);
    }
    function onMicStatus(event:StatusEvent):void 
    {   
        if (event.code == "Microphone.Unmuted") 
        { 
            mic.removeEventListener(StatusEvent.STATUS, onMicStatus);
            ExternalInterface.call('ResizeFlash', '215', '50'); // When the user presses allow, resize the div back to 215x50
        }
    }
    private function startRecording(e:MouseEvent):void
    {
        recorder.record();
        e.target.gotoAndStop(2);
        recButton.removeEventListener(MouseEvent.MOUSE_UP, startRecording);
        recButton.addEventListener(MouseEvent.MOUSE_UP, stopRecording);
    }
    private function stopRecording(e:MouseEvent):void
    {
        recorder.stop();
        e.target.gotoAndStop(1);
        recButton.removeEventListener(MouseEvent.MOUSE_UP, stopRecording);
        recButton.addEventListener(MouseEvent.MOUSE_UP, startRecording);
    }

我知道我里面的东西顺序错误..!我感谢任何评论。

正如你所建议的那样,在麦克风的状态事件处理程序中将应用大小调整回 215x50 可能为时过早。

只是一种预感,但是当用户单击Flash安全面板中的"允许"单选按钮时,会立即调度该状态事件。面板仍处于打开状态。事实上,如果您将其保持打开状态并在允许/拒绝之间单击,则每次都会被调度......

当安全面板启动时,有些事情您无法执行。我想知道使用ExternalInterface(调整应用程序大小)是否落入了这个桶。

我建议如下:

  1. 在没有安全面板的情况下测试调整大小功能。确保此代码在两个方向上成功调整应用的大小。
  2. 然后看看这个问题,了解如何检测用户何时实际关闭安全面板。那里有两种方法,一种非常黑客(BitmapData.draw()黑客),但我知道它有效。我建议尝试第二个,如果它确实有效,请在那里评论/赞成(我也会)。这是一种更优雅的检测用户何时关闭对话框的方法,但我还没有机会尝试它。
  3. 检测到对话框已关闭时,请调整应用大小。