I think this is a scope issue, but can’t be sure. I am using FlashDevelop, Actionscript 2.0 to create my movie. I call the sendAndLoad() function to display data from a database. I also have “Previous” and “Next” buttons to move through different data.
Since I was going to load data in three different locations (Load, Previous, Next) I created a LoadData() function. This function contains the sendAndLoad() to the server.
The initial load works great with the LoadData() function, the first record is displayed correctly. My problem is when I program the onPress for the Previous and Next buttons.
Why does my LoadData() function not run when inside the Previous/Next button onPress events?
Thanks,
Kris
example code:
class Main
{
private var parent:MovieClip;
public function LoadData()
{
var sVars2:LoadVars = new LoadVars();
sVars2.cID = _global.ClientID;
sVars2.tID = _global.cTicketID;
var lVars2:LoadVars = new LoadVars();
lVars2.onLoad = function(success) {
if (success) {
//success
} else {
//not successful
}
}
sVars2.sendAndLoad(url, lVars2, "POST");
}
function Main(mc:MovieClip)
{
this.parent = mc;
//Buttons Created
_root["next"].onPress = function() {
this.LoadData();
}
_root["prev"].onPress = function() {
this.LoadData();
}
LoadData();
}
static function main(mc:MovieClip)
{
var app = new Main(mc);
}
}