As3 Error #1006 Addchild Is Not A Function
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up TypeError: Error #1006: addEventListener is not a function. (AS3) up vote -1 down vote favorite Why does not work properly? error TypeError: Error #1006: addEventListener is not a function. (AS3) Thanks for help me Why does not work properly? error TypeError: Error #1006: addEventListener is not a function. (AS3) Thanks for help me package { import flash.display.MovieClip; import fl.transitions.Tween; import fl.transitions.easing.*; import flash.events.Event; import flash.events.MouseEvent; import flash.display.Sprite; import flash.geom.ColorTransform; import flash.events.MouseEvent; import flash.events.Event; import flash.utils.ByteArray; import flash.display.DisplayObject; public class Main extends MovieClip { public var earth_btn:Earth_btn=new Earth_btn(); public var mercury_btn:Mercury_btn=new Mercury_btn(); public var venus_btn:Venus_btn=new Venus_btn(); public var Contionu:MovieClip=new MovieClip(); public var teddy_mc1:Teddy_mc1 = new Teddy_mc1(); public var teddy_mc2:Teddy_mc2 = new Teddy_mc2(); public var teddy_mc3:Teddy_mc3 = new Teddy_mc3(); public var teddy = new Array(teddy_mc1, teddy_mc2, teddy_mc3); public var palette:palette_mc=new palette_mc(); public var pal_color:ColorTransform; public var colors:Array=new Array(0xFF0000,0x00FF00,0x0000FF,0xFF0000,0x00FF00 ); public var current_color:int=0; public var buttons = new Array(mercury_btn, venus_btn, earth_btn); public function on_palette_click(e:MouseEvent):void { var palette_clicked:palette_mc=e.currentTarget as palette_mc; current_color=palette_clicked.ind; } public function on_teddy_click(e:MouseEvent):void { for (var i:int = 0; i < teddy.numChildren; i++) { if (teddy.getChildAt(i).hitTestPoint(mouseX,mouseY,true)) { pal_color=teddy.getChildAt(i).transform.colorTransform; pal_color.color=colors[current_color]; teddy.getChildAt(i).transform.colorTransform=pal_color; } }
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a http://stackoverflow.com/questions/27294089/typeerror-error-1006-addeventlistener-is-not-a-function-as3 minute: Sign up Actionscript 3.0: TypeError: Error #1006: addToValue not a function up vote 0 down vote favorite I'm sure there's some dumb mistake hiding from me, but I've been at it for over 2 hours and cannot seem to find what's going wrong. Someone please help me determine what I am doing wrong, the error is in the title and the http://stackoverflow.com/questions/17735349/actionscript-3-0-typeerror-error-1006-addtovalue-not-a-function following is my relavent code. FURTHER USEFUL DETAILS: Exact error is the following: TypeError: Error #1006: addToValue is not a function. at SimpleMenuMain/onTick() at flash.utils::Timer/_timerDispatch() at flash.utils::Timer/tick() The game runs, but does not count score, I want the score to be counted. I have triple checked that all my instance names are correct, I really don't see anything wrong with what I've done there. Possibly I somehow could be referencing them incorrectly, but all the names used in the code ARE ON my objects inside symbols and texts...etc. Thank you so much for your time, this has really been killing me. P.S.---I'm following a tutorial so if I'm doing something unnecessary don't blame me! Although other comments in addition to helping me answer this conundrum are welcome =). DOCUMENT CLASS package { import flash.display.MovieClip; public class SMGDocClass extends MovieClip { public var playScreen:SimpleMenuMain; public var titleScreen:TitleScreen; public var gameOver:GameOver; public function SMGDocClass() { titleScreen = new TitleScreen(); titleScreen.addEventListener(NavigationEvent.START,onRequestStart,false,0,true); titleScreen.x = 0; titleScreen.y = 0; addChild(titleScreen); } public function onStickman1Death(stickman1Event:Stickman1Event):void { var finalScore:Number = playScreen.getFinalScore(); var finalClockTime:Number = playScreen.getFinalClockTime(); gameOver = new GameOver(); gameOver.addEventListener(NavigationEvent.RESTART,onRequestRestart,false,0,true); gameOver.addEventListener(Navigation
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/30751902/typeerror-error-1006-addeventlistener-is-not-a-function workings and policies of this site About Us Learn more about http://stackoverflow.com/questions/22130511/error-1006-value-is-not-a-function-made-a-function-through-movieclip-function Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. as3 error Join them; it only takes a minute: Sign up TypeError: Error #1006: addEventListener is not a function up vote 0 down vote favorite New to flash, just trying to complete an assignment. A simple nav interface with start and end screens. I have that working. the code is simple. Now I'm trying to insert this tutorial into one of as3 error #1006 my frames/pages. at the moment I'm getting the error in the title, but anyway, here is the code. package { import flash.display.MovieClip; import flash.events.MouseEvent; import flash.utils.setTimeout; import flash.utils.getTimer; public class MathGameFinal extends MovieClip { private var buttonsArray:Array = new Array(); private var num1Array:Array = new Array(); private var num2Array:Array = new Array(); private var answersArray:Array = new Array(); private var count:uint = 0; private var numOfQuestions:uint = 20; private var numRange:uint = 20; private var startTime:uint; private var currentTime:uint; public function MathGameFinal() { // constructor code buttonsArray = new Array(oneBtn,twoBtn,threeBtn,fourBtn, fiveBtn,sixBtn,sevenBtn,eightBtn, nineBtn, zeroBtn, clearBtn); for (var i:uint = 0; i < buttonsArray.length; i++) { buttonsArray[i].buttonMode = true; buttonsArray[i].addEventListener(MouseEvent.CLICK, buttonClicked); } mgEnd_Screen.visible = false; mgStart_Screen.mgStart_Btn.addEventListener(MouseEvent.CLICK, startGame); } private function startGame(e:MouseEvent):void{ mgStart_Screen.visible = false; init(); } private function init():void { startTime = getTimer(); currentTime = 0; for(var j:uint = 0; j < numOfQuestions; j++){ num1Array.push( uint(Math.random() * numRange)+1 ); num2Array.push( uint(Math.random() * numRange)+1 ); answersArray.push( num1Array[j] + num2Array[j] ); } Input_Txt.text = num1Array[count] + ' + ' + num2Array[count]; } private function buttonClicked(e:MouseEvent):void{ switch(e.target){ case zeroBtn: O
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error #1006: value is not a function. made a function through movieclip.Function and call it in eventlistener up vote 0 down vote favorite I got piece of code: gameholder.addChild(crocodile); crocodile.Function = this["croccheck"]; crocodile.addEventListener(MouseEvent.CLICK,animalclick); private function animalclick(evt:Event):void { if(!evt.currentTarget.addEventListener(Event.ENTER_FRAME,evt.currentTarget.Function)) { evt.currentTarget.name.addEventListener(Event.ENTER_FRAME,evt.currentTarget.Function); } } private function croccheck(evt:Event):void { if(evt.currentTarget.currentLabel == Info.ANIMALS_READY) { evt.currentTarget.gotoAndPlay(Info.ANIMALS_ACT + "1"); evt.currentTarget.removeEventListener(Event.ENTER_FRAME,evt.currentTarget.Function); } } Even i got this error TypeError: Error #1006: value is not a function. at main/animalclick() it still work fine but i wonder why? actionscript-3 share|improve this question asked Mar 2 '14 at 16:55 user3371149 11 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote addEventListener() returns void, and you have there in animalClick a check of its return value. This apparently resolves to false, thus the second addEventListener call is made, vs name property, which is in turn a String, thus does not have addEventListener as a function. So, you should clean up your animalClick function to this: private function animalclick(evt:Event):void { if(evt.currentTarget.Function) { evt.currentTarget.addEventListener(Event.ENTER_FRAME,evt.currentTarget.Function); } } Here you are checking if there's any Function that you can add, if yes, then add, if no, then skip. share|improve this answer answered Mar 3 '14 at 7:16 Vesper 14.8k22047 Thank you!!! this is helpfull –user3371149 Mar 15 '14 at 9:57 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign