You must be logged in to post Login Register
Search 

Combining XML images and masking help

User Post

10:14 am
October 13, 2009


jackrabbit75

New Member

posts 2

1

Post edited 5:15 pm – October 13, 2009 by jackrabbit75
Post edited 5:16 pm – October 13, 2009 by jackrabbit75
Post edited 10:07 pm – October 13, 2009 by jackrabbit75
Post edited 10:09 pm – October 13, 2009 by jackrabbit75
Post edited 10:27 pm – October 13, 2009 by jackrabbit75


I am very new to AS and I'm just starting to grasp the essentials of how things are working… but I haven't got to the point to where I can write my own from scratch, so I kind of have to “Frankenstein” different examples into a working project.  I found a great XML slideshow demo that I want to overlay with that wicked cool blur mask example from this site, but I'm having some difficulty combining the techniques.


At the bottom is my original slideshow code.  If there's anyone that can modify my code or at least guide me to what I need to do to make it work, I would be incredibly appreciative.  Thanks. Laugh


**Update**  Here's a link to my site where you can see the working image slideshow without my sad transition attempt.  There is a link on the page that has a .zip download of all the files you'll need to see my script including the .xml and all images.  Please download them and tweak as you see fit.  Thanks.  


http://redbandtrailer.net


-JR


———–


import fl.transitions.Tween;

import fl.transitions.easing.*;

import fl.transitions.TweenEvent;


var my_speed:Number;

var my_total:Number;

var my_images:XMLList;


var my_loaders_array:Array=[];

var my_success_counter:Number = 0;

var my_playback_counter:Number = 0;


var my_slideshow:MovieClip = new MovieClip;

var my_image_slides:MovieClip = new MovieClip;

var my_preloader:TextField;


var my_timer:Timer;

var my_prev_tween:Tween;

var my_tweens_array:Array=[];


var my_xml_loader:URLLoader = new URLLoader();

my_xml_loader.load(new URLRequest(”slideshow.xml”));

my_xml_loader.addEventListener(Event.COMPLETE, processXML);


function processXML(e:Event):void {

var my_xml:XML = new XML(e.target.data);

my_speed =

my_images = my_xml.IMAGE;

my_total = my_images.length();

loadImages();

my_xml_loader.removeEventListener(Event.COMPLETE, processXML);

my_xml_loader = null;

}


function loadImages():void {

for(var i:Number = 0; i < my_total; i++) {

var my_url:String = my_images[i].@URL;

var my_loader:Loader = new Loader();

my_loader.load(new URLRequest(my_url));

my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

my_loaders_array.push(my_loader);

}

my_preloader = new TextField();

my_preloader.text = “Loading…”;

my_preloader.autoSize = TextFieldAutoSize.CENTER;

my_preloader.x = (stage.stageWidth – my_preloader.width)/2;

my_preloader.y = (stage.stageHeight – my_preloader.height)/2;

addChild(my_preloader);

}


function onComplete(e:Event):void {

my_success_counter++;

if(my_success_counter == my_total) {

startShow();

}

var my_loaderInfo:LoaderInfo = LoaderInfo(e.target);

my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

}


function startShow():void {

removeChild(my_preloader);

my_preloader = null;

addChild(my_slideshow);

my_slideshow.addChild(my_image_slides);

nextImage();

my_timer = new Timer(my_speed * 1000);

my_timer.addEventListener(TimerEvent.TIMER, timerListener);

my_timer.start();

}


function nextImage():void {

var my_image:Loader = Loader(my_loaders_array[my_playback_counter]);

my_image_slides.addChild(my_image);

my_image.x = (stage.stageWidth – my_image.width)/2;

my_image.y = (stage.stageHeight – my_image.height)/2;

my_tweens_array[0] = new Tween(my_image, “alpha”, Strong.easeOut, 0, 1, 1, true);

}


function timerListener(e:TimerEvent):void {

hidePrev();

my_playback_counter++;

if(my_playback_counter == my_total) {

my_playback_counter = 0;

}

nextImage();

}


function hidePrev():void {

var my_image:Loader = Loader(my_image_slides.getChildAt(0));

my_prev_tween = new Tween(my_image, “alpha”, Strong.easeOut, 1, 0, 1, true);

my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut);

}


function onFadeOut(e:TweenEvent):void {

my_image_slides.removeChildAt(0);

}


Topic RSS 
Search