Hi Forum
This is someting weird...
I have a Flash-file that loads external SWFs. There I use LoadVars to get external data from a server. When the data has arrived, I'm using setInterval to call a function that fades-in the content.
So far so good.
But when I switch menus (a.k.a. unload one movie to load another) before all the data has arrived, Flash hangs for like 15 seconds and then shows me the infamous message «A script in this movie is slowing down Flash - would you like to abort it?» (roughly translated).
I attached an «onUnload»-function to the SWF that causes the major problems, where I use clearInterval to get rid of the interval and re-instantiate the LoadVars-Variable.
Nothing helps...
Any ideas?
as per request - here's the source of the SWF causing the trouble:
var myTimer = null;
var server_send:LoadVars = new LoadVars();
this.onUnload = function () {
clearInterval(myTimer);
server_send = new LoadVars();
trace("stopping gewerbe");
};
var myself = scrollContent;
import JSON; // external Class for parsing JSON
var sRes:LoadVars = new LoadVars();
function fadeIn(which){
which._alpha += 3;
if(which._alpha >= 100){
clearInterval(myTimer);
}
}
sRes.onLoad = function(success:Boolean){
if (success){
var o:Object = JSON.parse(sRes.res);
var s:String = JSON.stringify(o);
//trace(sRes.res);
var y = 0;
for(item in o){
actCol = 0;
myself.attachMovie("row", "entry" + item, myself.getNextHighestDepth(), {_x: 0, _y:y});
var tr = myself["entry" + item];
tr.cTitle = o[item]["title"];
tr.cBild = o[item]["image"];
tr.cText = o[item]["text"];
y += 65;
}
myTimer = setInterval(fadeIn, 0.1, myself);
_root.myIntervals.push(myTimer);
}
else
{
trace("no connection...");
}
}
myself._alpha = 0;
var vars = Array("id");
var values = Array("3");
server_send.load('void.txt');
for(var i=0;i<vars.length;i++)
{
server_send[vars[i]] = escape(values[i]);
}
server_send.sendAndLoad(_global.server, sRes, "POST");
stop();