469,578 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Another error - Null object reference

I'm getting this error when I try to preview my code:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at therun4life_fla::MainTimeline/frame1()

I don't know what it could be. I looked over my code several times, and I can't find anything. Maybe it isn't sticking out because I put the code in. All of this code is in the first frame. Any idea what it could be?

Expand|Select|Wrap|Line Numbers
  1. stop();
  2.  
  3. about_mc.buttonMode = true;
  4. //runners_mc.buttonMode = true;
  5. interact_mc.buttonMode = true;
  6. newsevents_mc.buttonMode = true;
  7. support_mc.buttonMode = true;
  8.  
  9. home_btn.addEventListener(MouseEvent.CLICK, onHomeClick);
  10. about_mc.addEventListener(MouseEvent.ROLL_OVER, aboutOver);
  11. about_mc.addEventListener(MouseEvent.ROLL_OUT, aboutOut);
  12. next_btn.addEventListener(MouseEvent.CLICK, onNextClick);
  13. prev_btn.addEventListener(MouseEvent.CLICK, onPrevClick);
  14. interact_mc.addEventListener(MouseEvent.ROLL_OVER, interactOver);
  15. interact_mc.addEventListener(MouseEvent.ROLL_OUT, interactOut);
  16. newsevents_mc.addEventListener(MouseEvent.ROLL_OVER, newseventsOver);
  17. newsevents_mc.addEventListener(MouseEvent.ROLL_OUT, newseventsOut);
  18. support_mc.addEventListener(MouseEvent.ROLL_OVER, supportOver);
  19. support_mc.addEventListener(MouseEvent.ROLL_OUT, supportOut);
  20. contact_btn.addEventListener(MouseEvent.CLICK, onContactClick);
  21. send_btn.addEventListener(MouseEvent.CLICK, submit);
  22. supporters_btn.addEventListener(MouseEvent.CLICK, onSupportersClick);
  23. links_btn.addEventListener(MouseEvent.CLICK, onLinksClick);
  24. privacy_btn.addEventListener(MouseEvent.CLICK, onPrivacyClick);
  25. faq_btn.addEventListener(MouseEvent.CLICK, onFAQClick);
  26.  
  27. function onHomeClick(e:MouseEvent):void
  28. {
  29.     gotoAndStop("home");
  30. }
  31.  
  32. function aboutOver(e:MouseEvent):void
  33. {
  34.     e.currentTarget.gotoAndPlay("over");
  35. //    about_mc.addEventListener(MouseEvent.ROLL_OUT, aboutOut);
  36. }
  37.  
  38. function aboutOut(e:MouseEvent):void
  39. {
  40.     e.currentTarget.gotoAndPlay("out");
  41. //    about_mc.enabled = false;
  42. //    about_mc.removeEventListener(MouseEvent.ROLL_OVER, aboutOver);
  43. //    about_mc.removeEventListener(MouseEvent.ROLL_OUT, aboutOut);
  44. //    var myTimer:Timer = new Timer(600,1);
  45. //    myTimer.addEventListener(TimerEvent.TIMER, enableAbout);
  46. //    myTimer.start();
  47. }
  48.  
  49. //function enableAbout(e:TimerEvent):void
  50. //{
  51. //    about_mc.enabled = true;
  52. //    about_mc.addEventListener(MouseEvent.ROLL_OVER, aboutOver);
  53. //}
  54.  
  55. about_mc.dropdownAbout_mc.story_btn.addEventListener(MouseEvent.CLICK, onStoryClick);
  56. about_mc.dropdownAbout_mc.founder_btn.addEventListener(MouseEvent.CLICK, onFounderClick);
  57. about_mc.dropdownAbout_mc.runners_mc.addEventListener(MouseEvent.CLICK, onRunnersClick);
  58.  
  59. function onStoryClick(e:MouseEvent):void
  60. {
  61.     gotoAndStop("story");
  62. }
  63.  
  64. function onFounderClick(e:MouseEvent):void
  65. {
  66.     gotoAndStop("founder");
  67. }
  68.  
  69. function onRunnersClick(e:MouseEvent):void
  70. {
  71.     gotoAndStop("runners");
  72. }
  73.  
  74. function onNextClick(e:MouseEvent):void
  75. {
  76.     gotoAndStop("jeremy");
  77. }
  78.  
  79. function onPrevClick(e:MouseEvent):void
  80. {
  81.     gotoAndStop("runners");
  82. }
  83.  
  84. function interactOver(e:MouseEvent):void
  85. {
  86.     e.currentTarget.gotoAndPlay("over");
  87. //    interact_mc.addEventListener(MouseEvent.ROLL_OUT, interactOut);
  88. }
  89.  
  90. function interactOut(e:MouseEvent):void
  91. {
  92.     e.currentTarget.gotoAndPlay("out");
  93. //    interact_mc.enabled = false;
  94. //    interact_mc.removeEventListener(MouseEvent.ROLL_OVER, interactOver);
  95. ///    interact_mc.removeEventListener(MouseEvent.ROLL_OUT, interactOut);
  96. //    var myTimer:Timer = new Timer(600,1);
  97. //    myTimer.addEventListener(TimerEvent.TIMER, enableInteract);
  98. //    myTimer.start();
  99. }
  100.  
  101. //function enableInteract(e:TimerEvent):void
  102. //{
  103. //    interact_mc.enabled = true;
  104. //    interact_mc.addEventListener(MouseEvent.ROLL_OVER, interactOver);
  105. //}
  106.  
  107. interact_mc.dropdownInteract_mc.blog_btn.addEventListener(MouseEvent.CLICK, onBlogClick);
  108. interact_mc.dropdownInteract_mc.guestbook_btn.addEventListener(MouseEvent.CLICK, onGuestbookClick);
  109. interact_mc.dropdownInteract_mc.messageboard_btn.addEventListener(MouseEvent.CLICK, onMessageboardClick);
  110. interact_mc.dropdownInteract_mc.networking_btn.addEventListener(MouseEvent.CLICK, onNetworkingClick);
  111.  
  112. function onBlogClick(e:MouseEvent):void
  113. {
  114.     gotoAndStop("blog");
  115. }
  116.  
  117. function onGuestbookClick(e:MouseEvent):void
  118. {
  119.     gotoAndStop("guestbook");
  120. }
  121.  
  122. function onMessageboardClick(e:MouseEvent):void
  123. {
  124.     gotoAndStop("messageboard");
  125. }
  126.  
  127. function onNetworkingClick(e:MouseEvent):void
  128. {
  129.     gotoAndStop("networking");
  130. }
  131.  
  132. function newseventsOver(e:MouseEvent):void
  133. {
  134.     e.currentTarget.gotoAndPlay("over");
  135. //    newsevents_mc.addEventListener(MouseEvent.ROLL_OUT, newseventsOut);
  136. }
  137.  
  138. function newseventsOut(e:MouseEvent):void
  139. {
  140.     e.currentTarget.gotoAndPlay("out");
  141. //    newsevents_mc.enabled = false;
  142. //    newsevents_mc.removeEventListener(MouseEvent.ROLL_OVER, newseventsOver);
  143. //    newsevents_mc.removeEventListener(MouseEvent.ROLL_OUT, newseventsOut);
  144. //    var myTimer:Timer = new Timer(600,1);
  145. //    myTimer.addEventListener(TimerEvent.TIMER, enableNewsEvents);
  146. //    myTimer.start();
  147. }
  148.  
  149. //function enableNewsEvents(e:TimerEvent):void
  150. //{
  151. //    newsevents_mc.enabled = true;
  152. //    newsevents_mc.addEventListener(MouseEvent.ROLL_OVER, newseventsOver);
  153. //}
  154.  
  155. newsevents_mc.dropdownNewsEvents_mc.articles_btn.addEventListener(MouseEvent.CLICK, onArticlesClick);
  156. newsevents_mc.dropdownNewsEvents_mc.calendar_btn.addEventListener(MouseEvent.CLICK, onCalendarClick);
  157. newsevents_mc.dropdownNewsEvents_mc.photos_btn.addEventListener(MouseEvent.CLICK, onPhotosClick);
  158. newsevents_mc.dropdownNewsEvents_mc.video_btn.addEventListener(MouseEvent.CLICK, onVideoClick);
  159.  
  160. function onArticlesClick(e:MouseEvent):void
  161. {
  162.     gotoAndStop("articles");
  163. }
  164.  
  165. function onCalendarClick(e:MouseEvent):void
  166. {
  167.     gotoAndStop("calendar");
  168. }
  169.  
  170. function onPhotosClick(e:MouseEvent):void
  171. {
  172.     gotoAndStop("photos");
  173. }
  174.  
  175. function onVideoClick(e:MouseEvent):void
  176. {
  177.     gotoAndStop("video");
  178. }
  179.  
  180. function supportOver(e:MouseEvent):void
  181. {
  182.     e.currentTarget.gotoAndPlay("over");
  183. //    support_mc.addEventListener(MouseEvent.ROLL_OUT, supportOut);
  184. }
  185.  
  186. function supportOut(e:MouseEvent):void
  187. {
  188.     e.currentTarget.gotoAndPlay("out");
  189. //    support_mc.enabled = false;
  190. //    support_mc.removeEventListener(MouseEvent.ROLL_OVER, supportOver);
  191. //    support_mc.removeEventListener(MouseEvent.ROLL_OUT, supportOut);
  192. //    var myTimer:Timer = new Timer(600,1);
  193. //    myTimer.addEventListener(TimerEvent.TIMER, enableSupport);
  194. //    myTimer.start();
  195. }
  196.  
  197. //function enableSupport(e:TimerEvent):void
  198. //{
  199. //    support_mc.enabled = true;
  200. //    support_mc.addEventListener(MouseEvent.ROLL_OVER, supportOver);
  201. //}
  202.  
  203. support_mc.dropdownSupport_mc.donate_btn.addEventListener(MouseEvent.CLICK, onDonateClick);
  204. support_mc.dropdownSupport_mc.membership_btn.addEventListener(MouseEvent.CLICK, onMembershipClick);
  205. support_mc.dropdownSupport_mc.store_btn.addEventListener(MouseEvent.CLICK, onStoreClick);
  206. support_mc.dropdownSupport_mc.volunteer_btn.addEventListener(MouseEvent.CLICK, onVolunteerClick);
  207.  
  208. function onDonateClick(e:MouseEvent):void
  209. {
  210.     gotoAndStop("donate");
  211. }
  212.  
  213. function onMembershipClick(e:MouseEvent):void
  214. {
  215.     gotoAndStop("membership");
  216. }
  217.  
  218. function onStoreClick(e:MouseEvent):void
  219. {
  220.     gotoAndStop("store");
  221. }
  222.  
  223. function onVolunteerClick(e:MouseEvent):void
  224. {
  225.     gotoAndStop("volunteer");
  226. }
  227.  
  228. function onContactClick(e:MouseEvent):void
  229. {
  230.     gotoAndStop("contact");
  231. }
  232.  
  233. function submit(e:MouseEvent):void
  234. {
  235.     var variables:URLVariables = new URLVariables();
  236.     variables.fromname = name_txt.text;
  237.     variables.fromemail = email_txt.text;
  238.     variables.fromsubject = subject_txt.text;
  239.     variables.frommessage = message_txt.text;
  240.  
  241.     var req:URLRequest = new URLRequest("contact.php");
  242.     req.data = variables;
  243.     req.method = URLRequestMethod.POST;
  244.  
  245.     var loader:URLLoader = new URLLoader();
  246.     loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  247.     loader.addEventListener(Event.COMPLETE, sent);
  248.     loader.addEventListener(IOErrorEvent.IO_ERROR, error);
  249.     loader.load(req);
  250.     status_txt.text = "Sending...";
  251. }
  252.  
  253. function sent(e:Event):void
  254. {
  255.     status_txt.text = "Your email has been sent.";
  256.     name_txt.text = "";
  257.     email_txt.text = "";
  258.     subject_txt.text = "";
  259.     message_txt.text = "";
  260. }
  261.  
  262. function error(e:IOErrorEvent):void
  263. {
  264.     status_txt.text = "Error - please try again later.";
  265. }
  266. /**
  267. var variables:URLVariables = new URLVariables();
  268. var req:URLRequest = new URLRequest("contact.php");
  269. var loader:URLLoader = new URLLoader;
  270. req.method = URLRequestMethod.POST;
  271. req.data = variables; 
  272.  
  273. send_btn.addEventListener("click", submit)
  274.  
  275. function submit(e:MouseEvent):void
  276.     variables.fromname = name_txt.text;
  277.     variables.fromemail = email_txt.text;
  278.     variables.fromsubject = subject_txt.text;
  279.     variables.frommessage = message_txt.text;
  280.     loader.load(req);
  281.  
  282.      //these next 4 lines are optional. I use them 
  283.      //to clear out the textfields once the message is sent
  284. //     firstName.text = "";
  285. //     email.text = "";
  286.  //    emailCT.text = "";
  287.   //   messg.text = "";
  288. }**/
  289.  
  290. function onSupportersClick(e:MouseEvent):void
  291. {
  292.     gotoAndStop("supporters");
  293. }
  294.  
  295. function onLinksClick(e:MouseEvent):void
  296. {
  297.     gotoAndStop("links");
  298. }
  299.  
  300. function onPrivacyClick(e:MouseEvent):void
  301. {
  302.     gotoAndStop("privacy");
  303. }
  304.  
  305. function onFAQClick(e:MouseEvent):void
  306. {
  307.     gotoAndStop("faq");
  308. }
Jul 6 '09 #1
1 3509
serdar
88
Little bit of a long code to read here, so add some trace calls within your code to detect which line causes the null reference error.

Don't you see a line number in the error mesage?
Jul 13 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.