AS3:如何调用带有两个参数的函数 -(vBox 和 vFile)
AS3: How do I call a function with two arguments - (vBox, and vFile)
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 playMPMovieOne(): void {
video_file = "/videos/MP_01.mp4";
launchVideo(video_holder, video_file)
}
同样根据您的示例代码,视频持有者已创建但从未添加到显示列表中。您可能需要添加此内容才能看到任何内容。
addChild(video_holder);
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 playMPMovieOne(): void {
video_file = "/videos/MP_01.mp4";
launchVideo(video_holder, video_file)
}
同样根据您的示例代码,视频持有者已创建但从未添加到显示列表中。您可能需要添加此内容才能看到任何内容。
addChild(video_holder);