我想用casalib加载和播放电影
我在reference中尝试了这个例子
但是当我试图将它添加到舞台时,它就会出现。
我使用flash cs4 professional。
播放器:Flash 10
我想要完成的任务:
自动加载给定元素的预加载器(img,json,movie)
然后在舞台上显示它。
我现在的问题:
当我尝试将它添加到舞台时,没有任何内容出现
我想也许是因为它不开始玩。
但在参考文献中我没有找到一种播放或停止的方法。
我的视频课程
package com.app
{
import org.casalib.display.CasaMovieClip;
import org.casalib.events.VideoLoadEvent;
import org.casalib.load.VideoLoad;
public class video extends CasaMovieClip
{
public var _videoLoad:VideoLoad;
protected var _file:String;
protected var _preloader:preload;
protected var _id:int;
public function video(file:String) {
super();
this._file = file;
this._videoLoad = new VideoLoad(this._file);
this._videoLoad.pauseStart = true;
this._videoLoad.addEventListener(VideoLoadEvent.PROGRESS, this._onProgress);
this._videoLoad.addEventListener(VideoLoadEvent.BUFFERED, this._onBuffered);
this.addChild(this._videoLoad.video);
}
public function load(preloader:preload)
{
this._preloader = preloader;
this._videoLoad.start();
}
public function play_movie()
{
this._videoLoad.pauseStart = false;
}
protected function _onProgress(e:VideoLoadEvent):void {
this._preloader.add_progress(this._id,e.progress.percentage);
}
protected function _onBuffered(e:VideoLoadEvent):void {
e.target.netStream.resume();
}
public function set_id(number:int)
{
this._id = number;
}
}
}
预加载类:
package com.app
{
import com.greensock.*;
import com.greensock.plugins.*;
import com.adobe.serialization.json.*;
public class preload
{
private var preloader:appPreloader;
public var objects:Array = [];
private var max_progress:int = 0;
private var current_progresses:Array = [];
private var complete_callback:Function;
private var load_error:Boolean = false;
public function preload(preloader:appPreloader, elements:Array)
{
this.preloader = preloader;
this.max_progress = elements.length * 100;
for(var i:int = 0; i < elements.length; i++)
{
elements[i].set_id(i);
elements[i].load(this);
this.objects.push(elements[i]);
}
}
public function add_progress(id:int,value:int)
{
this.current_progresses[id] = value;
this.update();
}
public function add_object(name:String ,object:*)
{
this.objects[name] = object;
}
public function update()
{
var join_progress:int = 0;
for(var i:int = 0; i < this.current_progresses.length; i++)
{
join_progress += this.current_progresses[i];
}
join_progress = (join_progress / this.current_progresses.length);
TweenLite.to(this.preloader.bar, 1, {scaleX:(this.preloader.logo.width * (join_progress/100))});
if(join_progress == 100)
{
this.complete_callback(this.objects);
}
}
public function complete(callback:Function)
{
if(this.load_error) return false;
this.complete_callback = callback;
}
public function display_error(message:String)
{
this.load_error = true;
TweenPlugin.activate([TintPlugin]);
TweenLite.to(this.preloader.error_msg, 0, {alpha: 0});
this.preloader.error_msg.text = message;
this.preloader.error_msg.appendText('\n--- Ende des Berichts ---');
TweenLite.to(this.preloader.error_msg, 1, {alpha: 1, tint:0xcc0000});
}
private function count_object(object:Object)
{
var count:int;
var key:String;
for (key in object)
{
count++;
}
return count;
}
}
}
在我的文章中
var preloader_view = new appPreloader();
stage.addChild(preloader_view);
var num = 13;
var preloader = new preload(preloader_view,[
new video('http://localhost/test/videos/akte.avi?'+num)
]).complete(function(elements) {
TweenLite.to(preloader_view, 2, {alpha:0, onComplete: preloader_end});
function preloader_end()
{
self.addChild(elements[1]);
elements[0].play_movie();
}
});
提前致谢。