I’m trying to load XML via PHP to Flash.
It all works good if I specify the: xmlData.load(“db_query.php?level0=1”);
But I have 5 buttons and I want them to load different XML (level0=1,2,3,4,5)
The PHP file is generating correct XML but I can’t get Flash to import it correctly.
In frame 1 I have the following code for handling the XML :
in movieclip “categories” there’s 5 buttons (cat1,cat2…) that, when clicked, should load the different levels and load the correct thumbnails and information.
the buttons in “categories” i have: (cat2)
on (release) {
_root.xmlData.load("db_query.php?level0=2");
_root.loadThumbs();
_root.categories.gotoAndPlay("unloadCats");
}
This code doesn’t load correctly, sometimes it loads 1 thumbnail, sometimes 2… but there is at least 5 in every level…
I’ve tried 100 different sollutions whithout any results, please help me!
Thanks, Michael.
Ps. It seems like it want’s to load the XML but doesn’t have the time = loadXML isn’t finnished when the loadThumbs() function is called, leading to only show 1-2 thumbnails and incorrect information… maby?? A recall of the xmldata.load is maby needed, but I can’t find out how…
Thats exactly whats happening - your trying to load your thumbs immediately after the xml.load is called. Flash is asynchronous - in that when the xml.load(“file.php?sdf=sdf”); is called, the next line of code is executed right away (loadThumbs) - flash doesn’t wait for the xml to load, then execute the next line of code.
You need to use the xml.onLoad method - you create the xml object, you set up the onLoad method, then you load the xml. When the xml is completely loaded, the onLoad method is fired. In that onLoad method is where you will call your loadThumbs() calling - knowing that the xml is completely loaded an in memory for use. Just search around here for xml.onLoad or “loading xml” - you’ll find many examples. Hope this helps.
I have [COLOR=#000000][COLOR=#0000BB]xmlData[/COLOR][COLOR=#007700].[/COLOR][COLOR=#0000BB]onLoad [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000BB]loadXML[/COLOR][COLOR=#007700] [/COLOR][/COLOR]and then at the end of [COLOR=#000000][COLOR=#0000BB]function loadXML(loaded)[/COLOR][COLOR=#007700][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#007700][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#007700][/COLOR][/COLOR] I have set the [COLOR=#000000][COLOR=#0000BB]loadThumbs()[/COLOR][COLOR=#007700][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#007700][/COLOR][COLOR=#0000BB][/COLOR][COLOR=#007700][/COLOR][/COLOR];
This results in, what I can see, that the thumbnail background (white square) moves correctly and places itself at a position like there where 20 thumbnails before it… But there are none…
If i set the ** xmlData.load(“db_query.php?level0=1”);** [COLOR=Navy][/COLOR]directly in frame 1 and _root.loadThumbs(); in one of the buttons it loads the thumbnails correctly.
Now I have _root.xmlData.load(“db_query.php?level0=1”); in one of the buttons and the** loadThumbs();** in the loadXML function… not working…
take out the loadthumbs on your onRelease…thats what getting called before its done loading. I moved the loadThumbs function call to the end of the XML after its loaded.
Thank you, but the result is still the same.
I dont have the loadThumbs() on my onRelease, it’s in the end of loadXML function.
It’s loading the correct amount of thumbnails, I can see it, but they doesn’t show up.
For ex. if I press category 1 it loads 14 thumbnails, result = the white background of the thumbnail loader moves to “square” 15. If I press category 2 it loads 6 thumbnails, result = another white background moves to “square” 7. Like if flash got the XML, but then theres something wrong with the attachMovie-function…
Here’s the thumbnails_fn(k) function, maby something wrong with _root-syntax or similar?