TypeError: Error #1009 - I know how to fix it. But I don't know whats going on!

I have a project that I’m working on that includes working in different scenes and frames. It’s a book project with lots of pages (frames) and chapters (scenes) so I have can’t avoid working in a single frame (like a game). I get a runtime error (TypeError: Error #1009: Cannot access a property or method of a null object reference.) when accessing an object inside of a movieclip. However, I have identified the problem and know how to fix it. But when I fix it the functionality goes away. Here’s how it happens:
On frame #1 of Scene 2 I click on a button to go to a frame #2.
On frame #2 is the offending code:
     stage.addEventListener(MouseEvent.MOUSE_UP, moveChapters);
//********************Navigation Bar code ********************//
function moveChapters(event:MouseEvent):void
        if(event.target == bottomNav.Chapter_1)
        trace("Chapter #1 is working!");
FYI, this code is part of a navigation bar the will take the user to different chapters. It is visible on stage. I haven't fully built it yet. For example, "if( event.target == bottomNav.Chapter_1)" will take the user to chapter 1, "bottomNav.Chapter_2," will take the user to chapter 2, so on and so forth. "bottomNav" is a movieclip and "Chapter_1" is a button inside it.
When I go back to frame #1 of Scene 2 and then click on “Home” button to go back to the main page (Frame #1 of Scene #2) I get the Error #1009.
When I comment out the “if(event.target == bottomNav.Chapter_1)” I don’t get the error but know I don’t have any functionality.
Is there a better way to do this?

Adding the event listener to the stage for this sort of functionality is a bad idea. Even though Flash can, apparently, resolve the objects inside the movieClip, you are making the connection between the object and the event that you want to capture more difficult than it should be. A better approach is to place all of the target objects into an array and then attach the event listener to each object in the array. Then you can easily extract the target from the event.
Something like this might work for you:
var chapterList:Array = new Array(bottomNav.Chapter_1,bottomNav.Chapter_2,bottomNav.Chapter_3);
for(var i in chapterList) {
     chapterList[i].addEventListener(MouseEvent.MOUSE_UP,moveChapters);
function moveChapters(event:MouseEvent):void {
     var thisChapter:Object = event.target;
           //  etc

Similar Messages

  • My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?

    My iphone dosen't doesn't make key tone sounds anymore when I write a text message or when I want to dial a phone number I don't know how to fix this problem, I don't hear the clicking noise anymore does anyone know how to fix this problem?And all the sounds on my phone are on, even the keyboard clicks.

    Try restarting your iPhone by holding down the on/off and the home buttons at the same time until you see the Apple logo, double check the volume button just in case.  If you still can't hear the tones go into your settings>sounds and make sure the options are on. 

  • I signed into my Apple ID on a new phone and I already had it on my iPod. When I signed into the new phone it won't let me buy anything unless I know my old security questions but I don't know the answers to them. How can I get past those or change them?

    I signed into my Apple ID on a new phone and I already had it on my iPod. When I signed into the new phone it won't let me buy anything unless I know my old security questions but I don't know the answers to them. How can I get past those or change them?

    See Kappy's great User Tips.
    See my User Tip for some help: Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities https://discussions.apple.com/docs/DOC-4551
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    Send Apple an email request for help at: Apple - Support - iTunes Store - Contact Us http://www.apple.com/emea/support/itunes/contact.html
    Call Apple Support in your country: Customer Service: Contacting Apple for support and service http://support.apple.com/kb/HE57
     Cheers, Tom

  • My ipod classic is corrupted I know how to fix it but it's dead and won't charge?

    I tried fixing my dad's old ipod classic but it was corrupted.So I looked up how to do it but my ipod dead and won't charge!!!!

    See Corrupt iPod classic.
    tt2

  • The time limits on the parental controls do not work. Apple does not seem to know how to fix this issue since the problem has been going on since at least leopard.

    The time limits in the parental controls do not work. I have several mac systems and they do not work on all of them. Also, I have had this problem since at least snow leopard and it is very frustrating that Apple is unable to fix a simple issue like this. All they have to do is somehow 'hard-wire' the time limits to the system clock but they are not listening. I used the feed-back feature in their support webpage and hopefully everybody else experiencing this issue will too. Thus, if they get a thousand notes on this issue they might listen and finally fix it.

    Well, the whole system with those time limits are funky. Sometime this happens, sometime that happens. When the user is on the bed time limits do not work nor do the length of time limits. It is very frustrating as one of the reasons I bought an apple in the first place was those parental controls which did not exist in Windows prior to Windows 7. I do have a Windows 7 machine now and the bed time limits work there. Maybe you have a Windows 7 machine as well and can let them use it.

  • HT5312 I forgot my security answers how do I change if I don't know the answers

    I forgot my security answers I know how to change them but I don't know the answers to my questions

    You need to ask Apple to reset your security questions; this can be done by phoning AppleCare and asking for the Account Security team, or clicking here and picking a method, or if your country isn't listed in either article, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (106026)

  • Disteller error 5 and i don't know how to fix.  can anyone provide guidance?

    disteller error 5 and i don't know how to fix.  can anyone provide guidance?

    What version of Distiller Server do you run? Or is this the regular Distiller, on a server? What triggers the error?

  • I get the pinwheel and the program freezes when trying to copy and paste in Word.  Does anyone know how to fix this?

    In Word I get the spinning pinwheel when I try to copy and paste.  I can switch to other programs just fine but I can't perform the copy and paste and I need to perform a hard reboot to close Word.  Does anyone know how to fix this?

    Hi Ibo,
    This is what just worked for me:
    In Finder, I've dragged all Pages files from the iCloud Drive to the Documents folder on my iMac. (Finder asks your confirmation to remove the files from iCloud; confirm that)
    Once they were on my local hard drive, the files could be opened again.
    It looks to me as if something has changed in iCloud quite recently, leading to this mess. Not the first time, I've had this before. Now it's back. Sigh. And, as you wrote, it renders iCloud fairly useless. Back to Dropbox I suppose.

  • Facebook on iPhone 4S and iPad 2 hang all the time after installing ios6. If anyone know how to fix it pls let me know. Thx

    Facebook on iPhone 4S and iPad 2 freeze and go to home screen after installing ios 6? Anyone know how to fix it pls pls let me know. Thx

    Start with this comprehensive troubleshooting article:
    https://discussions.apple.com/docs/DOC-3521
    Look at this one for possible solutions:
    https://discussions.apple.com/docs/DOC-3353
    Ciao.

  • Exception TYpeError:netscape security privilegemanager is unidentified,pls let me know how to fix this error

    I am trying to launch Db2 setup installation but error is coming -Exception TYpeError:netscape security privilegemanager is unidentified.
    Please let me know how to fix this.
    Thank you
    Nazia

    hello, privilegemanager is deprecated since firefox 12 - please contact ibm's support if you are having problems installing their product.

  • Error 1009 keeps appearing and i don't know how to fix it?

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
      ::MainTimeline/my_guess()
    how can i fix this?

    The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....
    - is declared but not instantiated
    - doesn't have an instance name (or the instance name is mispelled)
    - does not exist in the frame where that code is trying to talk to it
    - is animated into place but is not assigned instance names in every keyframe for it
    - is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
    If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

  • Error #1009 - don't know how to fix

    Hi everyone,
    I'm new to flash and specially to AS3 and I'm getting this error message:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at VIDEO_FINAL_02_fla::MainTimeline/frame1334()
    And strangely enough it works in mw SWF&FLV Player and in Safari or Firefox!!! The button just doesn't work with flash player - and I need it to work in this player.
    It's a simple educational video - it starts with a movie, then it stops and you have to click in a button that leeds you in to some text about a subject. then you click 'continue' and you continue watching tnhe second video - and so on (7 buttons and vídeos). - It's very linear.
    Here goes the the code of this frame:
    stop ();
    myLIVRO_BOTAO.addEventListener(MouseEvent.CLICK, livroPressz);
    function livroPressz(e:MouseEvent):void {
    gotoAndPlay("LIVROa");
    I can't understand... I gave this button (LIVRO_BOTAO) an instance name (myLIVRO_BOTAO) on the properties tab.

    Forget it..
    I just found the answer in another website.
    You shouldn't have movieclips inside buttons - and that was the problem...
    I've just tried and it worked!
    You just have to include a line before the rest of the code:
    myButton = SimpleButton(getChildByName(myButton))
    myButton - name of your button.
    Thank you anyway.

  • Does anyone know how to fix an error in cc photoshop on Win8 that says puppet warp could not complete request due to program error?

    Does anyone know how to fix an error in cc photoshop on Win8 that says puppet warp could not complete request due to program error?

    Questions on using a specific program should go in that program forum
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll

  • Can anyone help me with Magicjack? after I purchased US number I am unable to log in on my Iphone, I keep getting an error "YOUR DEVICE IS NOT ON THIS ACCOUNT" I contacted MJ support but they are very much useless and dont know how to fix it!

    can anyone help me with Magicjack? after I purchased US number I am unable to log in on my Iphone, I keep getting an error "YOUR DEVICE IS NOT ON THIS ACCOUNT" I contacted MJ support but they are very much useless and dont know how to fix it!

    There's a whole lot to read in your post, and frankly I have not read it all.
    Having said that, this troubleshooting guide should help:
    http://support.apple.com/kb/TS1538
    In particular, pay attention to the mobile device support sections near the bottom, assuming you have already done the items above it.

  • Hey when ever i download and install Itunes then i open it says error finding folder please re download and I tried a tons of times and it didn't work. Does anyone know how to fix this?

    Hey when ever i download and install Itunes then i open it says error finding folder please re download and I tried a tons of times and it didnt work. Does anyone know how to fix this?

    Hi Beege140,
    I have an article for you that will help you address this launch issue with iTunes:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

Maybe you are looking for

  • Function in where clause problem

    Hi, I use Oracle 9i release 2. Imagine a Query: select e.* from employee e left outer join department d on e.dep_id=d.dep_id where d.start_date=fn_get_start_date(some_value); I need all employees who works in departments which started there existance

  • Problem with comic in iBooks

    I recently downloaded a comic on iBooks for my iPhone 4s, but unfortunately the pages only half load, leaving most of the page completely gray while having a small top part of the image displayed. I have deleted and redownloaded the comic to no avail

  • Missing TCP/IP settings for iPhone tethering (Bluetooth and USB)

    Is it just me or Apple has completely disabled the TCP/IP settings for BT and USB connections for iPhone tethering (and possibly any other mobile devices)? I can now only set the IP addresses and DNS server. No Proxies or WINS settings tabs. I have a

  • Implicit Fact column creating problem to the reports.

    Hi Friends, I have two reports from same subject area from two different facts F1 & F2. I have created one implicit column, as it is unable to judge from which fact it needs to build the query. So, it is genarting query from fact F1. I have created o

  • Agilent 53150A driver

    Hello everyone.  I have a question on the Agilent 53150A Frequency Counter.  I have been unable to find drivers for it so that I can use it in labVIEW.  I have found drivers for the 5313xa and the 53181a.  I am sure that they can be modified to work