Help with Error #1009

I've started to work with classes and i've come across this error:

Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Ball$iinit() at bouncingBall_CS3_fla::MainTimeline/bouncingBall_CS3_fla::frame1() The following is my class:
Code: package { import flash.display.MovieClip; import*; import flash.display.*; public class Ball extends MovieClip { private var timer:uint = 0; private var initPos:Number = 0; private var initSpeed:Number = 0; private var tehground:MovieClip; private var myBall:MovieClip; private const decay:Number = .9; private const grav:Number = 32 / stage.frameRate; public function Ball(ground:MovieClip, ball:MovieClip):void { tehground = ground; myBall = ball; timer = 0; initPos = myBall.y; myBall.addEventListener(Event.ENTER_FRAME, fall); } private function fall(e:Event):void { timer += 1; checkGround(); myBall.y = initPos + .5 * grav *(timer * timer); } private function checkGround() { if (tehground.hitTestPoint(myBall.x, initPos + .5 * grav * (timer * timer)+1, true)) { myBall.removeEventListener(Event.ENTER_FRAME, fall) while (!tehground.hitTestPoint(myBall.x, myBall.y-1, true)) { myBall.y++; } initPos = myBall.y; timer = 0; initSpeed = decay * Math.sqrt(Math.abs(2 * (myBall.y - tehground.y))); myBall.addEventListener(Event.ENTER_FRAME, rise); } } private function rise(e:Event):void { timer += 1; myBall.y -= .5 * grav * (timer * timer) - initSpeed * timer; } } } And this is on the first frame of flash:
Code: var myBall:Ball = new Ball(tehground, tehball); tehground and tehball are instance names of 2 different MovieClips.

Posted On: Thursday 25th of October 2012 10:39:37 PM Total Views:  466
View Complete with Replies

Related Messages:

