Not able to synchronize object on screen with testcomplete
I am working on a flex based web application which takes time to load so I am using static delay which increases execution time significantly. I want to write a function to sync TestComplete with the object expected to be on screen.
I have written below code where I am passing the object that needs to be sync as a parameter but it is not working. I am new to Javascript so might be making some mistakes. can anyone please help.
function sync(syncobj)
{
var i=0
while (syncobj==NULL)
{
If (i > 60)
{
Log.Message("Object = " +syncobj + " not found")
}
aqutils.Delay(1000)
Log.Message("Syncing object")
i = i++
}
return syncobj
}
I am calling this sync function before the statement in which the object is getting used. While debugging I am getting error "Object expected" at If condition statement.