flash (macromedia):
I need to be able to set a variable that refers to a function name and run the
function from the variable name. (Example: testvar = ?somefuncitonname();?
then just user testvar to call the function)
The reason I would like to so this is if there is a data connection problem
then I would like to give the user a way to try again. There are many
functions that could be called and instead of setting a var and doing multiple
if statements I could use variable to set the function that I am calling and
if it fails use the variable to call the function if the user hits ok on an
alert. ((sorry about the run on there))
EXAMPLE:
// Define action after alert confirmation.
function AlertClickHandler(evt_obj:Object) {
if (evt_obj.detail == Alert.OK) {
trace("the alert ran");
checkone = 1;
this;
delete alert_Function;
}
}
// Define alert window
function AlertWindow() {
Alert.show(alert_ErrorMessage, alert_ErrorType, Alert.OK | Alert.CANCEL,
this, AlertClickHandler, "stockIcon", Alert.OK);
delete alert_ErrorMessage;
delete alert_ErrorType;
}
var GroupsTypes_sr:Service = new Service("http://yogi/flashservices/gateway",
new Log(Log.Debug), "logic.objGetGroupsTypes", null, null);
function getGroupsTypes() {
var GroupsTypes_pc:PendingCall = GroupsTypes_sr.getGroupsTypes();
GroupsTypes_pc.responder = new RelayResponder(this, "getGroupsTypes_Result",
"getGroupsTypes_Fault");
}
function getGroupsTypes_Fault(fault:FaultEvent):Void {
alert_ErrorMessage = "We could not connect to the data connector
(groupstype). Press OK below to try again or CANCEL to close this window";
alert_ErrorType = "System Error";
alert_Function = "getGroupsTypes()";
AlertWindow();
}
You can see a few lines above the "alert_Function" is variable containing the
function I would like to call if this data function fails and go to alert.
I am new to Flash MX 8 but did work a bunch in flash 5 and early mx versions.
I have done this with coldfusion and vb but cannot figure this one out.
I have tried:
this.alert_Function;
this;
?
Thanks Much