[CS3][AS2] My code only works after a page reload in firefox 3
I have a big problem.
I'm using Flash CS3, exporting for flash player 9 and having troubles with the code below only in Firefox 3 (flash player 9 or 10)
In IE 6 & 7, all works OK.
The code below should show small thumbnails of images. It does work on everything I tested except firefox 3. What is weird is that if I empty my cache and load the page online, it does not show any thumbnails or sometimes only one. However, if i reload the page without emptying my cache, it will then work perfectly.
Here is my code :
Code:
System.security.allowDomain("http://www.translucidedesign.com");
var prefix = 'http://www.translucidedesign.com/kana/';
//1. Import base class
import mx.utils.Delegate;
//2. XMLLoader setup
var XMLLoader:XML;
XMLLoader = new XML();
XMLLoader.ignoreWhite = true;
XMLLoader.onLoad = Delegate.create(this,onObjectsLoaded);
XMLLoader.load(prefix+'domainebrossard.xml');
function onObjectsLoaded(success:Boolean) {
if (success) {
var nodes:Array = this.XMLLoader.childNodes[0].childNodes;
var currentx = 10;
var currenty = 10;
var itemsxy = 76;
var spacing = 10;
var pictures:Array = new Array();
var thumb = '';
var picture = '';
for (var i:Number = 0; i<nodes.length; i++) {
thumb = nodes[i].attributes.thumb;
picture = nodes[i].attributes.image;
var thisObj:Object = new Object();
thisObj.pic = picture;
pictures[i] = thisObj;
//trace(picture);
attachMovie('photosquare','picturethumb'+i,this.getNextHighestDepth());
var thisPic = eval('picturethumb'+i);
thisPic._x = currentx + (i%4)*(itemsxy+spacing);
thisPic._y = currenty + (itemsxy+spacing)*Math.floor(i/4);
//Movie clip loader for pictures...
var mcLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.itemsxy = itemsxy;
mclListener.onLoadInit = function(mc:MovieClip) {
mc._x = 0;
mc._y = 0;
mc._width = this.itemsxy;
mc._height = this.itemsxy;
trace(mc+' has received onloadinit! -> '+mc._url+', x='+mc._x+', y='+mc._y);
}
mcLoader.addListener(mclListener);
mcLoader.loadClip(prefix+thumb, thisPic.pic);
thisPic.btn.number = i;
thisPic.btn.onPress = function() {
if (_root.popup)_root.popup.removeMovieClip();
_root.attachMovie('popup','popup',_root.getNextHighestDepth());
_root.popup.number = this.number;
_root.popup.loadPic(this.number);
_root.popup._x = 200;
_root.popup._y = 200;
}
}
//trace('pictures : '+ pictures[0].pic);
_root.pictures = pictures;
} else {
trace('Error reading XML');
}
}
Here is my XML file :
Code:
<?xml version="1.0" encoding="utf-8"?>
<xmldata>
<pic thumb="gallery/thumb_001.jpg" image="gallery/001.jpg"></pic>
<pic thumb="gallery/thumb_01.jpg" image="gallery/01.jpg"></pic>
<pic thumb="gallery/thumb_002.jpg" image="gallery/002.jpg"></pic>
<pic thumb="gallery/thumb_003.jpg" image="gallery/003.jpg"></pic>
<pic thumb="gallery/thumb_004.jpg" image="gallery/004.jpg"></pic>
<pic thumb="gallery/thumb_04.jpg" image="gallery/04.jpg"></pic>
<pic thumb="gallery/thumb_005.jpg" image="gallery/005.jpg"></pic>
<pic thumb="gallery/thumb_006.jpg" image="gallery/006.jpg"></pic>
<pic thumb="gallery/thumb_007.jpg" image="gallery/007.jpg"></pic>
<pic thumb="gallery/thumb_08.jpg" image="gallery/08.jpg"></pic>
<pic thumb="gallery/thumb_09.jpg" image="gallery/09.jpg"></pic>
<pic thumb="gallery/thumb_10.jpg" image="gallery/10.jpg"></pic>
<pic thumb="gallery/thumb_11.jpg" image="gallery/11.jpg"></pic>
<pic thumb="gallery/thumb_12.jpg" image="gallery/12.jpg"></pic>
<pic thumb="gallery/thumb_013.jpg" image="gallery/013.jpg"></pic>
<pic thumb="gallery/thumb_15.jpg" image="gallery/15.jpg"></pic>
<pic thumb="gallery/thumb_16.jpg" image="gallery/16.jpg"></pic>
<pic thumb="gallery/thumb_17.jpg" image="gallery/17.jpg"></pic>
<pic thumb="gallery/thumb_18.jpg" image="gallery/18.jpg"></pic>
<pic thumb="gallery/thumb_19.jpg" image="gallery/19.jpg"></pic>
<pic thumb="gallery/thumb_20.jpg" image="gallery/20.jpg"></pic>
</xmldata>
Anybody have an idea?