-
TypeError: Error #1009?
Alright so I'm working on making a skill calculator for this a game. This one I am working on right now has multiple skill calculators in a single flash file, but for some reason that I can't figure out, the skill calculator won't actually calculate. Here is a pastebin length to the AS code
http://pastebin.com/xB6xzJFd
Alright, I apoligize for its length, but I really have no idea what I'm doing wrong with this one. Here is the output:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at allInOneCalc_fla::MainTimeline/changeCalc()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::ComboBox/onListChange()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::SelectableList/handleCellRendererClick()
I get that error the second I select a calc and it goes to that frame, and when I input all the information it gives me a "0 and whatever text I had it add" for the answer. Please help, I've been stuck on this for a while.
EDIT: I Believe I did the wrong type of event for lines 22, 25 but I'm still not sure with what type of event I should use. Any advice is greatly appreciated
Last edited by braskez; 05-02-2012 at 03:51 PM.
-
I'm gonna come right out and say it: Ever heard of arrays and loops?
Now that that's done with, are you developing in Flash CS3/4/5 (doesn't matter). If you are, have you tried running this in debug mode (ctrl + shift + enter)? If you haven't, do that and replicate the error. It will tell you the exact line that this error is occurring at. Then maybe you can figure out why whatever variable it's using is null.
-
Yeah, I started messing around with flash like a week and a half ago, so I don't really know what I'm doing. I'm doing it with CS5.5 and debug mode says line 10 which is different since the code changed since I added a loading bar. Here is a code snippet.
Actionscript Code:
function loading(e:Event):void{ var total:Number = this.stage.loaderInfo.bytesTotal; var loaded:Number = this.stage.loaderInfo.bytesLoaded; bar_mc.scaleX = loaded/total; loader_txt.text = Math.floor((loaded/total)*100)+ "%"; if (total == loaded){gotoAndStop(2); startCalc();} } function startCalc():void{ skillPicker.addItem( { label: "Select A Calc" } ); skillPicker.addItem( { label: "Smithing Calc" } ); skillPicker.addItem( { label: "Combat Calc" } ); skillPicker.addItem( { label: "Mining Calc" } ); skillPicker.addItem( { label: "Woodcutting Calc" } ); skillPicker.addEventListener(Event.CHANGE, changeCalc); }
This is line 10 specifically:
Actionscript Code:
bar_mc.scaleX = loaded/total;
I am also getting this error contiuously repeating since I added the loading bar.
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at allInOneCalc_fla::MainTimeline/loading()
Anything I'm doing wrong or even unnecessary would be awesome if you pointed it out to me. I'm still trying to learn and this is the first object styled coding language I've ever tried to learn. I am still not sure of the problem.
Last edited by braskez; 04-27-2012 at 01:11 PM.
-
Dignitary
Not sure theres enough code there to see where the root of the problem is
-
Alright I'll make a new pastebin of it. Here is the link:
http://pastebin.com/xB6xzJFd
Last edited by braskez; 05-02-2012 at 03:50 PM.
-
Dignitary
Your problem is in this function:
Code:
31.function changeCalc(event:Event):void{
32. if (skillPicker.selectedItem.label == "Smithing Calc"){
33. gotoAndStop(3);
34. setSmith();
35. calcSelectButton.addEventListener(MouseEvent.CLICK, goBack);
36. CurrExp.restrict="0-9";
37. DesLvl.restrict="0-9";
38. finalResults.restrict="";
39. calcButtonSmith.label = "CALCULATE";
40. calcButtonSmith.addEventListener(MouseEvent.CLICK, calculateSmith);
41. calcSelectButton.label = "<BACK<";};
42. if (skillPicker.selectedItem.label == "Combat Calc"){
43. gotoAndStop(4);
44. setCombat();
45. calcSelectButton.addEventListener(MouseEvent.CLICK, goBack);
46. CurrExp.restrict="0-9";
47. DesLvl.restrict="0-9";
48. finalResults.restrict="";
49. calcButtonCombat.label = "CALCULATE";
50. calcButtonCombat.addEventListener(MouseEvent.CLICK, calculateCombat);
51. calcSelectButton.label = "<BACK<";
52. };
53. if (skillPicker.selectedItem.label == "Mining Calc"){
54. gotoAndStop(5);
55. setMining();
56. calcSelectButton.addEventListener(MouseEvent.CLICK, goBack);
57. CurrExp.restrict="0-9";
58. DesLvl.restrict="0-9";
59. finalResults.restrict="";
60. calcButtonMining.label = "CALCULATE";
61. calcButtonMining.addEventListener(MouseEvent.CLICK, calculateMining);
62. calcSelectButton.label = "<BACK<";
63. };
64. if (skillPicker.selectedItem.label == "Woodcutting Calc"){
65. gotoAndStop(6);
66. setWcing();
67. calcSelectButton.addEventListener(MouseEvent.CLICK, goBack);
68. CurrExp.restrict="0-9";
69. DesLvl.restrict="0-9";
70. finalResults.restrict="";
71. calcButtonWcing.label = "CALCULATE";
72. calcButtonWcing.addEventListener(MouseEvent.CLICK, calculateWcing);
73. calcSelectButton.label = "<BACK<";
74. };
75.}
One of the objects in that code does not exist. I assume on the stage somewhere.
-
rynoe, I send you a pm with the .fla file in it, please take a look. Thanks.
-
You can run it in debug mode, cause the error, and when the program stops and shows you the line, go to Window -> Debug Panels -> Variables. This shows you all the variables and their values. You can check which variable in that line is null through the Variables window.
-
It says that bar_mc is null, and a whole bunch others, yet bar_mc since I defined it as an instance on my stage. Am I misunderstanding how I should do this?
Here are some of the variables said to be nulled defined right here:
http://puu.sh/rXlO
http://puu.sh/rXku
Yet, they are still null:
http://puu.sh/rXp4
Also certain variables I am not even using are nulled, such as the first 2 in that last screenshot. It would be much appreciated if someone could explain to me what I am doing wrong and what I don't understand about variables. Thanks.
EDIT: I noticed the pastebin link is down, here is a reupload:
http://pastebin.com/xB6xzJFd
Last edited by braskez; 05-02-2012 at 03:51 PM.
-
-
Dignitary
900+ lines of code, mostly adding data...
hmmm
XML would be useful here is my first reaction. You may not be ready for that.
-
Well I'm quite familiar to HTML and CSS. I know that XML is supposed to be similar. I'm not sure if that would fix my problem but if it would I'm definitely open to it.
-
Would that allow me to change the content in the calc without recompiling also? If I did XML I mean.
-
Dignitary
Originally Posted by braskez
Would that allow me to change the content in the calc without recompiling also? If I did XML I mean.
Yes, the content would be dynamic.
-
How would you suggest I get started?
Last edited by braskez; 05-03-2012 at 04:53 PM.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|