|
-
AS2 - Flashvars Scope
I'm trying to figure out a massive scope issue with AS2 Flashvars. So far, I've gotten all of my scripts working within "on success" load. However, the program I'm writing calls for the occasional reload of several variables.
What I'd like to do is access loaded variables outside the on(success) method in FlashVars, but so far the scope has evaded me. this. works, but licenseLoad.
doesn't if I try to remove licenseLoad.onLoad = function(success).
Code:
// Load Variables //
licenseLoad = new LoadVars();
licenseLoad.onLoad = function(success) {
// Initial Setup //
// Names //
player.text = this.player;
enemy.text = this.enemy;
// HP //
// Setup Player and Enemy Hitpoints //
playerHP = 500;
enemyHP = 500;
// Report Player HP //
hp.text = playerHP;
eHP.text = enemyHP;
// Turn Phase //
phase = 1;
// 1 - "Auto Draw Card" //
// 2 - Active Phase - Flip Drawn Card //
// 3 - Interaction Phase - Choose Action //
// Attack / Defend / Boost //
// 4 - End Phase //
// Turn Control //
turn = 1;
switch (phase) {
case 1:
turn.text = "Draw Card";
drawButton._alpha=100;
attack._alpha=20;
defend._alpha=20;
boost._alpha=20;
attack.enabled = false;
defend.enabled = false;
boost.enabled = false;
drawButton.enabled = true;
break;
case 2:
turn.text = "Active Phase";
drawButton._alpha=20;
attack._alpha=100;
defend._alpha=100;
boost._alpha=100;
attack.enabled = true;
defend.enabled = true;
boost.enabled = true;
drawButton.enabled = false;
break;
case 3:
turn.text = "Battle Phase";
drawButton._alpha=20;
attack._alpha=20;
defend._alpha=20;
boost._alpha=20;
attack.enabled = false;
defend.enabled = false;
boost.enabled = false;
drawButton.enabled = false;
break;
case 4:
turn.text = "End Phase";
drawButton._alpha=20;
attack._alpha=20;
defend._alpha=20;
boost._alpha=20;
attack.enabled = false;
defend.enabled = false;
boost.enabled = false;
drawButton.enabled = false;
break;
}
// Player License Setup //
// Load License //
licenseName = this.licenseName;
license.licenseHolder.contentPath = "/site/minithumbs/" + this.licensePicture;
// License Variable Setup //
knowledge = this.knowledge;
logic = this.logic;
focus = this.focus;
speed = this.speed;
// Set Support Card Status //
playerSupport = "NotReady";
// Choose Support Type //
supportType = this.type;
if (supportType == "License") {
Ksupport = this.supportKnow;
Lsupport = this.supportLogic;
Fsupport = this.supportFocus;
Ssupport = this.supportSpeed;
} else {
effectOneTarget = this.targetOne;
effectTwoTarget = this.targetTwo;
effectOne = this.sEffectOne;
effectType = this.sEffectOneType;
effectTwo = this.sEffectTwo;
effectTypeTwo = this.sEffectTwoType;
}
// Load Enemy License //
// Load License //
enemyPic = this.ElicensePicture;
enemyLicense.enemyLoader.contentPath = "/site/minithumbs/" + enemyPic;
// License Variable Setup //
eKnowledge = this.knowledge;
eLogic = this.logic;
eFocus = this.focus;
eSpeed = this.speed;
// Rollover Effects //
license.onRollOver = function() {
playerReporter.text = "Name:" + licenseName + ", " +"Knowledge:" + knowledge + ", " +"Logic:" + logic + ", " + "Speed:" + speed + " ," + "Focus:" + focus;
}
license.onRollOut = function() {
playerReporter.text = "";
}
supportCard.onRollOver = function () {
if (playerSupport == "NotReady") {
playerReporter.text = "This card is set!";
} else {
if (supportType == "License") {
playerReporter.text = "Knowledge:" + Ksupport + " Logic:" + Lsupport + " Speed:" + Ssupport + " Focus:" + Fsupport;
} else {
playerReporter.text = " Ability One:" + effectOne + " Ability Two:" + effectTwo+ " Targets:" + effectOneTarget + " Second Target:" + effectTwoTarget;
}
}
}
supportCard.onRollOut = function() {
playerReporter.text = "";
}
}
// Load All Variables //
licenseLoad.load("/***/flashInfo.php");
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|