Jump to content

xml slideshow: alpha tweening array element's (sprites).


Greywacke

Recommended Posts

hi there, the lines in question are marked in bold (these lines are commented at the moment otherwise it does some unexpected tweening and only on the first sprite!). i need to let the images fade in over the last one:

import flash.events.Event;import flash.net.URLLoader;import flash.net.URLRequest;import flash.display.Loader;import flash.utils.Timer;import flash.events.TimerEvent;import flash.display.Sprite;import flash.display.Bitmap;import flash.display.BitmapData;import fl.transitions.Tween;var imagesXML:XML;var xmlLoader:URLLoader = new URLLoader();var imageLoader:Array = new Array();var imageHolder:Array = new Array();[b]var alphaTween:Array = new Array();[/b]var imageTimer:Timer;var path:Array = new Array();var delay:uint;var tween:Number;var n:uint=0;var d:uint=0;var o:uint=0;xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);xmlLoader.load(new URLRequest("http://www.ptbh.co.za/swf/img.xml"));function xmlLoaded(e:Event):void {	imagesXML = new XML(xmlLoader.data);	imageLoader[d] = new Loader();	imageLoader[d].contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);	trace((n+1) + " images detected");	for (var i:uint = 0; i < imagesXML.pic.length(); i++) {		path[i] = imagesXML.pic[i].@path;		trace(path[i] + " noted");	}	imageLoader[d].load(new URLRequest(path[d]));	delay = uint(imagesXML.delay[0].@display);	tween = uint(imagesXML.delay[0].@tween)/1000;}function showImage(e:Event):void {	//this.contentLoaderInfo.removeEventListener(Event.COMPLETE, showImage);	var tempBitmap:Bitmap = e.target.content;	var tempBitmapData:BitmapData = tempBitmap.bitmapData;	imageHolder[d] = new Sprite();	var loadBitmap:Bitmap = new Bitmap(tempBitmapData);	imageHolder[d].addChild(loadBitmap);	addChild(imageHolder[d]);	imageHolder[d].x = 13;	imageHolder[d].y = 0;	setChildIndex(imageHolder[d],2);	imageHolder[d].visible = false;	trace(path[d] + " downloaded");	d++;	if (d < path.length) {		imageLoader[d] = new Loader();		imageLoader[d].contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);		imageLoader[d].load(new URLRequest(path[d]));	} else {		loader_mc.visible = false;		imageTimer = new Timer(delay);		trace(delay + " millisecond timer created");		imageTimer.addEventListener(TimerEvent.TIMER, nextImage);		nextImage();	}}function nextImage(e:TimerEvent = null):void {	imageTimer.stop();	for (var i:uint = 0; i < imageHolder.length; i++) {		if (i == n) {			imageHolder[n].visible = true;			[b]imageHolder[n].alpha = 0;			alphaTween[n] = new Tween(imageHolder[n],"alpha",null,0,1,tween,true);[/b]		} else if (i != o) {			imageHolder[i].visible = false;		}	}	o = n;	if (n < imageHolder.length) {		n++;	} else {		n = 0;	}	imageTimer.start();}

and here is a look at the xml document which sets the display time for the sprites, and the tween time to fade in, as well as the images:

<pics>	<delay display="4000" tween="1000"/>	<pic path="http://www.ptbh.co.za/swf/000.jpg"/>	<pic path="http://www.ptbh.co.za/swf/001.jpg"/>	<pic path="http://www.ptbh.co.za/swf/002.jpg"/>	<pic path="http://www.ptbh.co.za/swf/003.jpg"/>	<pic path="http://www.ptbh.co.za/swf/004.jpg"/>	<pic path="http://www.ptbh.co.za/swf/005.jpg"/>	<pic path="http://www.ptbh.co.za/swf/006.jpg"/>	<pic path="http://www.ptbh.co.za/swf/007.jpg"/>	<pic path="http://www.ptbh.co.za/swf/008.jpg"/>	<pic path="http://www.ptbh.co.za/swf/009.jpg"/>	<pic path="http://www.ptbh.co.za/swf/010.jpg"/>	<pic path="http://www.ptbh.co.za/swf/011.jpg"/>	<pic path="http://www.ptbh.co.za/swf/012.jpg"/>	<pic path="http://www.ptbh.co.za/swf/013.jpg"/>	<pic path="http://www.ptbh.co.za/swf/014.jpg"/>	<pic path="http://www.ptbh.co.za/swf/015.jpg"/></pics>

Link to comment
Share on other sites

haha! success at last! this issue is now RESOLVED!!! :)3 layers, top layer only got loading movieclip labelled loader_mc and the actionscript below.first and second layers only have diff colored rectangles over each other as borders.

import flash.events.Event;import flash.net.URLLoader;import flash.net.URLRequest;import flash.display.Loader;import flash.utils.Timer;import flash.events.TimerEvent;import flash.display.Sprite;import flash.display.Bitmap;import flash.display.BitmapData;import fl.transitions.Tween;var imagesXML:XML;var xmlLoader:URLLoader = new URLLoader();var imageLoader:Array = new Array();var imageHolder:Array = new Array();var alphaTween:Array = new Array();var imageTimer:Timer;var path:Array = new Array();var delay:uint;var tween:Number;var n:uint=0;var d:uint=0;var o:uint=0;xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);xmlLoader.load(new URLRequest("http://www.ptbh.co.za/swf/img.xml"));function xmlLoaded(e:Event):void {	imagesXML = new XML(xmlLoader.data);	imageLoader[d] = new Loader();	imageLoader[d].contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);	trace((n+1) + " images detected");	for (var i:uint = 0; i < imagesXML.pic.length(); i++) {		path[i] = imagesXML.pic[i].@path;		trace(path[i] + " noted");	}	imageLoader[d].load(new URLRequest(path[d]));	delay = uint(imagesXML.delay[0].@display);	tween = Number(imagesXML.delay[0].@tween);}function showImage(e:Event):void {	//this.contentLoaderInfo.removeEventListener(Event.COMPLETE, showImage);	var tempBitmap:Bitmap = e.target.content;	var tempBitmapData:BitmapData = tempBitmap.bitmapData;	imageHolder[d] = new Sprite();	var loadBitmap:Bitmap = new Bitmap(tempBitmapData);	imageHolder[d].addChild(loadBitmap);	addChild(imageHolder[d]);	imageHolder[d].x = 13;	imageHolder[d].y = 0;	setChildIndex(imageHolder[d],2);	imageHolder[d].visible = false;	trace(path[d] + " downloaded");	d++;	if (d < path.length) {		imageLoader[d] = new Loader();		imageLoader[d].contentLoaderInfo.addEventListener(Event.COMPLETE, showImage);		imageLoader[d].load(new URLRequest(path[d]));	} else {		loader_mc.visible = false;		imageTimer = new Timer(delay);		trace(delay + " millisecond timer created");		imageTimer.addEventListener(TimerEvent.TIMER, nextImage);		nextImage();	}}function nextImage(e:TimerEvent = null):void {	imageTimer.stop();		imageHolder[n].visible = true;	imageHolder[n].alpha = 0;	if (n!=o) {		setChildIndex(imageHolder[o],3);		var t = setTimeout(hideHolder,tween,o);	}	setChildIndex(imageHolder[n],4);	alphaTween[n] = new Tween(imageHolder[n],"alpha",null,0,1,tween/1000,true);		o = n;	if (n < imageHolder.length - 1) {		n++;	} else {		n = 0;	}		imageTimer.start();}function hideHolder( {	imageHolder[b].visible = false;}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...