很抱歉,如果这是一个noob问题,但我已经不在AS3练习了。已经尝试过几个小时寻找解决方案,但没有任何快乐,
我有两个类应该是Dungeons和龙的角色构建器的一部分。到目前为止,代码似乎在我将它放在我的第一帧时起作用,但我想让它们进入类以便于使用。 麻烦的是,当我测试它时,绝对没有任何反应。在测试环境加载时,没有跟踪,没有错误消息,没有BSOD或除了空的白色Flash播放器之外的任何东西。
我的.fla文件文档类也使用“Main.as”。
这是Main.as类:
package
{
//imports
import Attributes;
public class Main()
{
//vars
var Humon:Attributes = new Attributes;
public function Main()
{
Humon.getStr();
trace("Wat???");
}
}
}
我认为这看起来不错。现在这是Attributes类:
//This class defines the frame work for all classes used
package
{
public class Attributes extends Object
{
//vars go here
//saves variables (get auto updated through function makeDefaultModsAndSaves())
static var refSave:int = 0;
static var forSave:int = 0;
static var wilSave:int = 0;
//attribute modifiers (get auto updated through function makeDefaultModsAndSaves())
static var StrMod:int = 0;
static var DexMod:int = 0;
static var ConMod:int = 0;
static var IntMod:int = 0;
static var WisMod:int = 0;
static var ChaMod:int = 0;
//2d array to store attributes [x][y] where x is str/dex/con/int/wis/cha and y is value
static var Attrs:Array = new Array();
Atts[0] = [10];
Atts[1] = [10];
Atts[2] = [10];
Atts[3] = [10];
Atts[4] = [10];
Atts[5] = [10];
function Attributes()
{
//constructor
trace("Attributes loaded");
}
//functions to GET Attributes
function getStr():int
{
var Str:int = 0;
Str = Atts[0][0];
trace ("Getting Str. It is " + Str);
return Str;
}
//different functions, same syntax as getStr above
function getDex():int
{
var Dex:int = 0;
Dex = Atts[1][0];
trace ("Getting Dex. It is" + Dex);
return Dex;
}
function getCon():int
{
var Con:int = 0;
Con = Atts[2][0];
trace ("Getting Con. It is" + Con);
return Con;
}
function getInt():int
{
var Int:int = 0;
Int = Atts[3][0];
trace ("Getting Int. It is" + Int);
return Int;
}
function getWis():int
{
var Wis:int = 0;
Wis = Atts[4][0];
trace ("Getting Wis. It is" + Wis);
return Wis;
}
function getCha():int
{
var Cha:int = 0;
Cha = Atts[5][0];
trace ("Cha is" + Cha);
return Cha;
}
//functions to SET Attributes
function setStr(input:int)
{
//trace old value
trace("Old Strength is: "+Atts[0][0]+".");
//assign new value from whatever source
Atts[0][0] = input;
//check new strength
trace("New Strength is: "+Atts[0][0]+"./n");
//and update mods/saves
makeDefaultModsAndSaves()
}
//different functions, same syntax as getStr above
function setDex(input:int)
{
trace("Old Dexterity is: "+Atts[0][0]+".");
Atts[1][0] = input;
trace("New Dexterity is: "+Atts[0][0]+"./n");
makeDefaultModsAndSaves()
}
function setCon(input:int)
{
trace("Old Constitution is: "+Atts[2][0]+".");
Atts[2][0] = input;
trace("New Constitution is: "+Atts[2][0]+"./n");
makeDefaultModsAndSaves()
}
function setInt(input:int)
{
trace("Old Intelligence is: "+Atts[3][0]+".");
Atts[3][0] = input;
trace("New Intelligence is: "+Atts[3][0]+"./n");
makeDefaultModsAndSaves()
}
function setWis(input:int)
{
trace("Old Wisdom is: "+Atts[4][0]+".");
Atts[4][0] = input;
trace("New Wisdom is: "+Atts[4][0]+"./n");
makeDefaultModsAndSaves()
}
function setCha(input:int)
{
trace("Old Charisma is: "+Atts[5][0]+".");
Atts[5][0] = input;
trace("New Charisma is: "+Atts[5][0]+"./n");
makeDefaultModsAndSaves()
}
//function to calculate and apply modifiers based off of ATTRIBUTES ONLY
function makeDefaultModsAndSaves():int
{
for(var i:int = 0; i < Atts.length; i++)
{
var modifier: int = 0;
trace("Current loop: "+i);
modifier = (((Atts[i][0])-10)/2);
switch (i)
{
case 0:
StrMod = modifier;
trace("Strength is "+Atts[i] +" and has a modifier of "+StrMod+".\n");
break;
case 1:
DexMod = modifier;
trace("Dexterity is "+Atts[i]+" and has a modifier of "+DexMod+". The reflex save bonus is "+refSave+".\n");
break;
case 2:
ConMod = modifier;
forSave = modifier;
trace("Constitution is "+ Atts[i]+" and has a modifier of "+ConMod+". The fortitude save bonus is "+forSave+".\n");
break;
case 3:
IntMod = modifier;
trace("Intelligence is " +Atts[i]+" and has a modifier of "+IntMod+".\n");
break;
case 4:
WisMod = modifier;
trace("Wisdom is "+Atts[i]+" and has a modifier of "+WisMod+". The will save bonus is "+wilSave+".\n");
break;
case 5:
ChaMod = modifier;
trace("Charisma is "+Atts[i]+" and has a modifier of "+ChaMod+".\n");
break;
}
}
return modifier;
}
//temporary var to initialise function.
var arse:int = makeDefaultModsAndSaves()
}
}
所以是的,我完全迷失了。我做错了什么想法?
提前致谢