【问题标题】:AS3: How do I call a function with two arguments - (vBox, and vFile)AS3:如何调用带有两个参数的函数 - (vBox 和 vFile)
【发布时间】:2015-03-29 20:22:36
【问题描述】:

Adobe Flash CC

这里有点困惑。我正在优化我的代码,而不是调用 launchVideo();对于每个视频,我可以简单地调用一次,同时将新的源字符串传递给函数。

如何从另一个函数中调用 launchVideo 函数?

当我添加一个事件监听器,它调用 playMPMovie

buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, playMPMovie, false, 0, true);
function playMPMovieOne(): void {
    video_file = "/videos/MP_01.mp4";
    launchVideo();
}

我明白了……

Scene 1, Layer 'actions', Frame 1, Line 21, Column 2    1136: Incorrect number of arguments.  Expected 2.

当我尝试将 (vBox, vFile) 添加到 launchVideo();我明白了……

Scene 1, Layer 'actions', Frame 1, Line 20, Column 20   1120: Access of undefined property vFile.
Scene 1, Layer 'actions', Frame 1, Line 20, Column 14   1120: Access of undefined property vBox.

这是完整的代码。

stop();

import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Graphics;
import fl.video.*;


vinetteMC.visible = false;

// VARIABLES //
var video_holder: MovieClip = new MovieClip();
var video_file: String;

// EVENT LISTENERS //
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, playMPMovie, false, 0, true);
function playMPMovieOne(): void {
    video_file = "/videos/MP_01.mp4";
    launchVideo();
}

// Place Playback
function launchVideo(vBox, vFile): void {

    var flvPlayer: FLVPlayback = new FLVPlayback();
    import fl.video.*;
    import flash.events.*;

    flvPlayer.source = vFile;
    flvPlayer.skinAutoHide = true;
    flvPlayer.skinBackgroundColor = 0x000000;

    flvPlayer.width = 1920;
    flvPlayer.height = 1080;

    flvPlayer.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
    function completeHandler(event: Event): void {

        removeChild(video_holder);
        removeChild(flvPlayer);
        flvPlayer.addEventListener(fl.video.VideoEvent.COMPLETE, completeHandler, false, 0, true);
        trace("Complete handler called");
    }

    vBox.addChild(flvPlayer);
}

launchVideo(video_holder, video_file);

【问题讨论】:

    标签: function actionscript-3 flash desktop flvplayback


    【解决方案1】:

    您似乎想打电话

    function playMPMovieOne(): void {
        video_file = "/videos/MP_01.mp4";
        launchVideo(video_holder, video_file)
    }
    

    同样从您的示例代码中创建了视频支架,但从未添加到显示列表中。您可能需要添加它才能看到任何内容。

    addChild(video_holder);
    

    【讨论】:

    • 谢谢安德鲁。我会让你知道它是否有效。感谢您的帮助!
    • 最终得到了来自@Vesper 的建议(和代码) - 巨大的帮助。我一直在为这个项目苦苦挣扎一分钟。完整代码在这里pastebin.com/BTNmh0jC
    猜你喜欢
    • 1970-01-01
    • 2013-09-24
    • 2012-01-21
    • 2015-03-16
    • 1970-01-01
    • 2022-01-11
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多