Intro repeats a few frames when using onClipEvent(enterFrame) and loadVars onLoad
I am using the following code to load my flash file, contact a php script and decide what frame to play based on the results. THat is all working fine, the problem is that when the animation starts from Frame 2 - gotoAndPlay(2) - it seems to repeat a few frames over and over until the whole animation is complete.
I have done some reading up and the enterFrame is called many times so I can understand why the problem is there but I don't know how to r开发者_开发技巧esolve it.
The interesting thing is, when I just use gotoAndPlay(2) in the if loaded section, it all works fine. It's only when it's in the onLoad for the loadVars that causes it to break.
Using: Flash CS5 and Actionscript 2.0
Can someone help please?
onClipEvent (load) {
total = _root.getBytesTotal();
}
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
text = percent+"%";
gotoAndStop(percent);
if (loaded == total) { //could also be percent == 100
var lvContent = new LoadVars();
lvContent.onLoad = function(success: Boolean) {
if (success) {
trace("Page: " + this.pageID);
if (this.pageID == "29") { //If it's the home page then play the full animation. If not .. don't.
_root.gotoAndPlay(5);
}else{
_root.gotoAndPlay(90);
}
}else{
_root.gotoAndStop(90); //If all else fails, don't do the intro.
}
}
lvContent.load("http://URL/Flash/getID.php");
}
}
Didn't manege to get this sorted so in the end I just stopped the animation from starting.
精彩评论