1)
url += "&page="+page;
// we use a hidden HTML control, so the user does not
// see the forums being rendered.
// TODO: Optimize this, so it doesn't bother to load things
// like images, css, etc (since we don't want those anyway)
hidden.location = url;
stat.text = "Loading page "+page+"...";
prog.visible=true;
rend = 0;
}
private var rend:int ;
public function pageLoaded(e:Event):void {
prog.visible=false;
hidden.removeEventListener(Event.COMPLETE, pageLoaded);
page++;
go.label = "Load page "+page;
stat.text = "Ready";
trace("page loaded "+(getTimer()-t)/1000);
var win:JavaScriptObject = hidden.htmlControl.window; // 'window' JS object
var doc:JavaScriptObject = win.document; // 'document' JS object
// pull out all the 'div's from the page
// (no idea why this is a 'JavaScriptFunction' and not
// a 'JavaScriptObject', but that's what it is)
var divs:JavaScriptFunction = doc.getElementsByTagName('div');
trace(typeof(divs) +" / "+divs.toString());
trace("found "+divs.length+" divs");
var str:String = "";
var n:int = 0;
var last:String;
// loop through all the divs
for(var i:int=0; i 0) continue;
// create html string for the tip
str = "
Tip "+(tips+1)+": "+last+"
";
str += divs[i].innerHTML+"
";
// store the data for that tip in our array
tipData[tips] = str;
// save the tip to disk
saveTip(tips, str);
tips++;
n++;
}
}
updateHTML();
trace(n+" posts found");
stat.text = tips+" tips loaded.";
saveData(); // store application state
}
// show the next tip
public function nextPage():void {
if(currentPage+1 >= tips) return;
currentPage++;
updateHTML();
}
//show the previous tip
public function prevPage():void {
if(currentPage-1 < 0) return;
currentPage--;
updateHTML();
}
// update contents of the visible HTML control
public function updateHTML():void {
html.htmlText = tipData[currentPage];
if(tips > 0)
pagelbl.text = (currentPage+1)+" / "+tips;
else
pagelbl.text = "";
}
]]>