|
-
[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?
-
-
does the swf itself have a preloader?
-
-
In fact the original file has a preloader but I made new file to isolate the problem and the code i posted in the only thing in the file...and it still do the same bug.
-
Did anybody found anything wrong in this code?
-
-
-
annoying bumper- unsubscribed!
-
 Originally Posted by renderhjs
annoying bumper- unsubscribed!
Sorry to bump like this but i really need an answer,
I tried every possible way to do that but it just don't work in FF3...
I tried using MovieClipLoader, or loadMovie both produce the same problem so the problem must lie somewhere else.. i tried this code online on 2 different servers and both produce the same problem... however in offline mode or on my test server (lochalost) it works even on FF3... so I still got no idea where the problem comes from...
Ive done this many times in the past and never had a problem... this is just so stupid... i havent found any answer yet to this problem...
-
Developing For Dunkets
did you set allowscriptaccess to true in the html? Try a relative path to the xml file instead of absolute? If it works locally and not remotely it's probably a security thing that FF doesnt allow.
-
allowscriptaccess was set to sameDomain, I changed it to true, but the same bug happened....
I tried a relative path or absolute way before posting this to the forum...believe me it dont change anything... it works the same way and always bug on the first load on FF3...
So... any other suggestions ? The weird thins is I loaded pictures with an XML file many times and never had a weird bug like this...
I isolaed the code I posted in a standalone file to see it it was my code or the website in which the code is... result : the code is buggy in itself or there is a bug in the flash lugin for FF3 or im missing something I<m not aware of yet...
Thought... you are right... it definitively seems like a security feature that blocks my code on the first load...
What is weird is that on the first load, the XML is loaded properly because when I click on a picture (even if the thumbnail is not loaded, the picture pops-up and its the right picture... so the data part is fully loaded and working even in the first load in FF3, it generates empty thumbnails and the right number of them, there is just the thumbnails that are not loaded... so how can I load them properly...I don't know anything else apart loadMovie and MovieClipLoader...
-
When the bug happens, I see it tries loading the thumbnails in FF3 cause there is written in the status bar at the bottom
Transferring from blablabla...
But it just seems to give up anytime soon after that... in IE however the thumbnails appears one after the other in the order they are loaded and it dont just "give up" like this...
Im thinking that maybe its related to the way flash considers variables... they are all pointers by default... ill try searching in that area tonight...
What could also solve my problem is to redesign the code into 2 loops, the first to parse the XML and the second to run through the parsed XML contained in an array to load the thumbnails... maybe that would help... I know that each time I had a weird bug... rewriting code always gives good chances to mistakenly create a workaround... what I hate about this is that we still dont know the source of the problem and well still loose many hours the next time this happens...
-
Developing For Dunkets
Well, regardless if this helps take the mcLoader out of the loop, what a waste:
PHP 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');
var mcLoader = new MovieClipLoader(); var mclListener:Object = {}; mcLoader.addListener(mclListener); mclListener.onLoadInit = mcLoaded;
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... mc.itemsxy = itemsxy; 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'); } }
function mcLoaded(mc:MovieClip){ mc._x = 0; mc._y = 0; mc._width = mc.itemsxy; mc._height = mc.itemsxy; }
I didn't check it but this should function fine although I don't know that it will fix your problem. The code is fairly clean above otherwise so I don't know what could cause it and you should be capable of debugging this if you wrote that.
I believe onLoadInit fires in the scope of the mc so passing mc:MovieClip as a parameter is unnecessary? I forget. Good luck
-
Developing For Dunkets
PHP 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');
var mcLoader = new MovieClipLoader(); var mclListener:Object = {}; mcLoader.addListener(mclListener); mclListener.onLoadInit = mcLoaded;
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 = ''; var num:Number = nodes.length;//declare outside of the loop otherwise you have to count nodes each time var i:Number = 0;//declare it here too. for (; i<num; i++) { thumb = nodes[i].attributes.thumb; picture = nodes[i].attributes.image; var thisObj:Object = {};//faster than new Object(); thisObj.pic = picture; pictures.push(thisObj);//push is faster than straight equality //trace(picture); var thisPic:MovieClip = attachMovie('photosquare','picturethumb'+i,this.getNextHighestDepth());//attachMovie returns the attached movies name if you use it right. thisPic._x = currentx + (i%4)*(itemsxy+spacing); thisPic._y = currenty + (itemsxy+spacing)*Math.floor(i/4); //Movie clip loader for pictures... mc.itemsxy = itemsxy; mcLoader.loadClip(prefix+thumb, thisPic.pic); thisPic.btn.number = i; thisPic.btn.onPress = thisPicBtnPress; } //trace('pictures : '+ pictures[0].pic); _root.pictures = pictures; } else { trace('Error reading XML'); } }
function mcLoaded(mc:MovieClip){ mc._x = 0; mc._y = 0; mc._width = mc.itemsxy; mc._height = mc.itemsxy; }
function thisPicBtnPress(){ 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;
}
Here. a little faster/ different/ cleaner.
-
Thank you for this code.... its definitively faster that way...
But unfortunately it didn't solve the problem...
-
I finally solved this weird bug by adding the gallery loading code at 2 places in the same FLA so its basically loading the jpegs twice so for Firefox, when its time to see the thumbnails, its the second time they are loaded which solves this bug the nasty way...
I'm still curious and would like to know what is causing this bug...but I don't have the time to work on that...
Feel free to post another solution here if you found the bug...
Ill be coming around from time to time to see if someone found the bug...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|