Really need help with page aware flash menu and AS3   (291 Views)
Hi all I followed a tutorial online to create a flash menu that 'knew' which page it was on via javascript ( The menu worked until I assigned links to the buttons. The code for the menu is: Code: stop(); // setup our 5 buttons item1.addEventListener(MouseEvent.CLICK, gotoURL); item2.addEventListener(MouseEvent.CLICK, gotoURL); item3.addEventListener(MouseEvent.CLICK, gotoURL); item4.addEventListener(MouseEvent.CLICK, gotoURL); item5.addEventListener(MouseEvent.CLICK, gotoURL); // grab variables try { var key:String; var val:String; var flashvars:Object = LoaderInfo(this.root.loaderInfo).parameters; for (key in flashvars) { val = String(flashvars[key]); if(key == "item"){ // If the parameter is called 'item'... if(val.substr(0,4) == "item"){ // ... and the name of the button starts with the characters 'item'... // ... we can extract the number-part of the item-name and go to the correct frame var frameToGoTo:Number = Number( val.substr(4,1) ); gotoAndStop( frameToGoTo+1 ); } } } } catch (error:Error) { // what to do if an error occurs } // Get the new page function gotoURL(e:MouseEvent):void { // First we grab the URL of the HTML document and split it into an array var htmlUrl:String ="window.location.href.toString"); // split the string at the questionmark var splitUrl:Array = htmlUrl.split(""); // use only the first part (ditch existing parameters) var trimmedUrl:String = splitUrl[0]; // get the name of the button clicked and set it as a parameter var parameters:String = "item="; trace("parameters "+parameters); // combine url and parameters with a new questionmark var requester:URLRequest = new URLRequest(trimmedUrl+""+parameters); // reload the page navigateToURL(requester, '_self'); } And the code for the buttons is: Code: item1.addEventListener(MouseEvent.CLICK,goindex1); function goindex1(e:MouseEvent){ var request = new URLRequest(""); navigateToURL(request,"_self"); } item2.addEventListener(MouseEvent.CLICK,goindex2); function goindex2(e:MouseEvent){ var request = new URLRequest(""); navigateToURL(request,"_self"); } item3.addEventListener(MouseEvent.CLICK,goindex3); function goindex3(e:MouseEvent){ var request = new URLRequest(""); navigateToURL(request,"_self"); } item4.addEventListener(MouseEvent.CLICK,goindex4); function goindex4(e:MouseEvent){ var request = new URLRequest(""); navigateToURL(request,"_self"); } item5.addEventListener(MouseEvent.CLICK,goindex5); function goindex5(e:MouseEvent){ var request = new URLRequest(""); navigateToURL(request,"_self"); } As you can see item1 should go to The item=item1 part means that the button 'item1' is highlighted. This works for fine if you click the buttons incrementally (button1 then button2...) but doesn't worki if you go back down through the sequence, only the part after the '' changes not that page itself. I am sorry if this is not explained very well but I am a total noob. You can see a working example at
AS3: need help with dynamically adding multiple mc to one mask   (404 Views)
hello, i'm trying to add movieclips to a single mask. but i cant seem to get it to work. is there a easy way to do this or do i have to remove the mask-child and add a new one again
Illegal function help..simplify xml import   (232 Views)
, For an application I'm making I need some dedicated xml import. To simplify this import I want to have a function (because I need a repetitive process). The only thing is that I want to change parameters inside a xml string as well. in all my function does not work. I've added the code below. The function I'm talking about is: function checkPercentage(intPer:Number, textfield, xmlText):void Code: var intPer1:Number = 30; var intPer2:Number = 60; function showXML(event:MouseEvent) { var intent_xml:XML; var xmlReq:URLRequest = new URLRequest("intent.xml"); var xmlLoader:URLLoader = new URLLoader(); function checkPercentage(intPer:Number, textfield, xmlText):void { if(intPer < 33){ textfield.text = intent_xml.xmlText.low; }else if(intPer < 66){ textfield.text = intent_xml.xmlText.medium; }else{ textfield.text = intent_xml.xmlText.high; } } function dataLoaded(event:Event):void { intent_xml = new XML(; //give proper description for low/medium/high checkPercentage(intPer1, intentI_txt, intent_I); checkPercentage(intPer2, intentII_txt, intent_II); } xmlLoader.addEventListener(Event.COMPLETE, dataLoaded); xmlLoader.load(xmlReq); } process_btn.addEventListener(MouseEvent.CLICK, showXML); Can someone point me in the right direction
Flash AS3 help - Error   (141 Views)
, Sorry if this is been answered 1000 times before but I keep getting this message whenever I test my movie.. I've googled it so many times and I still can't figure it out. TypeError: Error #1009: Cannot access a property or method of a null object reference. at Main() at site() at flashsitecopy_fla::wholeSite_1/frame1() I've used a tutorial on dynamic websites and another tutorial from Computer Arts magazine. Main is an external Base class file and site is the movie clip I'm trying to add to my website This is from Code: package { import caurina.transitions.Tweener; import*; import flash.display.*; import*; import flash.filters.BitmapFilterQuality; import flash.filters.BlurFilter; public class Main extends MovieClip { // This is the list of the photo's z and x positions, the parallax damp, image, depth and t-shirt name. // This can be easily changed so this data is XML driven. private var arrPhotos:Array = new Array({zPos:500, xPos:-500, damp:7, image:image1, depth:0, tee:""}, {zPos:700, xPos:300, damp:8, image:image2, depth:1, tee:""}, {zPos:500, xPos:600, damp:6, image:image3, depth:2, tee:""}, {zPos:300, xPos:-50, damp:4, image:image4, depth:3, tee:""}); private var photoYpos = -320; // The y position of each photo. private var bgDamp:Number = 20; // The parallax damp for the background. private var picPush:Number = 5; // The z depth of each photo when it's rolled over. private var blurAmount:Number = 7; // The blur amount of the remaining items when a photo is selected. private var currPhoto:MovieClip; // The current selected photo. private var currPhotoNum:Number; // The number of the current selected photo. private var photoHolder:MovieClip = new MovieClip(); // The clip that holds the photos. private var closeBtn:closebtn; function Main(){ stage.quality = StageQuality.HIGH; addChild(photoHolder); FilterShortcuts.init(); initStage(); } // ***** INITIALIZE FUNCTIONS ***** private function initStage():void { for(var i:uint = 0; i < arrPhotos.length; i++){ var photoMC:photo = new photo(); arrPhotos[i].clip = photoMC; = "p" + i; photoMC.z = arrPhotos[i].zPos; photoMC.x = arrPhotos[i].xPos; photoMC.y = photoYpos; photoMC.p_mc.txt.text = arrPhotos[i].tee; var bmap:Bitmap = new Bitmap( new arrPhotos[i].image(0,0) ); photoMC.p_mc.image_mc.addChild(bmap); var btn:MovieClip = photoMC.area_mc; initBtn(btn); btn.addEventListener(MouseEvent.ROLL_OVER, picRoll); btn.addEventListener(MouseEvent.ROLL_OUT, picOut); btn.addEventListener(MouseEvent.CLICK, picClick); photoHolder.addChild(photoMC); } startParallax(); } // ***** PARALLAX FUNCTIONS ***** private function initBtn(btn:MovieClip):void { btn.useHandCursor = true; btn.buttonMode = true; } private function startParallax():void { stage.addEventListener(MouseEvent.MOUSE_MOVE, trackMouse); } private function stopParallax():void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, trackMouse); trace("hello"); } private function trackMouse(evt:Event):void { var mousePos:Number = stage.mouseX; moveItem(bg_mc, 0 - (mousePos / bgDamp)); for(var i:uint = 0; i < arrPhotos.length; i++){ var photo:MovieClip = arrPhotos[i].clip; moveItem(photo, arrPhotos[i].xPos - (mousePos / arrPhotos[i].damp)); } } // ***** PHOTO FUNCTIONS ***** private function picRoll(evt:Event):void { var mc:MovieClip =; twistItem(mc, picPush, 0); } private function picOut(evt:Event):void { var mc:MovieClip =; twistItem(mc, 0, 0); } private function picClick(evt:Event):void { stopParallax(); enableBtns(false); currPhoto =; currPhotoNum = Number(; photoHolder.setChildIndex(currPhoto, arrPhotos.length - 1); blurItems(blurAmount); Tweener.addTween(currPhoto,{rotationX:0, z:-50, x:0, time:0.5, transition:"easeInOutSine", onComplete:initClose}); } private function enableBtns(e:Boolean):void { for(var i:uint = 0; i < arrPhotos.length; i++){ var btn:MovieClip = arrPhotos[i].clip.area_mc; btn.mouseEnabled = e; } } // ***** MOVE FUNCTIONS ***** private function moveItem(mc:MovieClip, xpos:Number):void { Tweener.addTween(mc,{x:xpos, time:1, transition:"easeOutBack"}); } private function twistItem(mc:MovieClip, rX:Number, rY:Number):void { Tweener.addTween(mc,{rotationX:rX, rotationY:rY, time:0.5, transition:"easeOutBack"}); } private function twistPhoto(evt:Event):void { twistItem(currPhoto, 0, currPhoto.mouseX / 50); } private function blurItems(amount:Number):void { blurItem(bg_mc, amount); for(var i:uint = 0; i < arrPhotos.length; i++){ var photo:MovieClip = arrPhotos[i].clip; if(photo != currPhoto){ blurItem(photo, amount); } } } private function blurItem(mc:MovieClip, amount:Number):void { var blur:BlurFilter = new BlurFilter(); blur.blurX = amount; blur.blurY = amount; blur.quality = BitmapFilterQuality.LOW; mc.filters = [blur]; } // ***** SLECTED FUNCTIONS ***** private function initClose():void { stage.addEventListener(MouseEvent.MOUSE_MOVE, twistPhoto); closeBtn = new closebtn(); closeBtn.x = -160; closeBtn.y = 775; initBtn(closeBtn); closeBtn.addEventListener(MouseEvent.CLICK, removeDetails); currPhoto.p_mc.addChild(closeBtn); } private function removeDetails(evt:Event):void { currPhoto.p_mc.removeChildAt(numChildren); stage.removeEventListener(MouseEvent.MOUSE_MOVE, twistPhoto); currPhoto.rotationY = 0; blurItems(0); Tweener.addTween(currPhoto,{rotationX:0, z:arrPhotos[currPhotoNum].zPos, x:arrPhotos[currPhotoNum].xPos, time:0.3, transition:"easeOutSine", onComplete:startAgain}); photoHolder.setChildIndex(currPhoto, arrPhotos[currPhotoNum].depth); } private function startAgain():void { startParallax(); enableBtns(true); } } } and this is from frame1 on the timeline Code: stop (); import fl.transitions.*; import fl.transitions.easing.*; // tween the main menu into place upon opening var moveTween:Tween = new Tween(mainmenu_mc, "y", Elastic.easeOut, mainmenu_mc.y, 580, 2, true); // claim MCs from library to use on stage when needed using addChild var p1:site = new site; var p2:page2 = new page2; var p3:page3 = new page3; var p4:page4 = new page4; var p5:page5 = new page5; pageContainer_mc.addChild(p1); var pageMoveTween:Tween = new Tween(pageContainer_mc, "y", Elastic.easeOut, 0, 0, 2, true); mainmenu_mc.menuBtn1_btn.addEventListener(MouseEvent.CLICK, btn1Click); mainmenu_mc.menuBtn2_btn.addEventListener(MouseEvent.CLICK, btn2Click); mainmenu_mc.menuBtn3_btn.addEventListener(MouseEvent.CLICK, btn3Click); mainmenu_mc.menuBtn4_btn.addEventListener(MouseEvent.CLICK, btn4Click); mainmenu_mc.menuBtn5_btn.addEventListener(MouseEvent.CLICK, btn5Click); function btn1Click (event:MouseEvent):void { var btn1Outro:Tween = new Tween(pageContainer_mc, "alpha", Strong.easeOut, 1, 0, 1, true); btn1Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn1Transition); function runBtn1Transition (event:TweenEvent):void { pageContainer_mc.removeChildAt(1); pageContainer_mc.addChild(p1); var btn1Intro:Tween = new Tween(pageContainer_mc, "alpha", Strong.easeOut, 0, 1, 1, true); } } function btn2Click (event:MouseEvent):void { var btn2Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true); btn2Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn2Transition); function runBtn2Transition (event:TweenEvent):void { pageContainer_mc.removeChildAt(1); pageContainer_mc.addChild(p2); var btn2Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true); } } function btn3Click (event:MouseEvent):void { var btn3Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true); btn3Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn3Transition); function runBtn3Transition (event:TweenEvent):void { pageContainer_mc.removeChildAt(1); pageContainer_mc.addChild(p3); var btn3Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true); } } function btn4Click (event:MouseEvent):void { var btn4Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true); btn4Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn4Transition); function runBtn4Transition (event:TweenEvent):void { pageContainer_mc.removeChildAt(1); pageContainer_mc.addChild(p4); var btn4Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true); } } function btn5Click (event:MouseEvent):void { var btn5Outro:Tween = new Tween(pageContainer_mc, "x", Strong.easeIn, pageContainer_mc.x, 100, 1, true); btn5Outro.addEventListener(TweenEvent.MOTION_FINISH, runBtn5Transition); function runBtn5Transition (event:TweenEvent):void { pageContainer_mc.removeChildAt(1); pageContainer_mc.addChild(p5); var btn5Intro:Tween = new Tween(pageContainer_mc, "x", Strong.easeOut, pageContainer_mc.x, 330, 1, true); } } if you could tell me what I'm doing wrong or how to fix it that would be awesome. - Tish
AS3 Date Chooser help   (149 Views)
I am looking for a Date picker tool but i seems AS3 does not include the DateChooser component anymore. What is the alternative Writing one from scratch will take a long time. Is there any other way to achieve the same functionality in AS3 Are there any ready made date pickers available I searched on the net, but could not find any similar to the AS2 datechooser.
Scroll Bar - Simple but need help   (333 Views)
I have dynamic text coming into a window. I have a scrollBar attached to it. Just like yahoo chat, or msn chat, or any messenger chat, the scrollBar goes DOWN with the text, so you don't have to scroll down, it automatically scrolls down as someone types. With default scrollBar in AS3, everytime new text comes in, the scrollBar moves up, so in order to see the text you would need to grab the bar and pull it down. Anyone know a simple fix
External swf transition big help needed.   (327 Views)
, I'm in serious trouble with an external SWF loader. Let me explain : I'm loading different SWF's in a choosen area of my website, I needed a transition effect between these loadings so I created a animation movieclip that needs to be added on top, played, removed (and rewinded each time for reuse). For an unknown reason, my external swf do load BUT the transition MC either dont play or get rewinded, meaning it sometimes hides my external SWF. Could you please tell me what's the cleanest way to achieve this in order to avoid these problems A real huge
Need help passing PHP variable through flash MC   (259 Views)
Need to get a flash banner to carry through PHP session download. The PHP code is below;
Need as3 Blur Filter help   (427 Views)
how i can initialize the Blur Filter value in as3 pls help
Selective tinting -help-   (149 Views)
Hi Everyone, I have some bitmap characters that I need to tint. They have a black outline. I've figured out how to do -almost- what I want using as3. The problem is that the outline tints too. Does anyone know of a way to exclude the black (or any other color for that matter) outline from tinting other than by copying the outline to another movieclip and overlaying it There could be thousands of movieclips and that's not practical for what I'm doing. Thank you in advance, Ian
need help with dynamic navigation   (186 Views)
, The Action script code below takes the strings in the array (pgtit) and creates a dynamic navigation bar I am trying to trace the index number of the array being click I just seem to get -1.
Need help: AS2 to AS3   (161 Views)
to ! I am a graphic designer, and I want to make my own website in flash. I know how to work in flash, but as you guess I don't have the "touch" with actionscript. I managed to understand a few of the principles of how it works, but it's still a fog in my mind. I don't intend to learn actionscript, because it's not going to be a part of what I do and, at least, for now, I don't have the necessary time. So, by reading a few tutorials, and after watching some videos, I made myself a scheme of how the site will look and work in corelation with actionscript. My website will be a portfolio, and now I want to make 3 different slideshows, each one coresponding to it's specific page. I want to make it with .xml so I can update my images easier. So...I found a component which I modified but the script is AS2 and is not working with AS3. So.. if anyone could help me, translate this to AS3...if it's possible. Code: //the time in miliseconds, which is between images var slideShowDelay:Number=5000; //curent position var curentPosition:Number=0; //the number of the images, from the xml var totalImages:Number=0; var intervalId:Number; var imagesArray:Array=[] var isSliding:Boolean=false; var _xml:XML; var me=this; //method used to start the slideshow function startSlideShow() { isSliding=true; showNextImage(); } //method used to stop the slideshow function stopSlideShow() { clearInterval(intervalId); isSliding=false; } //method used to play the next image from the slideshow function showNextImage() { loadImage(curentPosition+1); } //method used to play the previous image from the slideshow function showPreviousImage() { loadImage(curentPosition-1); } /** method used to jump to a specified index usage: loadImage(3); */ function loadImage(nr:Number) { //cecking if the nr is between 0 and totalImage if(nr>totalImages-1) nr=0; if(nr
PHP to AS3 trouble. Need help.   (177 Views)
Delete post
Random position generators help!!!   (174 Views)
, Im trying to make like a catch the falling balls game for my class assignment and its due in 2 days i need a script that is simple enough that generates a object that i have allready made and them makes it fall at different speeds. I also need a code so when my player hits the falling object it resets and goes bak to the top and falls again. The code doesnt have to be to simple i can understand a bit of action script just stuck on this bit.
swfAddress: need help with interesting problem   (262 Views)
I'm building a site that is basically a big visual interactive timeline of sorts. It uses swfAddress to track the history etc, but I'm facing an interesting problem I can't quite solve. The timeline swf itself (the core of the site) is being loaded into a wrapper swf, as one of the requirements is that this timeline can be used elsewhere, in other projects. This wrapper, however, will have some additional visuals that pertain to a stand-alone version of this timeline. As a result of never knowing exactly where this is going to be used (either a subchapter in another flash website, or as a stand-alone site by itself), I've decided to dump all of the swfAddress code into the wrapper, in a child class of it. To handle the navigation changes, I'm dispatching custom events (from the timeline) with parameters that describe the nav changes, which gets picked up by the parent wrapper, which then calls a function in the swfAddress child class for handling. Also done in this swfAddress class is the parsing of the URL onChange event (when a browser back button button or history changes the nav, rather than a Flash button). This, too, dispatches an event with info about the parsed URL, which the wrapper is picking up and then calling a function in the timeline's API to make the necessary changes. Now, the problem is that when the wrapper first loads, the swfAddress class seems to pick up an onChange event from swfAddress. It then does what it's supposed to do -- call a function in the timeline's API -- but the timeline isn't yet loaded since this happens immediately as the wrapper loads. Any suggestions on how I should handle this I need it to call this function only *after* the timeline is loaded & ready to go, but it's also got to continue calling this same function every time an onChange happens when the URL changes. So to be clear: The wrapper .swf is the first thing to load, and the swfAddress proxy class is a child of the wrapper's document class. The timeline .swf is loaded into the wrapper, and all communication is done via public function calls to the timeline (from wrapper), and events dispatches from the timeline (to the wrapper).
New project experiment, any help?   (177 Views)
Myself and a couple of others are working on a flash project that involves taking and using sound data (via audio input microphone, guitar etc) to create images/colours. I was wondering if anyone could help us out at all telling me if this is even possible in AS 3.0 and if so would it be possible to carry this out in real time, or is there other ways to do this Cheers
AS3 help   (160 Views)
I am getting an error with the following code: this.footerUp = false; //User has clicked on footer to move up function footerUp(p_event : Event) { if(this.footerUp == false){ Tweener.addTween(this.footerContainer.footerTopBar , {time:0.5, y:this.footerContainer.footerTopBar.y-40}); Tweener.addTween(this.footerContainer.pullUp, {time:0.5, y:this.footerContainer.pullUp.y-40}); Tweener.addTween(this.footerContainer.footerText, {time:0.5, y:this.footerContainer.footerText.y-40}); this.footerUp = true; } else { Tweener.addTween(this.footerContainer.footerTopBar , {time:0.5, y:this.footerContainer.footerTopBar.y+40}); Tweener.addTween(this.footerContainer.pullUp, {time:0.5, y:this.footerContainer.pullUp.y+40}); Tweener.addTween(this.footerContainer.footerText, {time:0.5, y:this.footerContainer.footerText.y+40}); this.footerUp = false; } } the error is: 1168: Illegal assignment to function footerUp. It is refering to the lines in red Any ideas why
help with buttons in different frames   (182 Views)
I'm trying to make a button in each frame which directs to different URL in each frame, and buttons which navigate between the frames right. Here I uploaded the *.fla file (Couldnt attach to kirupa, cause of the very small size limit) Throws 1009 error for me. How can I make my idea happen Maybe someone can say how this kind of things are done the proper way...
I keep getting this error: TypeError: Error #1034: Please help!   (390 Views)
I keep getting this error and I'm not sure why. TypeError: Error #1034: Type Coercion failed: cannot convert flash.text::TextField@3a062121 to fl.controls.TextArea. at SrHome_fla::MainTimeline/frame3() at flash.display::MovieClip/gotoAndPlay() at SrHome_fla::intro_mc_3/frame139() I am fairly new at this As 3.0 stuff so bare with me if this is an easy fix. Here is the code that I am using that produces that error. import fl.controls.*; var info_txt:TextArea = photoArea_mc.photoSquare_mc.info_txt; var image:XML = new XML(); image.@fileName = "pic1.jpg"; image.photographer = "Photographer 1"; info_txt.text = image.photographer; stop();
help: update flash player on authoring tool   (300 Views)
Anyone knows how to do that I can upgrade the player on the browser, the standalone player, the projector player... but not the test player inside flash cs3 authoring tool. this is driving me mad....