grabarz
11-19-2007, 04:37 PM
I have the script in the movie that is putted to the frame of timeline wich is looping. After about minute i'm getting warning message: Script cause Flash Player run slow. Here is the script, please guys help me find where the problem is. Basicly it takes data from xml, and show one entry after every loop.
This is start of movie:
function ignoreEnter(mystring)
{
var temp; //stores string value with replace substring
var searchIndex=-1;
var startIndex=0;
while((searchIndex = mystring.indexOf("\n",startIndex)) != -1)
{
//if want enter include use searchIndex instead of searchIndex -1
temp+=mystring.substring(startIndex,searchIndex-1);
temp+=" ";
startIndex=searchIndex+1;
}
return temp+mystring.substring(startIndex);
}
var tempstring:String;
if(clientValue[clientindex].cdescription.length < 132)
{
tempstring=ignoreEnter(clientValue[clientindex].cdescription);
tempstring="\"" + tempstring + "\"";
}
else
{
tempsub=ignoreEnter(clientValue[clientindex].cdescription.slice(0,110));
tempstring="\"" + tempsub + "..."+"\"";
}
gtest.description=tempstring;
var custring:String;
if(clientValue[clientindex].ccustomer.length <= 18)
{
custring=clientValue[clientindex].ccustomer;
}
else
{
custring=clientValue[clientindex].ccustomer.slice(0,18);
}
gtest.customer=custring;
var citystring:String;
citystring=clientValue[clientindex].ccity+","+clientValue[clientindex].cstate;
if(citystring.length<=22){
gtest.city_state=citystring;
}
else{
gtest.city_state=citystring.slice(0,22);
}
gtest.onRelease=function(){
getURL("testimonials.php#TESTIMONIALS"+clientindex,"_self");
}
And what we have at the end of loop:
if(clientindex < xml_length)
{
var tmp=clientindex+1;
if(tmp==xml_length)
clientindex=0;
else
clientindex=tmp;
}
else if(clientindex > xml_length)
{
clientindex=0;
}
gotoAndPlay("Start");
This is start of movie:
function ignoreEnter(mystring)
{
var temp; //stores string value with replace substring
var searchIndex=-1;
var startIndex=0;
while((searchIndex = mystring.indexOf("\n",startIndex)) != -1)
{
//if want enter include use searchIndex instead of searchIndex -1
temp+=mystring.substring(startIndex,searchIndex-1);
temp+=" ";
startIndex=searchIndex+1;
}
return temp+mystring.substring(startIndex);
}
var tempstring:String;
if(clientValue[clientindex].cdescription.length < 132)
{
tempstring=ignoreEnter(clientValue[clientindex].cdescription);
tempstring="\"" + tempstring + "\"";
}
else
{
tempsub=ignoreEnter(clientValue[clientindex].cdescription.slice(0,110));
tempstring="\"" + tempsub + "..."+"\"";
}
gtest.description=tempstring;
var custring:String;
if(clientValue[clientindex].ccustomer.length <= 18)
{
custring=clientValue[clientindex].ccustomer;
}
else
{
custring=clientValue[clientindex].ccustomer.slice(0,18);
}
gtest.customer=custring;
var citystring:String;
citystring=clientValue[clientindex].ccity+","+clientValue[clientindex].cstate;
if(citystring.length<=22){
gtest.city_state=citystring;
}
else{
gtest.city_state=citystring.slice(0,22);
}
gtest.onRelease=function(){
getURL("testimonials.php#TESTIMONIALS"+clientindex,"_self");
}
And what we have at the end of loop:
if(clientindex < xml_length)
{
var tmp=clientindex+1;
if(tmp==xml_length)
clientindex=0;
else
clientindex=tmp;
}
else if(clientindex > xml_length)
{
clientindex=0;
}
gotoAndPlay("Start");