PDA

View Full Version : help with flash as3



wdaniel
03-06-2009, 10:17 PM
hello
i need some help with as3

this file works the way i want it to, but the output box flips out. please take a look.

please help thanks.

w............

wdaniel
03-07-2009, 05:15 PM
can you see the output window in the html page. the problem is that the output window in flash has some weird errors, but it seems to work ok. but as requested i added the html file to the above zip, even though you can't see the problem.

thanks

w............

wdaniel
03-08-2009, 07:35 PM
someone please.

wdaniel
03-09-2009, 01:37 PM
Anyone have any ideas. please help.

JonO
03-11-2009, 04:45 PM
"this file works the way i want it to, but the output box flips out"

Are you referring to the Flash player error that reads:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at goodtest_fla::MainTimeline/update()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

Or is there some other problem you're seeing?

wdaniel
03-11-2009, 07:15 PM
yes

that error just keeps repeating in the output panel.

JonO
03-11-2009, 09:07 PM
Looking at the error window is the first place to start:

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

From the first line you can tell that somewhere in your code you are trying to access a property or method of a null object. The next line tells you where in the code the error occurred - in this case the udpate() function.

Looking at that function the only objects that could possibly be null are txtHrs, txtMins, and txtSecs. Running the program in debug mode confirms this:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at goodtest_fla::MainTimeline/update()[goodtest_fla.MainTimeline::frame1:108]

The debug error output gives you one really key piece of info - the line number where the error occurred. Line 108 in your code is:

txtHrs.text = String(hr);

so txtHrs must be a null object.

Also if you look in the variables box at the left side of the screen and expand the "this" branch to see all the current variables you'll see that txtHrs, txtMins, and txtSecs are all listed as being null.

Now you know what the error means, an easy fix is to place a conditional statement around any code that accesses those objects to ensure they are instantiated (i.e. not null) before trying to access their properties and methods:

Before line 108 add "if (txtHrs && txtMins && txtSecs) {"
and close the conditional by adding "}" to line 137 (the line after "txtSecs.appendText(String(sec));")

This will prevent any of the code that references the txtHrs, txtMins, and txtSecs objects from executing before those objects are instantiated.

Cheers,
Jon

wdaniel
03-13-2009, 08:18 AM
yes thank you i figured it out , i will post an example of my project later so you can see it.

w............