PeepingTom
July 24th, 2007, 09:13 AM
I made a Flash XML gallery from a mix if tutorials, I have found that if you are fast broadband some images load too quickly, it affects my bodgy code and users don't get their descriptions and exit button.
Is there anyway to slow the download speed or code better?
PeepingTom
July 24th, 2007, 09:15 AM
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(ok) {
loadBar._width = 0;
white_mc._visible = true;
active = true;
if (ok) {
//process data
allWorks = this.firstChild.childNodes;
for (i=0; i<allWorks.length; i++) {
newPiece = slider_mc.attachMovie('template', 'piece'+i, i);
newPiece._y = Math.floor(i/20)*50;
newPiece._x = (i%20)*50;
newPiece.load_btn.imageName = allWorks[i].firstChild.nextSibling.firstChild;
newPiece.holder_mc.loadMovie('thumbs/'+newPiece.load_btn.imageName);
newPiece.load_btn.imageTitle = allWorks[i].firstChild.firstChild;
newPiece.load_btn.medium = allWorks[i].firstChild.nextSibling.nextSibling.firstChild;
newPiece.load_btn.price = allWorks[i].firstChild.nextSibling.nextSibling.nextSibling.fi rstChild;
newPiece.load_btn.dimensions = allWorks[i].firstChild.nextSibling.nextSibling.nextSibling.ne xtSibling.firstChild;
newPiece.load_btn.useHandCursor = false;
newPiece.load_btn.onRelease = function() {
if (_root.active == true) {
loadBar._width = 0;
_root.createEmptyMovieClip("target_mc", 1000);
_root.target_mc._x = Stage.width/2;
_root.target_mc._y = Stage.height/2-100;
_root.target_mc.loadMovie('paintings/'+this.imageName+"?cachebuster=" + new Date().getTime());
loadBar._visible = true;
_root.attachMovie('loading', 'ltext', 1);
ltext._visible = true;
_root.ltext._x = Stage.width/2-50;
_root.ltext._y = 200;
_root.target_mc._alpha = 0;
wTitle = this.imageTitle;
wMedium = this.medium;
wPrice = this.price;
wDimensions = this.dimensions;
_root.white_mc.gotoAndPlay(2);
_root.onEnterFrame = function() {
_root.target_mc.onEnterFrame = function() {
bytes_loaded = Math.round(_root.target_mc.getBytesLoaded());
bytes_total = Math.round(_root.target_mc.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
loadBar._width = getPercent*100;
_root.active = false;
_root.quit.e_but.onRelease = function() {
_root.target_mc.unloadMovie();
_root.quit._visible = false;
_root.medium_txt._visible = false;
_root.title_txt._visible = false;
_root.price_txt._visible = false;
_root.size_txt._visible = false;
_root.white_mc.play();
loadBar._visible = false;
ltext._visible = false;
getPercent = 0;
_root.active = true;
};
if (getPercent == 0) {
loadBar._visible = false;
}
if (bytes_loaded == bytes_total) {
if (this._alpha<100) {
this._alpha += 10;
}
}
};
if (_root.target_mc._width>0) {
delete _root.onEnterFrame;
_root.target_mc._x -= _root.target_mc._width/2;
_root.target_mc._y -= _root.target_mc._height/2;
trace(_root.target_mc._width);
trace(_root.target_mc._x);
textPos = _root.target_mc._x+_root.target_mc._width;
textY = _root.target_mc._y+_root.target_mc._height;
trace(textPos);
}
style_fmt = new TextFormat();
style_fmt.size = 11;
style_fmt.font = "_sans";
if (_root.loadBar._width == 100) {
textPos = _root.target_mc._x+_root.target_mc._width;
textY = _root.target_mc._y+_root.target_mc._height;
_root.attachMovie('exit', 'quit', 998);
_root.quit._x = textPos+10;
_root.quit._y = _root.target_mc._y+10;
this.createTextField("title_txt", 10, textPos+10, textY-100, 300, 100);
title_txt.multiline = true;
title_txt.wordWrap = true;
title_txt.autoSize = "left";
title_txt.text = wTitle;
title_txt.textColor = 0x666666;
title_txt.setTextFormat(style_fmt);
this.createTextField("medium_txt", 11, textPos+10, textY-80, 300, 100);
medium_txt.multiline = true;
medium_txt.wordWrap = true;
medium_txt.autoSize = "left";
medium_txt.text = wMedium;
medium_txt.textColor = 0x666666;
medium_txt.setTextFormat(style_fmt);
this.createTextField("price_txt", 12, textPos+10, textY-40, 300, 100);
price_txt.multiline = true;
price_txt.wordWrap = true;
price_txt.autoSize = "left";
price_txt.text = wPrice;
price_txt.textColor = 0x666666;
price_txt.setTextFormat(style_fmt);
this.createTextField("size_txt", 13, textPos+10, textY-60, 300, 100);
size_txt.multiline = true;
size_txt.wordWrap = true;
size_txt.autoSize = "left";
size_text.font = "_sans";
size_txt.text = wDimensions;
size_txt.textColor = 0x666666;
size_txt.setTextFormat(style_fmt);
}
};
}
};
}
} else {
trace('Incorrect file');
}
};
myXML.load("paintings.xml");
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.