Liebe Flasher,
Ich bastel gerade an einer dynamischen Galerie mit Kategoriesystem. Jetzt möchte ich thumbnails von den Bildern in einen Container stecken. Die Bilder werden alle brav geladen, aber angezeigt wird immer nur das letzte. Ich nehme an, das es daran liegt, dass der "ImgEventHandler" nur das letzte Bild bekommt.
Meine frage lautet also: Wie schaffe ich es, dass der "ImgEventHandler" jedes bekommt?
Die Container Klasse:
Der PicLoader:
Der ImgIsLoaded Dispatcher:
Mit den besten Wünschen
Gone
Ich bastel gerade an einer dynamischen Galerie mit Kategoriesystem. Jetzt möchte ich thumbnails von den Bildern in einen Container stecken. Die Bilder werden alle brav geladen, aber angezeigt wird immer nur das letzte. Ich nehme an, das es daran liegt, dass der "ImgEventHandler" nur das letzte Bild bekommt.
Meine frage lautet also: Wie schaffe ich es, dass der "ImgEventHandler" jedes bekommt?
Die Container Klasse:
Code:
package container{
import flash.display.*;
import flash.events.*;
import loaders.GetCatXML;
import loaders.PicLoader;
import dispatcher.*;
import container.Thumb;
public class CatCont extends MovieClip{
public var thumbCounter:uint = 0;
public var catXMLLoader = new GetCatXML;
public static var thePicWidth:uint;
public static var thePicHeight:uint;
public static var thePicStartX:uint;
public static var thePicStartY:uint;
public static var thePicSpaceX:uint;
public static var thePicSpaceY:uint;
public static var thePicMaxX:uint;
public var countX:uint = 0;
public var countY:uint = 0;
thePicWidth = 110;
thePicHeight = 110;
thePicStartX = 10;
thePicStartY = 10;
thePicSpaceX = 10;
thePicSpaceY = 10;
thePicMaxX = 5;
function CatCont(){
addChild(catXMLLoader);
catXMLLoader.addEventListener(XMLisArray.CONTROL_TYPE,catsEventHandler);
}
function catsEventHandler(key:String){
var i:uint;
for(i = 0; i < this.catXMLLoader.theCatsArray.length; i++){
var thePic:MovieClip;
thePic = new MovieClip;
thePic.scaleX = 0.5;
thePic.scaleY = 0.5;
var img:PicLoader;
img = new PicLoader("../images/" + this.catXMLLoader.theCatsArray[i].src);
img.addEventListener(ImgIsLoaded.CONTROL_TYPE,ImgEventHandler);
var imgArray:Array = new Array();
imgArray.push(img);
}
function ImgEventHandler(){
thePic.addChild(img);
var aThumb:Thumb;
aThumb = new Thumb;
aThumb.x = (thePicStartY + (thumbCounter*aThumb.width) + (thumbCounter*thePicSpaceX));
aThumb.addChildAt(thePic,0);
if(thePic.width < 220){
thePic.x = (aThumb.width - thePic.width)/2;
}
if(thePic.height < 220){
thePic.y = (aThumb.height - thePic.height)/2;
}
addChild(aThumb);
thumbCounter++;
}
}
}
}
Der PicLoader:
Code:
package loaders{
import flash.display.*;
import flash.net.URLRequest;
import flash.events.*;
import dispatcher.ImgIsLoaded;
public class PicLoader extends MovieClip{
function PicLoader(theSrc:String){
var thePicLoader:Loader;
thePicLoader = new Loader;
applyListeners(thePicLoader.contentLoaderInfo);
var theUrlRequest:URLRequest;
theUrlRequest = new URLRequest(theSrc);
thePicLoader.load(theUrlRequest);
addChild(thePicLoader);
}
private function applyListeners(dispatcher:IEventDispatcher):void{
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
private function completeHandler(event:Event):void {
dispatchEvent(new ImgIsLoaded('ImgIsLoaded'));
}
}
}
Der ImgIsLoaded Dispatcher:
Code:
package dispatcher{
import flash.events.Event;
public class ImgIsLoaded extends flash.events.Event{
public static const CONTROL_TYPE:String = "ImgIsLoaded";
private var command:String;
public function ImgIsLoaded(command:String){
super(CONTROL_TYPE);
this.command = command;
}
}
}
Mit den besten Wünschen
Gone