# Images changing order upon browser refresh

**URL:** https://forum.kirupa.com/t/images-changing-order-upon-browser-refresh/301254
**Category:** flash
**Created:** [December 6, 2009, 5:30am UTC](https://forum.kirupa.com/t/images-changing-order-upon-browser-refresh/301254 "2009-12-06T05:30:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![graphica29](https://avatars.discourse-cdn.com/v4/letter/g/9fc29f/32.png) [@graphica29](https://forum.kirupa.com/u/graphica29)
#### Post date: [December 6, 2009, 5:30am UTC](https://forum.kirupa.com/t/images-changing-order-upon-browser-refresh/301254/1 "2009-12-06T05:30:11Z")

</div>

hello I have an image sroll bar on a site but cannot get the images to appear in order. Everytime the browser is refreshed the images appear in a new order. Is there a quick fix to this problem? please see code below. Thank You!

import flash.filters.DropShadowFilter;  
BarHeight=85;  
BarHeightOver=100;  
BarWidth=850;  
Spacing=5;  
alpha=65;  
barColor=“0x000000”;  
borderColor=“0x000000”;  
borderColorOnOver=“0x000000”;  
borderSize=0;  
barBorder=0;  
background=true;  
efect=3;  
WidthSpacing=30;

xml=new XML();  
xml.ignoreWhite=true;  
xml.load(“scroll.xml”); // Set the xml file  
xml.onLoad = function(ok)  
{  
if (ok)  
create\_scroll();  
}  
openWinCentre = function (url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable) {  
getURL (“javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open(’” + url + “’,’” + winName + “’,’” + “width=” + w + “,height=” + h + “,toolbar=” + toolbar + “,location=” + location + “,directories=” + directories + “,status=” + status + “,menubar=” + menubar + “,scrollbars=” + scrollbars + “,resizable=” + resizable + “,top=’+((screen.height/2)-(” + h/2 + “))+’,left=’+((screen.width/2)-(” + w/2 + “))+’” + “’)}else{myWin.focus();};void(0);”);  
};  
create\_scroll =function(){  
this.createTextField(“test”,this.getNextHighestDepth(),0,0,0,0);  
test.autoSize=“center”;  
test.text=“home”;  
test.setTextFormat(textFormat);  
testHeight=test.\_height;  
test.text="";  
this.createEmptyMovieClip(“scroll”,this.getNextHighestDepth());  
scroll.\_x=(Stage.width-BarWidth)/2;  
scroll.\_y=(Stage.height-BarHeightOver)/2;  
scroll.createEmptyMovieClip(“barBackground”,scroll.getNextHighestDepth());  
with(scroll.barBackground){  
beginFill(barColor,100);  
lineTo(BarWidth,0);  
lineTo(BarWidth,BarHeightOver+(2_barBorder));  
lineTo(0,BarHeightOver+(2_barBorder));  
lineTo(0,0);  
}

scroll.createEmptyMovieClip(“bar”,scroll.getNextHighestDepth());

scroll.createEmptyMovieClip(“barMask”,scroll.getNextHighestDepth());  
with(scroll.barMask){  
beginFill(0x000000,100);  
lineTo(BarWidth,0);  
lineTo(BarWidth,BarHeightOver+(2_barBorder)+testHeight);  
lineTo(0,BarHeightOver+(2_barBorder)+testHeight);  
lineTo(0,0);  
}

scroll.bar.setMask(scroll.barMask);  
var dsfInstanceLeft:DropShadowFilter = new DropShadowFilter(10, 0,  
barColor, 10, 20, 0);  
var dsfInstanceRight:DropShadowFilter = new DropShadowFilter(-10, 0,  
barColor, 10, 20, 0);  
scroll.createEmptyMovieClip(scroll.getNextHighestDepth());  
with(scroll.blurLeft){  
beginFill(barColor,100);  
lineTo(20,0);  
lineTo(20,BarHeightOver+(2_barBorder));  
lineTo(0,BarHeightOver+(2_barBorder));  
lineTo(0,0);  
\_x=-20;  
filters=[dsfInstanceLeft];  
}  
scroll.createEmptyMovieClip(scroll.getNextHighestDepth());  
with(scroll.blurRight){  
beginFill(barColor,100);  
lineTo(20,0);  
lineTo(20,BarHeightOver+(2_barBorder));  
lineTo(0,BarHeightOver+(2_barBorder));  
lineTo(0,0);  
\_x=scroll.bar.\_x+BarWidth;  
filters=[dsfInstanceRight];  
}  
width=WidthSpacing;  
var pic:Object = new Object();  
pic.onLoadInit = function(target:MovieClip){  
target.forceSmoothing = true;  
while (target.\_height\>BarHeight-2_borderSize){  
target.\_height-=target.\_height/100;  
target.\_width-=target.\_width/100;  
}  
target.\_x=width+borderSize;  
target.\_y=borderSize+barBorder+(BarHeightOver-BarHeight)/2;  
target.width=target.\_width;  
target.height=target.\_height;  
target.load=true;  
target.\_alpha=alpha;  
width+=(target.\_width+Spacing+(2_borderSize));  
for (j=0;j\<xml.firstChild.childNodes.length;j++){  
if (target==scroll.bar[“picture”+j].pic){  
scroll.bar[“picture”+j].y=scroll.bar[“picture”+j].\_y;  
scroll.bar[“picture”+j].x=scroll.bar[“picture”+j].\_x;  
if (background){  
with(scroll.bar[“picture”+j].background){  
beginFill(0x666666,100);  
lineTo(target.\_width+2_borderSize,0);  
lineTo(target.\_width+2_borderSize,target.\_height+2_borderSize);  
lineTo(0,target.\_height+2_borderSize);  
lineTo(0,0);  
\_x=target.\_x-borderSize;  
\_y=target.\_y-borderSize;  
}  
}  
scroll.bar[“picture”+j].onRollOver = function(){  
this.caption=true;  
}  
scroll.bar[“picture”+j].onRollOut = function(){  
this.caption=false;  
scroll.info.text="";  
}  
scroll.bar[“picture”+j].onRelease = function(){  
for (k=0;k\<xml.firstChild.childNodes.length;k++)  
if (this==scroll.bar[“picture”+k]){  
openWinCentre(xml.firstChild.childNodes[k].attributes.address, xml.firstChild.childNodes[k].attributes.target\_winName, int(xml.firstChild.childNodes[k].attributes.width), int(xml.firstChild.childNodes[k].attributes.height), int(xml.firstChild.childNodes[k].attributes.toolbar), int(xml.firstChild.childNodes[k].attributes.location), int(xml.firstChild.childNodes[k].attributes.directories), int(xml.firstChild.childNodes[k].attributes.status), int(xml.firstChild.childNodes[k].attributes.menubar), int(xml.firstChild.childNodes[k].attributes.scrollbars), int(xml.firstChild.childNodes[k].attributes.resizable));  
}  
}

}  
}

}

var imag:MovieClipLoader = new MovieClipLoader();  
imag.addListener(pic);  
for (i=0;i\<xml.firstChild.childNodes.length;i++){  
scroll.bar.createEmptyMovieClip(“picture”+i,i);  
scroll.bar[“picture”+i].createEmptyMovieClip(“background”,scroll.bar[“picture”+i].getNextHighestDepth());  
scroll.bar[“picture”+i].createEmptyMovieClip(“pic”,scroll.bar[“picture”+i].getNextHighestDepth());  
imag.loadClip(xml.firstChild.childNodes\*.attributes.url,scroll.bar[“picture”+i].pic);  
}  
scroll.createTextField(“info”,scroll.getNextHighestDepth(),0,BarHeightOver+barBorder\*2,0,0);  
scroll.info.autoSize=“center”;

scroll.barMask.onEnterFrame=function(){  
for (i=0;i\<xml.firstChild.childNodes.length;i++){  
if (scroll.bar[“picture”+i].caption){  
scroll.textBar.info.text=xml.firstChild.childNodes\*.attributes.title;  
scroll.textBar.info.setTextFormat(textFormat);  
scroll.bar[“picture”+i].pic.\_alpha=100;  
scroll.info.text=xml.firstChild.childNodes\*.attributes.title;  
scroll.info.setTextFormat(textFormat);  
if (background)  
scroll.info.\_x=scroll.bar[“picture”+i].background.\_x+scroll.bar.\_x;  
else  
scroll.info.\_x=scroll.bar[“picture”+i].pic.\_x+scroll.bar.\_x+(scroll.bar[“picture”+i].pic.\_width-scroll.info.\_width)/4;  
var color:Color = new Color(scroll.bar[“picture”+i].background);  
color.setRGB(borderColorOnOver);  
if (efect==1)  
scroll.bar[“picture”+i].\_y=5;  
if (efect==2)  
scroll.bar[“picture”+i].\_y=-5;  
if ((efect==3)&&(scroll.bar[“picture”+i].\_height\<BarHeightOver)){  
scroll.bar[“picture”+i].swapDepths(xml.firstChild.childNodes.length)  
scroll.bar[“picture”+i].pic.\_height+=5_scroll.bar[“picture”+i].pic.\_height/100;  
scroll.bar[“picture”+i].pic.\_width+=5_scroll.bar[“picture”+i].pic.\_width/100;  
scroll.bar[“picture”+i].\_y-=5_scroll.bar[“picture”+i].\_height/200;  
scroll.bar[“picture”+i].\_x-=5_scroll.bar[“picture”+i].\_width/200;  
scroll.bar[“picture”+i].background.\_width=scroll.bar[“picture”+i].pic.\_width+(2_borderSize);  
scroll.bar[“picture”+i].background.\_height=scroll.bar[“picture”+i].pic.\_height+(2_borderSize);

```
}

```

}  
else{  
var color:Color = new Color(scroll.bar[“picture”+i].background);  
color.setRGB(borderColor);  
scroll.bar[“picture”+i].pic.\_alpha=alpha;  
if ((efect==1)or(efect==2))  
scroll.bar[“picture”+i].\_y=0;  
if ((efect==3)&&(scroll.bar[“picture”+i].background.\_height\>BarHeight)&&(background)){  
scroll.bar[“picture”+i].swapDepths(i);  
scroll.bar[“picture”+i].pic.\_height-=5_scroll.bar[“picture”+i].pic.\_height/100;  
scroll.bar[“picture”+i].pic.\_width-=5_scroll.bar[“picture”+i].pic.\_width/100;  
scroll.bar[“picture”+i].\_x+=5_scroll.bar[“picture”+i].pic.\_height/200;  
scroll.bar[“picture”+i].\_y+=5_scroll.bar[“picture”+i].pic.\_width/200;  
scroll.bar[“picture”+i].background.\_height=scroll.bar[“picture”+i].pic.\_height+(2_borderSize);  
scroll.bar[“picture”+i].background.\_width=scroll.bar[“picture”+i].pic.\_width+(2_borderSize);  
if (scroll.bar[“picture”+i].\_height\<=BarHeight){  
scroll.bar[“picture”+i].pic.\_width=scroll.bar[“picture”+i].pic.width;  
scroll.bar[“picture”+i].pic.\_height=scroll.bar[“picture”+i].pic.height;  
scroll.bar[“picture”+i].\_x=scroll.bar[“picture”+i].x;  
scroll.bar[“picture”+i].\_y=scroll.bar[“picture”+i].y;  
scroll.bar[“picture”+i].background.\_height=scroll.bar[“picture”+i].pic.\_height+(2_borderSize);  
scroll.bar[“picture”+i].background.\_width=scroll.bar[“picture”+i].pic.\_width+(2_borderSize);  
}  
}  
if ((efect==3)&&(scroll.bar[“picture”+i].\_height\>BarHeight)&&(background!=true)){  
scroll.bar[“picture”+i].swapDepths(i);  
scroll.bar[“picture”+i].pic.\_height-=5_scroll.bar[“picture”+i].pic.\_height/100;  
scroll.bar[“picture”+i].\_y+=5_scroll.bar[“picture”+i].pic.\_width/200;  
scroll.bar[“picture”+i].pic.\_width-=5_scroll.bar[“picture”+i].pic.\_width/100;  
scroll.bar[“picture”+i].\_x+=5_scroll.bar[“picture”+i].pic.\_height/200;  
if (scroll.bar[“picture”+i].\_height\<=BarHeight){  
scroll.bar[“picture”+i].pic.\_width=scroll.bar[“picture”+i].pic.width;  
scroll.bar[“picture”+i].pic.\_height=scroll.bar[“picture”+i].pic.height;  
scroll.bar[“picture”+i].\_x=scroll.bar[“picture”+i].x;  
scroll.bar[“picture”+i].\_y=scroll.bar[“picture”+i].y;  
}  
}  
}  
}  
firstWidth=scroll.bar[“picture”+0].\_width;  
lastWidth=scroll.bar[“picture”+(xml.firstChild.childNodes.length-1)].\_width;

if ((this.\_ymouse\>0)&&(this.\_ymouse\<BarHeightOver)&&(this.\_xmouse\>=0)&&(this.\_xmouse\<=BarWidth)){  
xmouse=this.\_xmouse;  
}  
if (((xmouse-firstWidth)\>0)&&((xmouse+lastWidth)\<BarWidth)){  
scroll.bar.\_x-=(Math.abs((((width+WidthSpacing)-BarWidth)/BarWidth)_(xmouse-lastWidth+(firstWidth+lastWidth)_(xmouse/(BarWidth-lastWidth))))-Math.abs(scroll.bar.\_x-this.\_x))/10;  
}  
if ((xmouse-firstWidth)\<0){  
if (scroll.bar.\_x\<this.\_x)  
scroll.bar.\_x+=(Math.abs(scroll.bar.\_x)+this.\_x)/10;  
}  
if ((xmouse+lastWidth)\>BarWidth){  
if (scroll.bar.\_x\>-((width+WidthSpacing)-BarWidth-this.\_x))  
scroll.bar.\_x-=(((width+WidthSpacing)-BarWidth-this.\_x)+scroll.bar.\_x)/10;  
}  
}  
}
