actionscript 3 - as3 error loading "good" "bad" array -


i creating "good" "bad" array display on screen can later use simple if statements upon if player has collided "good" "bad" objects. cant objects randomly generate on screen following code.

// create , set good/bad random word objects

public function newobject(e:event)      {         var goodobjects:array = ["wordobject1"];         var badobjects:array = ["wordobject2"];         if (math.random() < .5)          {             var r:int = math.floor(math.random()*goodobjects.length);             var classref:class = getdefinitionbyname(goodobjects[r]) class;             var newobject:movieclip = new classref();              newobject.typestr = "good";         } else          {             r = math.floor(math.random()*badobjects.length);             classref = getdefinitionbyname(badobjects[r]) class;             newobject = new classref();              newobject.typestr = "bad";         }         newobject.x = math.random();         newobject.y = math.random();         addchild(newobject);         objects.push(newobject);         placewords();     }     // create random word objects      public function placewords() {         objects = new array();         for(var i:int=0;i<numwordobjects;i++) {              // loop forever             while (true) {                  // random location                 var x:number = math.floor(math.random()*maprect.width)+maprect.x;                 var y:number = math.floor(math.random()*maprect.height)+maprect.y;                  // check blocks see if on                 var isonblock:boolean = false;                 for(var j:int=0;j<blocks.length;j++) {                     if (blocks[j].hittestpoint(x+gamesprite.x,y+gamesprite.y)) {                         isonblock = true;                         break;                     }                 }                  // not on any, use location                 if (!isonblock) {                     newobject.x = x;                     newobject.y = y;                     newobject.gotoandstop(math.floor(math.random()*1)+1);                     gamesprite.addchild(newobject);                     objects.splice(newobject);                     break;                 }             }         }     } 

i following errors:

1119: access of possibly undefined property x through reference static type function.
1119: access of possibly undefined property y through reference static type function. 1067: implicit coercion of value of type function unrelated type flash.display:displayobject.

try renaming var x , var y else. public properties in class extends display object (sprite/movieclip/shape).


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -