Is there anyway to access variables or methods in actionscript in the timeline from a class?
I am new to CS3 and started developing with the meat of my code in the timeline. After creating a class and some instances of it, I’ve found that I can’t access methods that I’ve declared in the timeline.
I’ve seen posts that say create a new .as file and to put that filename in the Document Class field on the properties tab of the .fla file. Then put your code in there. I tried putting some code in that .as file but when I published it, there was an error about the .swf containing invalid data.
After looking around some more, I found that you get that error if you have a Docuement Class defined and you have code in the timeline.
I tried to put ALL the code that was in the timeline into the class that I had Document Class referring to. I called the class Main. When I tried to run it, I got an error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
I deleted code from the end toward the top until I finally deleted the following line of code and it compiled with no error:
var dt:DistortionTweener = new DistortionTweener(s, clip_mc, new Point(0, 0), new Point(clip_mc.width, 0), new Point(clip_mc.width, clip_mc.height), new Point(0, clip_mc.height), 5);
I’ve imported the Distortion tweener class right after the start of the package:
I think the error that I was getting was because the instance of the DistortionTweener that I create passes an argument (the second one) of a movieclip that exists on the stage called clip_mc. Perhaps it doesn’t have access to it yet?
It worked when the code was on the timeline but now it doesn’t since I’ve moved it into the Document Class.
Oh, this AS3 is killing me! Please help!