Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Action script 3.0 output error please help flash pro

New Here ,
Apr 13, 2014 Apr 13, 2014

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

TOPICS
ActionScript
531
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2014 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2014 Apr 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));

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2014 Apr 13, 2014

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

trace("mytext: " + mytext);

trace("myString: " + myString);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2014 Apr 13, 2014

I get this on the first frame;

mytext: [object TextField]

myString: Name: Earth

Diameter: 12,756 km

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 13, 2014 Apr 13, 2014
LATEST

What about the frame where the error occurs?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines