topical media & game development
actionscript-video-07-player.ax
actionscript-video-07-player.ax
[swf]
flex
author: Jim Kremens kremens@gmail.com
package
{
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import com.flashconnections.core.Core;
import com.flashconnections.ui.component.mediaPlayer.ifc.IMVCMediaPlayer;
import com.flashconnections.ui.component.mediaPlayer.MediaPlayerView;
import com.flashconnections.ui.component.mediaPlayer.MVCMediaPlayer;
import flash.xml.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
public class @ax-actionscript-video-07-player extends MovieClip
{
private var _@ax-actionscript-video-07-player:IMVCMediaPlayer;
private var urlLoader:URLLoader;
private var xmlTextField:TextField;
private var playlist:Array;
public function @ax-actionscript-video-07-player():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
playlist = new Array();
xmlTextField = new TextField();
urlLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
urlLoader.load(new URLRequest("actionscript-video-07-playlist.xml"));
}
public function initMediaPlayer(event:Event):void
{
var myXML:XML = new XML(urlLoader.data);
_@ax-actionscript-video-07-player = new MVCMediaPlayer();
_@ax-actionscript-video-07-player.init(this);
_@ax-actionscript-video-07-player.initCoordinates(40, 60, 320, 240);
xmlTextField.x = 500;
xmlTextField.y = 80;
xmlTextField.width = 400;
xmlTextField.height = 200;
xmlTextField.background = true;
addChild(xmlTextField);
//xmlTextField.appendText(urlLoader.data + "\n");
readNodes(myXML);
//_@ax-actionscript-video-07-player.populatePlaylist(myXML.item); // AE: does not work, somehow, so need readNodes
//_@ax-actionscript-video-07-player.populatePlaylist(["../assets/video/flash/sl_lg.flv",
//"../assets/video/flash/med_lg.flv", "../assets/video/flash/fast_lg.flv"]);
_@ax-actionscript-video-07-player.populatePlaylist(playlist);
_@ax-actionscript-video-07-player.getView().layout();
//_@ax-actionscript-video-07-player.playMedia(String(_@ax-actionscript-video-07-player.getPlaylist().getItemAt(0).path));
_@ax-actionscript-video-07-player.playMedia(String(_@ax-actionscript-video-07-player.getPlaylist().getItemAt(0)));
}
private function readNodes(node:XML):void {
for each (var element:XML in node.elements()) {
xmlTextField.appendText(element.path + "\n");
playlist.push(String(element.path));
//readNodes(element);
}
}
}
}
(C) Æliens
27/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.