class
PHP-Code:
class djpublic.image.ImageStream {
/**
* class ImageStream by public (Sebastian Vogt)
*
* Properties
* images:Array [read]
* containers:Array [read]
* count:Number [read]
* bytesLoaded:Number [read]
* totalBytes:Number [read]
* percentLoaded:Number [read]
*
* Constructor
* new ImageStream(timeline:MovieClip)
*
* Methodes
* stream (args[images]):ImageStream
* destroy ():ImageStream
* addListener(listener:Object):Void
* removeListener(listener:Object):Void
*
* Eventlistener
* onStreamStart = function(){}
* onStreamFinish = function(){}
* onLoadStart = function(act_mc:MovieClip){}
* onLoadProgress = function(act_mc:MovieClip, bytesLoaded:Number, totalBytes:Number, percentLoaded:Number){}
* onLoadComplete = function(act_mc:MovieClip){}
* onLoadInit = function(act_mc:MovieClip){}
* onLoadError = function(){}
*/
private var _images:Array = [];
private var _containers:Array = [];
private var _timeline:MovieClip;
private var _mcl:MovieClipLoader;
private var _count:Number = 0;
//
private var _bytesLoaded:Number;
private var _totalBytes:Number;
private var _percentLoaded:Number;
// Broadcaster
public var addListener:Function;
public var removeListener:Function;
private var broadcastMessage:Function;
/**
* Properties
*/
// images
public function get images ():Array {
return this._images;
}
// containers
public function get containers ():Array {
return this._containers;
}
// count
public function get count ():Number {
return this._count;
}
// bytesLoaded
public function get bytesLoaded ():Number {
this._bytesLoaded = this.containers[this._count].getBytesLoaded ();
return this._bytesLoaded;
}
// totalBytes
public function get totalBytes ():Number {
this._totalBytes = this._containers[this._count].getBytesTotal ();
return this._totalBytes;
}
// percentLoaded
public function get percentLoaded ():Number {
this._percentLoaded = this.bytesLoaded / this.totalBytes * 100;
return this._percentLoaded;
}
/**
* Konstruktor
*/
function ImageStream (timeline:MovieClip) {
AsBroadcaster.initialize (this);
if (timeline == undefined) {
timeline = _root;
}
this._timeline = timeline;
}
/**
* stream ():ImageStream
*/
public function stream ():ImageStream {
if (arguments.length != 0) {
this._images = arguments;
this.broadcastMessage ("onStreamStart");
}
if (this._count < this._images.length) {
trace (this._count);
var mc:MovieClip = this.createContainer (this._timeline, "__ImageStream_" + this._count, this._timeline.getNextHighestDepth ());
this._mcl = new MovieClipLoader ();
var o:Object = {};
//
o.onLoadStart = this.proxy (this, function ():Void {
this.broadcastMessage ("onLoadStart", mc);
});
//
o.onLoadProgress = this.proxy (this, function ():Void {
this.broadcastMessage ("onLoadProgress", mc, this.bytesLoaded, this.totalBytes, this.percentLoaded);
});
//
o.onLoadComplete = this.proxy (this, function ():Void {
this.broadcastMessage ("onLoadComplete", mc);
});
//
o.onLoadInit = this.proxy (this, function ():Void {
this.broadcastMessage ("onLoadInit", mc);
this._count++;
this.stream ();
});
//
o.onLoadError = this.proxy (this, function ():Void {
this.broadcastMessage ("onLoadError");
});
this._mcl.addListener (o);
this._mcl.loadClip (this._images[this._count], mc);
} else {
this.broadcastMessage ("onStreamFinish");
this._count = 0;
}
return this;
}
/**
* destroy ():ImageStream
*/
public function destroy ():ImageStream {
for (var i:Number = 0; i < this._containers.length; i++) {
this._containers[i].removeMovieClip ();
}
this._containers.length = 0;
this._count = 0;
return this;
}
/**
* toString ():String
*/
public function toString ():String {
return "[object ImageStream]";
}
/**
* createContainer (timeline:MovieClip, name:String, depth:Number):MovieClip
*/
private function createContainer (timeline:MovieClip, name:String, depth:Number):MovieClip {
var mc:MovieClip = timeline.createEmptyMovieClip (name, depth);
this._containers.push (mc);
return mc;
}
/**
* proxy (obj:Object, func:Function):Function
*/
private function proxy (obj:Object, func:Function):Function {
var args:Array = arguments.slice (2);
return function () {
func.apply (obj, args);
};
}
}
fla
PHP-Code:
import djpublic.image.ImageStream;
var is:ImageStream = new ImageStream ();
var o:Object = {};
o.onLoadProgress = function (mc:MovieClip, bl:Number, tb:Number, pl:Number):Void {
trace (pl);
};
o.onLoadStart = function (mc:MovieClip):Void {
trace ("onLoadStart");
trace (mc);
};
o.onLoadComplete = function (mc:MovieClip):Void {
trace ("onLoadComplete");
trace (mc);
};
o.onLoadInit = function (mc:MovieClip):Void {
trace ("onLoadInit");
mc._alpha = 50;
};
o.onStreamFinish = function ():Void {
trace ("onStreamFinish");
};
o.onStreamStart = function ():Void {
trace ("onStreamStart");
};
is.addListener (o);
is.stream ("01.jpg", "02.jpg", "03.jpg", "04.jpg");//<----- Images hier eintragen
onMouseDown = function ():Void {
trace (is.containers);
is.containers[3]._alpha = 100;
};