Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 05-12-2012, 12:22 AM   #1
TheMrKiko
Member
 
Join Date: Feb 2012
Location: I´m bad at English...
Posts: 84
Question Error in Timer

Hi,
I have a problem with the following code:
ActionScript Code:
var myTimer:Timer = new Timer(100); myTimer.addEventListener(TimerEvent.TIMER, correr); myTimer.start(); function correr(event:TimerEvent):void{ stope.addEventListener(MouseEvent.CLICK, parar); } function parar(Event:MouseEvent):void{ myTimer.stop() rea1.text = (getTimer() + " ms"); }
It's suposed to start a timer that stops when I press the 'stope' button and display that time (after stoped) in the text box 'rea1'. But that doesn't happen and the following text keeps repeating many times when I enter the frame:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at MyGame_fla::MainTimeline/correr()
	at flash.utils::Timer/_timerDispatch()
	at flash.utils::Timer/tick()
Could someone help me please?
Thanks
TheMrKiko is offline  
Old 05-12-2012, 03:04 AM   #2
svenjoypro
DontJustEnjoyIt,SvEnjoyIt
 
svenjoypro's Avatar
 
Join Date: Sep 2005
Location: California
Posts: 1,388
Default

My guess would be that rea1 is either spelled incorrectly, or it isn't on the stage on the keyframe where the code is.

You can go to File->Publish Settings->Actionscript then check the 'Permit Debugging' check box (near the bottom) and then re-run the program and it will tell you which line is causing the error.

Hope that helps
svenjoypro is offline  
Old 05-12-2012, 01:27 PM   #3
TheMrKiko
Member
 
Join Date: Feb 2012
Location: I´m bad at English...
Posts: 84
Default

Quote:
Originally Posted by svenjoypro View Post
My guess would be that rea1 is either spelled incorrectly, or it isn't on the stage on the keyframe where the code is.

You can go to File->Publish Settings->Actionscript then check the 'Permit Debugging' check box (near the bottom) and then re-run the program and it will tell you which line is causing the error.

Hope that helps
I debug that and the line that is causing the error is
Code:
stope.addEventListener(MouseEvent.CLICK, parar);
But I cheked the button and exists with that name and the function is ok.
Help me!
TheMrKiko is offline  
Old 05-12-2012, 02:07 PM   #4
svenjoypro
DontJustEnjoyIt,SvEnjoyIt
 
svenjoypro's Avatar
 
Join Date: Sep 2005
Location: California
Posts: 1,388
Default

You can send me the fla. My email is my username at gmail
svenjoypro is offline  
Old 05-12-2012, 02:19 PM   #5
TheMrKiko
Member
 
Join Date: Feb 2012
Location: I´m bad at English...
Posts: 84
Default

Quote:
Originally Posted by svenjoypro View Post
You can send me the fla. My email is my username at gmail
I think I found the solution. The Button must be on the same layer of the text box. But thank you for the help.

Last edited by TheMrKiko; 05-12-2012 at 02:36 PM.
TheMrKiko is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:00 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.