Note that there are some explanatory texts on larger screens.

plurals
  1. POError 1006: Not a function
    primarykey
    data
    text
    <p>I am getting the error in the title when trying to access a method in another class. I have the main class, ZombieBots, which is linked to a movie clip of the same name. I then have 3 more movie clips which all get added to the ZombieBots clip during runtime, and each of these have their own classes. </p> <p>When I attempt to access a method within the ZombieBots class from one of the other 3 classes, I get error 1006. </p> <p>The function I am attempting to access in the ZombieBots class, that cannot be accessed:</p> <pre><code> package { import flash.events.*; import flash.display.MovieClip; import flash.geom.Rectangle; public class ZombieBots extends MovieClip{ private var pLives:int; private var pScore:int; private var pSkill:int; private var pItems:int; private var characterMC:Character; private var cGameObjs:Array; public function ZombieBots() { /*cGameObjs = new Array(); addCharacter(); addItems(); addBots(); pLives = 5 - pSkill; pScore = 0; pItems = pSkill + 5;*/ resetGame(); } private function addCharacter():void{ trace("Adding the character"); if (!characterMC){ var myBorder:Rectangle = new Rectangle(35,35,600,480); var myXY:Array = [38, 400]; var myChar:int = Math.ceil(Math.random()*3); var myKeys:Array = [37,39,38,40]; var myDistance:int = myChar * 3; characterMC = new Character(myBorder, myXY, myKeys, myChar, myDistance); addChild(characterMC); } else{ characterMC.x = 38; characterMC.y = 510; characterMC.gotoAndStop(pSkill); } } private function addItems():void{ trace("yeah boi"); var mySkill:int = Math.ceil(Math.random() *3); var myMaxItems:int = mySkill + 5; trace(mySkill); trace(myMaxItems); trace(this); for (var i:int = 0; i &lt; myMaxItems; i++){ var thisItem:Item = new Item(this, characterMC, mySkill); thisItem.name = "item" + i; cGameObjs.push(thisItem); addChild(thisItem); } pSkill = mySkill; updateScores(); } private function addBots():void{ trace("adding the bots bra"); var myBorder:Rectangle = new Rectangle(100,100,400,350); var mySkill:int = Math.ceil(Math.random()*3); var myMaxBots:int = mySkill +10; for (var i:int = 0; i &lt; myMaxBots; i++){ var thisBot:Bot = new Bot(myBorder, characterMC, mySkill); thisBot.name = "bot" + i; cGameObjs.push(thisBot); addChild(thisBot); } } private function updateScores():void{ scoreDisplay.text = String(pScore); itemsDisplay.text = String(pItems); livesDisplay.text = String(pLives); msgDisplay.text = "Orc Invasion"; } public function updateLives(myBot:MovieClip):void{ trace("update lives"); pLives--; pScore -= myBot.getPts(); var myIndex:int = cGameObjs.indexOf(myBot); cGameObjs.splice(myIndex, 1); if (pLives &gt; 0){ updateScores(); } else{ gameOver(false); } } public function updateItems(myItem:MovieClip):void{ trace("update items"); pItems--; pScore += myItem.getPts(); var myIndex:int = cGameObjs.indexOf(myItem); cGameObjs.splice(myIndex, 1); if (pItems &gt; 0){ updateScores(); } else{ gameOver(true); } } private function gameOver(bool:Boolean):void{ trace("Game over dawg"); updateScores(); if(bool){ msgDisplay.text = "Good job buddy"; } else{ msgDisplay.text = "You suck dawg"; } removeLeftovers(); } private function resetGame():void{ playAgainBtn.visible = false; playAgainBtn.removeEventListener(MouseEvent.CLICK,playAgain); cGameObjs = new Array(); addCharacter(); addItems(); addBots(); pLives = 5 - pSkill; pScore = 0; pItems = pSkill + 5; updateScores(); } private function playAgain(evt:MouseEvent):void{ resetGame(); } private function removeLeftovers():void{ trace("Removing leftover items and bots"); for each(var myObj in cGameObjs){ myObj.hasHitMe(); myObj = null; } playAgainBtn.visible = true; playAgainBtn.addEventListener(MouseEvent.CLICK, playAgain); } } } </code></pre> <p>and this is the class where I am attempting to access this function within one of the other 3 classes:</p> <pre><code> package { import flash.display.MovieClip; import flash.events.*; import ZombieBots; public class Item extends MovieClip{ private var cNumItem:int; private var cNumPts:int; private var characterMC:MovieClip; private var ZombieBot:ZombieBots; public function Item(myZB:ZombieBots, myChar:MovieClip, mySkill:int=1) { ZombieBot = myZB; cNumItem = Math.ceil(Math.random() * (mySkill * 3 + 1)); characterMC = myChar; this.addEventListener(Event.ADDED_TO_STAGE,initItem); addEventListener(Event.ENTER_FRAME, checkCollision); } private function initItem(evt:Event):void{ this.gotoAndStop(cNumItem); cNumPts = cNumItem * 25; setPosition(); this.removeEventListener(Event.ADDED_TO_STAGE,initItem); } private function setPosition():void{ this.x = (Math.ceil(Math.random() * 10)*50); this.y = (Math.ceil(Math.random()*10)*35); } private function checkCollision(evt:Event){ if (characterMC.hitTestObject(this)){ ZombieBot.updateItems(this); hasHitMe(); } } public function hasHitMe():void{ trace("remove"); removeEventListener(Event.ENTER_FRAME, checkCollision); this.parent.removeChild(this); } public function getPts():int{ return cNumPts; } } } </code></pre> <p>can anyone help?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload