Skip to main content
Participating Frequently
April 13, 2014
Question

Action script 3.0 output error please help flash pro

  • April 13, 2014
  • 1 reply
  • 614 views

So, I am creating a type effect animation in flash and my code for the first frame in my time line is;

  1. var i=0;
  2. var myString:String = "Name: Earth\nDiameter: 12,756 km"
  3. var mytimer:Timer = new Timer(200,myString.length);
  4. mytimer.addEventListener(TimerEvent.TIMER, timerHandler);
  5. mytimer.start();
  6. function timerHandler(event:TimerEvent):void{
  7.           mytext.appendText (myString.charAt(i));
  8.           i++;
  9.           if (i==myString.length && currentFrame == 1){ gotoAndStop(10)}
  10. }

My second code on the next frame is essentailly the same thing but becuase i cannot place a var again I have taken them out and put code that refs the first code;

  1. i=0;
  2. mytext.text = ""; // empty the textfield
  3. myString = "Name: Neptune\nDiameter: 49,532 km";
  4. mytimer.repeatCount = myString.length;
  5. mytimer.reset();
  6. mytimer.start();

My animation still works correctly as I wanted however if i then place the above code on another frame at time line i receive an output error code refusing it to show the third frame;

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at Animation_fla::MainTimeline/timerHandler()

          at flash.utils::Timer/_timerDispatch()

          at flash.utils::Timer/tick()

What does this mean can someone explain it to me please and how I would fix ti?

Thanks

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 13, 2014

Are you extending the layer that has the function for the length of the timeline like I showed in the example file I made for you?  I put the code for the other frames on a separate layer to make sure that the one being shared is not cut short.

I think I also already mentioned that you should go into the Flash Publish Settings and select the option to Permit Debugging so that the error message indicates which line of code is causing the problem.

Participating Frequently
April 13, 2014

Hi,

I have used the example file as a guide to place it in my animation.

It says that line 9 in the first frame has an error which is; mytext.appendText (myString.charAt(i));

Ned Murphy
Legend
April 13, 2014

USe the trace function in that frame to see which object is coming up null...

trace("mytext: " + mytext);

trace("myString: " + myString);