Im bueno en AS2, pero quería hacer mi propio AS3 reproductor de vídeo al hacerlo me daría a entender bien el código. Este es probablemente el tema más fácil Ive publicado aquí principalmente desde Im nuevo en AS3 y sólo jugó con unos tid fragmentos de código.
Así que sé cómo hacerlo en AS2 pero AS3 me esta dando problemas. Tengo un reproductor de vídeo que se carga un archivo swf externo que contiene los botones y controles de las animaciones que hacen. Sin embargo, toda la funcionalidad será tratada por la película de raíz o pare no dependiendo de cómo desea llamarlo.
// Make a url Loader object
var player_loader:URLLoader = new URLLoader();
// Setup and event listener
player_loader.addEventListener(Event.COMPLETE, setup_player);
// Load the XML file
player_loader.load(new URLRequest('config.xml'));
// Setup the player
function setup_player(e:Event):void {
var xml_config:XML = new XML(e.target.data);
var skin_loader:Loader = new Loader();
// var skin_url:URLRequest = new URLRequest(xml_config.skin.text()); // This is how the skin will be loaded however for the sake test testing use the line below
var skin_url:URLRequest = new URLRequest('skin.swf');
skin_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, set_buttons);
skin_loader.load(skin_url);
player_controls.addChild(skin_loader);
}
function set_buttons(e:Event):void {
trace('In Set Buttons');
player_controls.play_button.addEventListener(MouseEvent.CLICK, play_video);
}
function play_video(e:MouseEvent):void {
trace('clicked')
}
-
- // Make a url Loader object
- var player_loader:URLLoader = new URLLoader();
-
- // Setup and event listener
- player_loader.addEventListener(Event.COMPLETE, setup_player);
-
- // Load the XML file
- player_loader.load(new URLRequest('config.xml'));
-
- // Setup the player
- function setup_player(e:Event):void {
-
- var xml_config:XML = new XML(e.target.data);
-
- var skin_loader:Loader = new Loader();
- // var skin_url:URLRequest = new URLRequest(xml_config.skin.text()); // This is how the skin will be loaded however for the sake test testing use the line below
- var skin_url:URLRequest = new URLRequest('skin.swf');
-
- skin_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, set_buttons);
- skin_loader.load(skin_url);
- player_controls.addChild(skin_loader);
-
- }
-
- function set_buttons(e:Event):void {
- trace('In Set Buttons');
- player_controls.play_button.addEventListener(MouseEvent.CLICK, play_video);
-
- }
-
- function play_video(e:MouseEvent):void {
- trace('clicked')
- }
-
-
Por lo que este código se carga cargará un XML cuando completa la piel una vez que la carga podría configurar las funciones de clic. todo esto funciona hasta configurar la función de clic
player_controls.play_button.addEventListener(MouseEvent.CLICK, play_video);
Ahora sé que cuando lo hice con AS2 tuve que usar onLoadInit como este
// Get the skin and make sure something is in it
var skin_swf = 'skin2.swf';
// Make a new movie clip loader for the skin
var SkinLoader:MovieClipLoader = new MovieClipLoader();
// Add a listener so we know when something has happened
SkinLoader.addListener(this);
// Load the skin into the empty movie clip
SkinLoader.loadClip(skin_swf, empty);
// This function is the onload listener for the skin loader. this is a must to have other wise there would be no way to communicate
// from the actions here to the buttons in the skin
function onLoadInit(mc:MovieClip) {
control_bar.play_pause_button.onPress = function () {
// Play the animation
this.animation.gotoAndPlay('press');
}
}
- // Get the skin and make sure something is in it
- var skin_swf = 'skin2.swf';
-
- // Make a new movie clip loader for the skin
- var SkinLoader:MovieClipLoader = new MovieClipLoader();
-
- // Add a listener so we know when something has happened
- SkinLoader.addListener(this);
-
- // Load the skin into the empty movie clip
- SkinLoader.loadClip(skin_swf, empty);
-
- // This function is the onload listener for the skin loader. this is a must to have other wise there would be no way to communicate
- // from the actions here to the buttons in the skin
- function onLoadInit(mc:MovieClip) {
- control_bar.play_pause_button.onPress = function () {
-
- // Play the animation
- this.animation.gotoAndPlay('press');
-
- }
- }
-
Ive buscó el onLoadInit AS3 o algo que gusta y no parecen encontrar nada.
Así que en resumen tengo una swf(swf1) que carga un swf2 swf(swf2) tiene los botones y swf1 contiene el actionscipt para los botones en el swf2. Si alguien sabe cómo hacer esto o me puede dirigir alguna documentación que puede ayudar. Se agradece su ayuda.
Si descubro una solución que será publicarlo.