Hi All,
I’m having a bit of a problem here. My audio is still playing when my swf is removed. I tried using unloadAndStop(); but this isn’t working for me (either that or I’m not putting it in the correct spot. The code I have is from a template I downloaded, I didn’t actually write all this. Can someone please help me out with this:
import fl.containers.UILoader;
import caurina.transitions.*;
//---------loading the external xml file-------
var urlRequest:URLRequest = new URLRequest("xml/imagesXML.xml");
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;
urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);
//--------holds the paths to the thumbnails-------
var arrayURL:Array = new Array();
//--------holds the paths to the big photos-------
var arrayName:Array = new Array();
//--------holds the thumbnail objects-------
var holderArray:Array = new Array();
//--------represents the number of collumns-------
var nrColumns:uint = 5;
//-------represents the container of our gallery
var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;
//-------- the thumbnails container-------
var thumbsHolder:Sprite = new Sprite();
sprite.addChild(thumbsHolder);
//-------- the photoLoader container-------
var loaderHolder:Sprite = new Sprite();
//loaderHolder.graphics.beginFill(0x000000,1);
//loaderHolder.graphics.drawRect(0,0,570,330);
//loaderHolder.graphics.endFill();
loaderHolder.x = 0;
loaderHolder.alpha = 100;
loaderHolder.y = 0;
sprite.addChild(loaderHolder);
//-------- loads the big photo-------
var photoLoader:UILoader = new UILoader();
photoLoader.width = 577;
photoLoader.height = 342;
photoLoader.y = -10;
photoLoader.x = -3.5;
//photoLoader.buttonMode = true;
photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
loaderHolder.addChild(photoLoader);
/* we loop through the xml file
populate the arrayURL, arrayName and position the thumbnalis*/
function fileLoaded(event:Event):void {
myXML = XML(event.target.data);
xmlList = myXML.children();
for (var i:int=0; i<xmlList.length(); i++) {
var picURL:String = xmlList*.url;
var picName:String = xmlList*.big_url;
arrayURL.push(picURL);
arrayName.push(picName);
holderArray* = new Thumbnail(arrayURL*,i,arrayName*);
holderArray*.addEventListener(MouseEvent.CLICK,onClick);
holderArray*.name = arrayName*;
holderArray*.buttonMode = true;
//if (i<nrColumns) {
holderArray*.y = 15;
holderArray*.x = i*65+10;
//} else {
//holderArray*.y = holderArray[i-nrColumns].y+110;
//holderArray*.x = holderArray[i-nrColumns].x;
//}
thumbsHolder.addChild(holderArray*);
}
showPicture(holderArray[0].name);
}
//----handles the Click event added to the thumbnails--
function onClick(event:MouseEvent):void {
showPicture(event.currentTarget.name);
}
function showPicture(source:String):void
{
photoLoader.source = source;
loaderHolder.alpha = 0;
//Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(loaderHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(thumbsHolder, {alpha:1, time:1, transition:"linear"});
Tweener.addTween(loaderHolder, {alpha:1, time:1, delay:1, transition:"linear"});
}
//----handles the Click event added to the photoLoader----
function onClickBack(event:MouseEvent):void {
//Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(loaderHolder, {x:0, time:1, transition:"easeInLinear"});
Tweener.addTween(thumbsHolder, {alpha:1, time:2, transition:"linear"});
//Tweener.addTween(loaderHolder, {alpha:0, time:2, transition:"linear"});
}
thumbsHolder.mask = maskk2;
photoLoader.mask = maskk;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
function enterFrameHandler(event:Event):void {
var placing:int = thumbsHolder.x;
if ((placing + (300-mouseX)/10) >= -1*thumbsHolder.width+620)
{
//Tweener.addTween(thumbsHolder, {x:(thumbsHolder.x + (300-mouseX)/5), time:0.2, transition:"linear"});
placing = placing + (300-mouseX)/5;
} else {
placing = -1*thumbsHolder.width+620
}
if ((placing + (300-mouseX)/10) < 30)
{
placing = placing + (300-mouseX)/5;
} else {
placing = 30
}
Tweener.addTween(thumbsHolder, {x:placing, time:1, transition:"easeOutLinear"});
}