I’m trying to target something and just can’t get it to work. Here’s the code:
function xmlLoaded(e:Event):void {
var loadedxml:XML = new XML(e.target.data);
for (var i:uint=0; i<loadedxml.piece.length(); i++) {
var pieceholder:MovieClip = new MovieClip();
portfolio.addChild(pieceholder);//portfolio is a mc on the stage
pieceholder.buttonMode = true;
var pieceloader = new Loader();
var pictURLReq:URLRequest = new URLRequest(loadedxml.piece.image.text()*);
pieceholder.addChild(pieceloader);
pieceloader.alpha = .0;//until loaded
pieceloader.load(pictURLReq);
pieceloader.contentLoaderInfo.addEventListener(Event.COMPLETE, pieceloaderComplete);
pieceholder.addEventListener(MouseEvent.MOUSE_OVER, linkyover);
pieceholder.addEventListener(MouseEvent.MOUSE_OUT, linkyout);
}
}
function pieceloaderComplete(e:Event):void {
TweenLite.to(e.currentTarget.loader, 0.5, {alpha:0.2});// this works but then can't change the alpha with linkyover
TweenLite.to(MovieClip(e.currentTarget.loader).pieceholder, 1, {alpha:0.2});// this does not work
}
function linkyover(e:MouseEvent):void {
TweenLite.to(MovieClip(e.currentTarget), 0.5, {alpha:1}); // if I set the alpha to 0 it will do that, but obviously that's not what I need
}
summary: pieceholder is holding pieceloader. when pieceloader (loader class) finishes loading, its alpha is set to 0.2. linkyover is triggered by a mouseover over pieceholder and I need the alpha to go to 1.
there’s obviously something wrong, and I suspect it has to do with me trying to do things with the loader class. if I do things in reverse it DOES work (set the alpha to 1 when loaded, rolling over sets to 0). so I think linkyover is properly targeted, but pieceloaderComplete is not.
help!