I successfully built a XML gallery; everything seems to work fine. But everytime I click on a thumbnail, I will get the following error:
Error: Error #2029: This URLStream object does not have a stream opened.
I researched on this error, and it seems this error involves sounds. Something about trying to load something that’s already fully loaded. Therefore, I’m confused since I don’t have any sound in my gallery. On top of that, the gallery works just fine but this error keeps popping up in Flash. Does anyone have information about this error and how to resolve this?
import gs.TweenLite;
import fl.motion.easing.*;
import fl.controls.ProgressBar;
import flash.text.TextFieldAutoSize;
var imgNum:int = galleryData.image.length();
var spacing:int = galleryData.@spacing;
var cols:int = galleryData.@cols;
var rows:int = Math.ceil(imgNum / cols);
var imgCount:int = 0;
var gallery:MovieClip = new MovieClip();
var detailImage:Loader = new Loader();
var preloader:MovieClip;
addChild(gallery);
buildGalleryGrid();
setupDetail();
function setupDetail():void {
detail.visible = false;
detail.buttonMode = true;
detail.closeMessage.mouseEnabled = false;
detail.desc.mouseEnabled = false;
detailImage.x = detailImage.y = 15;
detail.addChild(detailImage);
detail.addEventListener(MouseEvent.CLICK, onCloseDetail, false, 0, true);
addChild(detail);
}
function onCloseDetail(evt:MouseEvent):void {
if (detailImage.alpha > .9){
detailImage.unload();
TweenLite.to(detail, .5, {autoAlpha:0});
}
}
function buildGalleryGrid():void {
var maxWidth:Number;
var maxHeight:Number;
for (var py:int = 0; py<rows; py++) {
for (var px:int = 0; px<cols; px++) {
var thumb:MovieClip = new Thumb();
thumb.x = thumb.x / 2 + (thumb.width + spacing) * px;
thumb.y = thumb.y / 2 + (thumb.height + spacing) * py;
thumb.width = 141;
thumb.height = 70;
thumb.background.alpha = 0;
preloader = new MovieClip();
preloader.x = thumb.x;
preloader.y = thumb.y;
addChild(preloader);
gallery.addChild(thumb);
if (imgCount < imgNum) {
var imageData:XML = galleryData.image[imgCount];
var loader:Loader = new Loader();
var path:String = galleryData.@folder + imageData.@thumb;
loader.load(new URLRequest(path));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onThumbComplete);
thumb.addChild(loader);
thumb.addChild(thumb.background);
thumb.addChild(thumb.border);
thumb.background.alpha = 0;
thumb.buttonMode = true;
thumb.desc = imageData;
thumb.hasImage = true;
thumb.detail = galleryData.@folder + imageData.@detail;
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = loader.contentLoaderInfo;
preloader_pb.x = gallery.x;
preloader_pb.y = 116 + thumb.height / 2 - preloader_pb.height / 2;
preloader_pb.width = thumb.width;
preloader.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
} else {
thumb.background.alpha = 0.75;
thumb.border.alpha = 0.75;
thumb.alpha = 0.75;
}
imgCount++;
maxWidth = gallery.width;
maxHeight = gallery.height;
}
}
gallery.y = 116;
for (var i:int = 0; i<gallery.numChildren; i++){
thumb = MovieClip(gallery.getChildAt(i));
TweenLite.from(thumb, 0.5, {alpha:0, delay: i / 10, onComplete:onThumbsAnimated, onCompleteParams:[thumb]});
}
}
function onThumbsAnimated(thumb:MovieClip):void{
if (thumb.hasImage){
thumb.addEventListener(MouseEvent.CLICK, onThumbClick, false, 0, true);
thumb.addEventListener(MouseEvent.ROLL_OVER, onThumbOver, false, 0, true);
thumb.addEventListener(MouseEvent.ROLL_OUT, onThumbOut, false, 0, true);
}
}
function onThumbComplete(evt:Event):void {
evt.target.removeEventListener(Event.COMPLETE, onThumbComplete);
}
function onThumbOver(evt:MouseEvent):void {
var thumb:MovieClip = MovieClip(evt.target);
TweenLite.to(thumb.background, 0.5, {alpha:0.75, ease:Cubic.easeOut, onUpdate: onSortThumb, onUpdateParams:[thumb]});
}
function onSortThumb(thumb:MovieClip):void{
if (thumb.scaleX>.75){
gallery.addChild(thumb);
}
}
function onThumbOut(evt:MouseEvent):void {
var thumb:MovieClip = MovieClip(evt.target);
TweenLite.to(thumb.background, 0.5, {alpha:0, ease:Cubic.easeOut});
//TweenLite.to(evt.target,.5,{alpha:.35});
}
function onThumbClick(evt:MouseEvent):void {
TweenLite.to(detail,.75, {autoAlpha:1});
detail.desc.condenseWhite = true;
detail.desc.htmlText = evt.currentTarget.desc;
try{
detailImage.close();
}catch (e:Error){
trace(e);
}
detailImage.load(new URLRequest(evt.currentTarget.detail));
detailImage.alpha = 0;
detailImage.contentLoaderInfo.addEventListener(Event.COMPLETE, onDetailComplete);
}
function onDetailComplete(evt:Event):void {
TweenLite.to(detailImage, .5, {alpha:1});
}
function donePb(evt:Event):void{
var pb:ProgressBar = ProgressBar(evt.target);
pb.parent.removeChild(pb);
}