Actionscript 2.0 in Flash CS3
I downloaded a simple xml based photo gallery, but I want to categorize the content. Basically the data gets pushed into the object, and when i click a new category button I want it to begin showing the photos only in that category (which is a separate XML file).
The problem I am having is that when i click a new category it doesn’t replace the XML data of the object, it appends to it. So it continues to show the original category and then shows the new category after it gets done and then eventually goes back to the original. For example, it starts playing CatOne01.jpg from CatOne.xml, CatOne02, 03 - 10… etc… at the end it goes back to CatOne01
If you click on category 2, it loads CatTwo.xml (I watched it all load up in firebug)and it finishes playing through CatOne CatOne10.jpg and then plays CatTwo01.jpg-CatTwo10.jpg and goes back to CatOne01. I need to find a way to clear out the data before it pushes the new data from the new XML file. I tried flush (as shown below) and nothing changes, i tried delete XML, and that just makes it go blank onclick. All I need is for the values from the first xml to be flushed out before the new values are pushed in each time the user clicks the category buttons, and the new category’s images immediately begin playing.
Any suggestions?
on (release) {
gotoAndStop(1);
_root.techtype.flush();
_root.caps.flush();
_root.photos.flush();
var feed:XML = new XML();
feed.ignoreWhite = true;
feed.onLoad = function(){
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
_root.techtype.push(nodes*.attributes.id);
_root.caps.push(nodes*.attributes.desc);
_root.photos.push(nodes*.attributes.url);
}
_root.mcl.loadClip(photos[0], _root.gallery.photo);
_root.textBar.t.text = caps[0];
_root.buttons.gotoAndStop(techtype[0]);
}
feed.load("images/CatOne.xml");
}
and
var photos:Array = new Array();
var caps:Array = new Array();
var techtype:Array = new Array();
var current:Number = 0;
this.createEmptyMovieClip("gallery", -99999);
this.gallery.createEmptyMovieClip("bmdc", 1);
this.gallery.createEmptyMovieClip("photo", 2);
var bmd:BitmapData = new BitmapData(500, 375,true,0x000000);
this.gallery.bmdc.createEmptyMovieClip("preload", 1);
this.gallery.bmdc.attachBitmap(bmd, 2);
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadComplete = Delegate.create(this, tranny);
mcl.addListener(mclL);
function loadPhoto():Void
{
trace("loading photo...");
bmd.draw(this.gallery.photo);
this.gallery.photo._alpha = 0;
if(current == photos.length-1) current = 0;
else current++;
textbar._rotation = rr;
textBar.t.text = caps[current];
mcl.loadClip(photos[current], this.gallery.photo);
_root.buttons.gotoAndStop(techtype[current]);
}
function preload():Void
{
if(current == photos.length-1) var num = 0;
else var num = current+1;
this.gallery.bmdc.preload.loadMovie(photos[num]);
}
function tranny():Void
{
trace("starting transition...");
var f:Fuse = new Fuse();
f.push([{target:this.gallery.photo, alpha:100, time:4},
{target:textBar, delay:0.5, start_x:-518, x:cx, time:0.5, ease:"easeOutExpo"},
{target:textBar.arrow, x:ca, time:0.5, ease:"easeOutQuad", delay:0.5}]);
f.push({func:preload, scope:this});
f.push({target:textBar,delay:5, x:-518, time:1, ease:"easeOutExpo", func:loadPhoto, scope:this});
f.start();
}
function cx():Number
{
var te:Number = textBar.t.textWidth;
var nx:Number = -518 + te + 60;
return nx;
}
function ca():Number
{
return textBar.t._x - cx()+27;
}
function rr():Number
{
if(Math.random() < 0.5) return Math.round(Math.random()*15);
else return Math.round(-Math.random()*15);
}