where to add Event.ADDED_TO_STAGE with error #1009

I have an error code #1009 and have been googling around and found a lot of links, yet I'm not sure where to put the Event.ADDED_TO_STAGE to make my project work.
The error code is
Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at at at at and my as3 code is:
Code: package{ import flash.display.*; import*; import gs.*; import fl.motion.easing.*; import framework.utils.LoadXML; import*; import*; import* import; import*; public dynamic class wotd_widget extends MovieClip{ //vars var loadXML:LoadXML = new LoadXML('',onComplete); private var mc01:MovieClip; private var mclayout:MovieClip; //constructor public function wotd_widget():void{ trace('wotd'); init_btn(); } private function onComplete($xml:XML):void{ trace($[0].title); trace($[0].description); wotd_In.text = $[0].title; des_In.text = $[0].description; var gt:GoogleTranslation = new GoogleTranslation(); gt.translate($[0].title,'en','de'); gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslate); } private function onTranslate(e:GoogleApiEvent):void{ trans_In.text =; } private function init_btn():void{ this.mc01 = new trans_btn; this.mc01.x = 340.9; this.mc01.y = 234.4; addChild(this.mc01);,1,{x:340.9, y:234.4, ease:Cubic.easeOut,onComplete:onComplete1}); } private function onComplete1():void{ this.mc01.buttonMode = true; this.mc01.addEventListener(MouseEvent.ROLL_OVER,mEvent01); this.mc01.addEventListener(MouseEvent.ROLL_OUT,mEvent01); this.mc01.addEventListener(MouseEvent.CLICK,mEvent01); } function mEvent01(e:MouseEvent):void{ switch(e.type){ case 'rollOver': //this executes when you rollover the target,0,{tint:0xFF75B6}); break; case 'rollOut': //this executes when you rolloff the target,0,{removeTint:true}); break; case 'click': //this executes when you click the target onClick01(); break; } } private function onClick01():void{ var gt:GoogleTranslation = new GoogleTranslation(); gt.translate(input_trans.text,'en','de'); gt.addEventListener(GoogleApiEvent.TRANSLATION_RESULT,onTranslation); } function onTranslation(e:GoogleApiEvent):void{ trace(; trace(; trace(; trace(; output_trans.text =; } } } NEED YOUR HELP REALLY REALLY FAST!

Posted On: Thursday 25th of October 2012 10:22:09 PM Total Views:  488
View Complete with Replies

Related Messages:

where are classes born?   (297 Views)
i got some code and a class and i want the class to access a movieclip residing in the same place that the class instance was created. how can i do this parent ain't work in classes, neither does root.
where the heck is "tance30" tracing from???   (137 Views)
I made a keyboard MovieClip full of other movieclips for the keyboard buttons. This is for a touch screen application. My thought is that the best we to handle this is to set up an event listener for the entire Keyboard movieclip instance. When the keys are touched, I find out what key letter to print to a text field by capturing the movie clip instance names: var; and then using the buttonName to ascertain what to type: var keyed:String = buttonName.slice(3); I have my mc names set up like "keyA, keyB, key1, key@ ...etc", hence the slice. I then have a case/switch that determines whether to print the character to an input field or to run a "backspace", "submit" etc function. of this works great except that, when the user touches anywhere there isn't a button, I still have an event firing off. When I trace buttonName for this, it traces "tance30".... What the heck is that "instance 30" Where is instance 30 How do I make it not send an event Of coarse, I could just have a case that does nothing when "tance30" is detected... but will it always be "tance30" Maybe in this app, but I have a feeling that this changes depending on the number of MCs present. Maybe I'm going about this all wrong and this is not the best way to capture the events in a "keyboard" movieclip. I would like some help with this if possible,
where to begin with?please help!   (176 Views)
I have very very basic knowledge about actionscript 2.0 . But now I want to learn thoroughly about actionscript.I am bit confused,beacuse now a days actionscript 3.0 is on. My question is how to proceed about learning the actionscript.would it be wise to proceed with AS3.0 directly or should I learn AS2.0 first then move to AS3.0. Can any one please help me Can you suggest me some books to begin with... *My aim is to build websites and interactive cd presentation in flash......
Scrolling is jumpy (while using the scroll bar) unless user first clicks somewhere   (207 Views)
so I have an rss reader, and starting when it first loads, it takes the rss feeds, displays the feeds, and then scrolls through them. I have a scrollbar on the side, if after the swf first loads, the user cicks on the scroll bar, and starts dragging it, the scrolling is very jumpy. Instead, if the user clicks somewhere within the swf first, the scolling is very smooth. Btw, this issue does not exist if it's in IE, only if firefox. I have been searching for days and I cannot seem to find a solution.
width and height set in HTML --where do I find them in AS3?   (247 Views)
hi, this may be a lame question but.. what exactly is "stage", or "Stage" in AS2. I mean.. the stageWidth property (Width in as2) - it's the width of my flash movie, which I set in document properties in flash, right by default, when you create a new fla, it's 550. but where do I find the width value set in the HTML file when embedding the swf
*SOLLUTION* Switch scenes on root timeline from anywhere   (187 Views)
, I've seen a lot of people struggling with this problem and just came across the sollution: To switch the scene just do the following: Code: MovieClip(root).gotoAndPlay(1, "sceneName"); Before you flame me... this is NOT the oop way but it works perfectly! The main problem is this. root is an object of type DisplayObject, that's why you get errors anytime you try to root.gotoAndPlay(). Using the above method you typecast the root object to be of the type MovieClip. Because it's a movieclip it accepts the gotoAndPlay method. Took me some time to get this principle but once you find out it ROCKS. Grtz and happy coding
SharedObject data--> where is it on the user's harddrive?   (181 Views)
I've looked on Adobe's Flash Player guide and in the official docs, but it's not mentioned. I'm creating a game that saves your progress to the local drive using SharedObjects and want to reassure users about what's going on. Also, I just want to know: where are the files saved, what is the format, etc. , You should be able to search for *.sol files to figure it out for whatever system you're on.
HELP: where to define vars in subclasses, instances   (162 Views)
Hi all, I'm an AS3 newbie and I'm trying to figure out how subclasses, instances, and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues. Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main". Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass Code: package { import flash.display.MovieClip; public class Animals extends MovieClip { public static var animalSpecies:String; public function Animals() {} } } Code: package { import flash.display.MovieClip; import Animals; public class Dog extends Animals { public function Dog() { animalSpecies = "dog"; } } } Code: package { import flash.display.MovieClip; import Animals; public class Cat extends Animals { public function Cat() { animalSpecies = "cat"; } } } Code: package { import flash.display.MovieClip; public class Main extends MovieClip { var dog_MC:Dog; var cat_MC:Cat; public function Main() { dog_MC = new Dog; addChild(dog_MC); cat_MC = new Cat; addChild(cat_MC); } } } Also, conventionally, what should be in my Main class Only the addChild code which attaches MCs to the stage Or should the values of variables be defined in Main What am I missing I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head. Can someone please explain where I should be defining values of variables for classes, subclasses, and instances
Determine where I am in array of seconds   (183 Views)
I have an array of times that I used to add cue points.. I have a Timecode In and a Timecode Out. My video is 50 minutes long. When I seek I need to determine which timecodes I am between. so say I have this: Code: [ {in:0,out:300}, {in:300,out:400}, {in:400,out:600} ] and I seek to 324 seconds..I need to somehow determine that I am in the second object (or [1]) in the array because it is between 300 and can I do that
[RESOLVED] Finding where an instance of an object is placed?   (178 Views)
. I need to find an instance of a movieclip that is on my flash file. It is really big and uses a lot of memory. It says on the number of times used that there is one instance of the object on the flash file, but I can't find it. I thought I deleted them all but there must be one left. How do I go about finding it It's a really large flash file with many layers, and I don't want to just delete the library file. Is there any way I can find where the object is placed in my file
How to make site where you upload name/face in a movie?   (187 Views)
I have a question for the more technical orientatated - What's the process behind sites like the following, where it captures information from your Facebook and displays the information randomly on the site/in the movie How is it done In the movie clip for example, how do you they show your name on the birthday sign How do they take your pictures into elements of the movie Here is the link - Something similar done before -
creating a side carosouel to scroll through images. where to begin   (181 Views)
i need some advice here and some good tutorial links. ive have to create a side carousel. the example is were if move to the left side it scrolls through image and same if mnove to the left side, the imagees have to be loaded dynamically as well. im not sure if it is called a carousel as its not a circular motion. the motion is sideways left to right. i may have to use xml ive been advised ;however, im not sure . iv dont know xml either.
I've learned AS3...where to go from here?   (368 Views)
Flashkit. I've always been interested in the developement of flash games, so have spent the last few months learning as3. I've read a good portion of the Collin Moocke book on it, and have watched at least ten hours in video instruction. I've also been messing around making test programs in Flash and Flex for a while. My ultimate goal is to make a flash platformer game, but I'm not really sure where to start. I really have no idea on how to make an actionscript virtual camera, how to make good ai, or how to do many of the things that a finished game would require. I don't need to read any more theory on actionscript, I just need some instruction on the game creation process. There doesn't seem to be as many tutorials as I would have liked for this kind of I'm coming to you . If you develop flash games, where would you recommend going to start making actual games Or am I entirely over my head in this (I do have a bit of experience in programming, namely c++ and javascript.)
ALL NEW to CS4, where to start?   (174 Views)
! I would like some help getting pointed in the right direction. (Jump to the bolded question so skip the back story) I am trying to learn ActionScript 3.0 within Flash CS4. Although I have no previous flash or action script experience, I have been a web-designer for years, I taught myself HTML and PHP. I have also taken various programming classes throughout junior high and high school; languages like QuickBasic, VisualBasic, Delphi and some C++. I am not afraid to study or to do my own research, I am however, at a standstill. For the past 2 months Ive been trying to play around and learn. I purchased 2 books which I hoped would help me get started, but apparently, I need to start with something a lot more simple. I purchased: Adobe Flash CS4 Professional BIBLE and ActionScript 3.0 BIBLE. I believe that my current knowledge of Flash CS4 is slightly past noob level, however, animations VIA timeline dont interest me as much as creating and manipulating dynamic content VIA ActionScript. What are some good books(and or website tutorials) for the ULTIMATE NOOB on ActionScript 3.0 within Flash CS4
where is it embedded???   (169 Views)
How to know how many websites and which websites embed my flash project I uploaded my flash project to google sites and and made an embed button inside it so can embed it to their websites....Now I want to know how many embedded it. Is there any actionscript code that I can add to track the sites embedding it I'll put it off stage so no one can see it except me cuz I'm the only one who WILL expand the stage to see it.
how do reference instances created by a loop elsewhere?   (178 Views)
Code: var Grid:Array = [ [1,2,1,2,1,2,1,2,1,2] [2,1,2,1,2,1,2,1,2,1] [1,2,1,2,1,2,1,2,1,2] [2,1,2,1,2,1,2,1,2,1] [1,2,1,2,1,2,1,2,1,2] [2,1,2,1,2,1,2,1,2,1] [1,2,1,2,1,2,1,2,1,2] [2,1,2,1,2,1,2,1,2,1] [1,2,1,2,1,2,1,2,1,2] [2,1,2,1,2,1,2,1,2,1] ]; My code will: - loop through the Grid array and place each tile on the stage - assign RedBall a random Grid coordinate and places it on the stage at that coordinate Problem I want to be able to click RedBall, which will create a border around the tile beneath RedBall, and create borders around the tiles above, below, to the left and to the right. BUT, I don't want to reference the tiles by their distance in pixels from RedBall or from each other; I want to reference the tiles by their coordinates in the Grid array. So I want to: - get the coordinates of RedBall - use those same coodinates to reference the tile at the same coordinates in the Grid array - use the tile's coordinates to reference the tiles above/below/left/right - apply a border to all these tiles Questions What's the best way to reference an instance of a tile Should I apply a name to each instance as it's created in the loop like = "tile"+i+"_"+j; If so, how do you reference that instance later Just tile1_3 Do you have to prepend it with root, or stage, or the class it was originally created in Do you have to use getChildByName OR, can you still reference it later without having given it a name
I want to learn: where do I start + forget AS2 and learn AS3?   (252 Views)
I want to learn: where do I start! OK: I'm no stranger to Flash and have done lots of coding in Flash (non AS2) My coding has been mostly hacking and creating spaghetti unmanageable code! I went to a Flash seminar today and really want to get into everything again Where do I start Should I just learn from the online tutorials from Adobe Anywhere else I'm no stranger to programming - but never really got into OO programming I really want to get into it now though! I want to learn: Flash CS4 AS3 Flex Air Is there anything else I need to learn I'd like to really get into Papervision as well Are there any recommended books + I never got into AS2 Should I forget about AS2 and just head straight into AS3
Arrow at 90 degrees with the mouse can move regardless of where the mouse is   (227 Views)
I have the following problem: I use that script to rotate a arrow. from 0 to 90 Degrees. But with this script I can the arrow only between 0 and 90 degrees can rotate when the mouse hovers over it in this area. My question now is how can I change the order of the arrow is aligned correctly when I do with the mouse only the corresponding circular movement no matter where it is located on the Flash Programm I Hope these translation is passably ok
8-way scroller where's wally. Code help   (288 Views)
Sorry if the title made no sense. Basically I'm making a where's Wally (Waldo if your American) type game, where you scroll up, down, left, right and diagonally around an image. Firstly, my code seems pretty overweight. I'd normally use AS2 but im dabbling in AS3 as i'll probably need to make the move soon anyway. Was just after some advice on how to make the code less bulky. I realise i've probably gone the long way about doing things. So any tips for shortening it Secondly, the image keeps scrolling even if you go past the edge of it. I tried to figure out how to make it stop if you reach the edge but it didnt work. I'm sure its pretty simple but couldnt manage it. Heres the AS ActionScript Code: import; import; import flash.ui.Mouse; var moveDown = false; var moveUp = false; var moveRight = false; var moveLeft = false; var speed = 10; downBtn.addEventListener(MouseEvent.ROLL_OVER, downOver, false, 0, true); downBtn.addEventListener(MouseEvent.ROLL_OUT, downOut, false, 0, true); upBtn.addEventListener(MouseEvent.ROLL_OVER, upOver, false, 0, true); upBtn.addEventListener(MouseEvent.ROLL_OUT, upOut, false, 0, true); rightBtn.addEventListener(MouseEvent.ROLL_OVER, rightOver, false, 0, true); rightBtn.addEventListener(MouseEvent.ROLL_OUT, rightOut, false, 0, true); leftBtn.addEventListener(MouseEvent.ROLL_OVER, leftOver, false, 0, true); leftBtn.addEventListener(MouseEvent.ROLL_OUT, leftOut, false, 0, true); downRightBtn.addEventListener(MouseEvent.ROLL_OVER, downRightOver, false, 0, true); downRightBtn.addEventListener(MouseEvent.ROLL_OUT, downRightOut, false, 0, true); downLeftBtn.addEventListener(MouseEvent.ROLL_OVER, downLeftOver, false, 0, true); downLeftBtn.addEventListener(MouseEvent.ROLL_OUT, downLeftOut, false, 0, true); upRightBtn.addEventListener(MouseEvent.ROLL_OVER, upRightOver, false, 0, true); upRightBtn.addEventListener(MouseEvent.ROLL_OUT, upRightOut, false, 0, true); upLeftBtn.addEventListener(MouseEvent.ROLL_OVER, upLeftOver, false, 0, true); upLeftBtn.addEventListener(MouseEvent.ROLL_OUT, upLeftOut, false, 0, true); function downOver(event:MouseEvent):void{ moveDown = true; } function downOut(event:MouseEvent):void{ moveDown = false; } function upOver(event:MouseEvent):void{ moveUp = true } function upOut(event:MouseEvent):void{ moveUp = false; } function rightOver(event:MouseEvent):void{ moveRight = true; } function rightOut(event:MouseEvent):void{ moveRight = false; } function leftOver(event:MouseEvent):void{ moveLeft = true; } function leftOut(event:MouseEvent):void{ moveLeft = false; } function downRightOver(event:MouseEvent):void{ moveDown = true; moveRight = true; } function downRightOut(event:MouseEvent):void{ moveDown = false; moveRight = false; } function downLeftOver(event:MouseEvent):void{ moveDown = true; moveLeft = true; } function downLeftOut(event:MouseEvent):void{ moveDown = false; moveLeft = false; } function upRightOver(event:MouseEvent):void{ moveUp = true; moveRight = true; } function upRightOut(event:MouseEvent):void{ moveUp = false; moveRight = false; } function upLeftOver(event:MouseEvent):void{ moveUp = true; moveLeft = true; } function upLeftOut(event:MouseEvent):void{ moveUp = false; moveLeft = false; } function Move() { stage.addEventListener(Event.ENTER_FRAME, moveAround); } function moveAround(evt:Event):void { if (moveDown == true) { mainImage.y -= speed; } if (moveUp == true) { mainImage.y += speed; } if (moveRight == true) { mainImage.x -= speed; } if (moveLeft == true) { mainImage.x += speed; } } stage.addEventListener(Event.ENTER_FRAME, stopMoving); function stopMoving(evt:Event):void { if (mainImage.y < 0){ speed == 0; } Move(); } Iv hosted the files but can't write the link!
Scaling, Registration point where art thou?   (171 Views)
Hiya, I've a perlinmap stuck unto a bitmap which is in a movieclip. Basically its a pretty starscape its tiled (2x2) so i can zoom around on it without scaling and the edges all "meet" so it appears like I have a smooth scrolling infinite bitmap. You can see it here Theres some buttons on the top right that you can use to pan and scale. Now my problem is that all scaling is tied into the (0,0) registration point thats the default for the clip. The result is that scaling/zooming results in distorted zoom that angles off towards the origin. How can I implement a centred scaling that zooms in and out of the center of the current displayed portion of the bitmap