actionscript 3 - My var doesn't seem to want to inherit from a custom class -


i'm sorry if ends being noob question.

i have var set new object of class. however, keep getting error 1120 whenever test it. know error means it's undefined property. tried changing scope of (to every possible place in main class. namely class, after imports , constructor).

the code supposed part of character creator dungeons , dragons 4e.

have tried hours find solution i'm not sure. include attributes class if it's help.

var humon:attributes = new attributes 

it's declared part of main class:

package { //imports import com.classes.attributes; import flash.text.*;  public class main extends movieclip() {      private var humon:attributes = new attributes;      public function main()     {             atties.text = (humon.getstr()+", "+humon.getdex()+", "+humon.getcon()+", "+humon.getint()+", "+humon.getwis()+",  "+humon.getcha()+".");             var res:int = humon.getstr();             trace("humon str "+res+".");         }     } } 

and here's class attributes.

//this class defines frame work 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 store attributes [x][y] x str/dex/con/int/wis/cha , y 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 attributes     function getstr():int         {             var str:int = 0;             str = atts[0][0];             trace ("getting str. " + str);             return str;         } //different functions, same syntax getstr above function getdex():int     {         var dex:int = 0;         dex = atts[1][0];         trace ("getting dex. is" + dex);         return dex;     }  function getcon():int     {         var con:int = 0;         con = atts[2][0];         trace ("getting con. is" + con);         return con;     }  function getint():int     {         var int:int = 0;         int = atts[3][0];         trace ("getting int. is" + int);         return int;     }  function getwis():int     {         var wis:int = 0;         wis = atts[4][0];         trace ("getting wis. is" + wis);         return wis;     }  function getcha():int     {         var cha:int = 0;         cha = atts[5][0];         trace ("cha is" + cha);         return cha;     }  //functions set attributes function setstr(input:int) {     //trace old value     trace("old strength is: "+atts[0][0]+".");      //assign new value 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 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 calculate , apply modifiers based off of attributes         function makedefaultmodsandsaves():int         {              for(var i:int = 0; < 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 "+atts[i] +" , has modifier of "+strmod+".\n");            break;          case 1:         dexmod = modifier;         trace("dexterity "+atts[i]+" , has modifier of "+dexmod+". reflex save bonus "+refsave+".\n");         break;          case 2:         conmod = modifier;         forsave = modifier;         trace("constitution "+ atts[i]+" , has modifier of "+conmod+". fortitude save bonus "+forsave+".\n");         break;          case 3:         intmod = modifier;         trace("intelligence " +atts[i]+" , has modifier of "+intmod+".\n");         break;          case 4:         wismod = modifier;         trace("wisdom "+atts[i]+" , has modifier of "+wismod+". save bonus "+wilsave+".\n");         break;          case 5:         chamod = modifier;         trace("charisma "+atts[i]+" , has modifier of "+chamod+".\n");         break;         }            }     return modifier; }  //temporary var initialise function. var arse:int = makedefaultmodsandsaves()   } } 

  1. remove parentheses:

    public class main extends movieclip() public class main extends movieclip 
  2. ensure main.as , attributes.as placed in same folder. remove unnecessary import statement:

    import com.classes.attributes; 
  3. there error here:

    static var attrs:array = new array(); atts[0] = [10]; atts[1] = [10]; atts[2] = [10]; ... 

    rename attrs atts.

  4. in main.as class address atties. atties?

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -