Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am using actionscript 3 and I have used an external actionscript file (.as) for my game.

I would like the external actionscript file to be played at frame 2 (instead of frame 1, as it is an introductory page of the game) on the timeline.

How do I do that? I have been trying and looking for answers for hours, appreciate if you can help on this. Many thanks in advance!

share|improve this question

1 Answer 1

I'm assuming you're using the Flash IDE?

If your file isn't an Actionscript class, just use the include statement. Eg. on frame 2, write:

include "myFile.as";

If you're using classes, there's an option in the Actionscript-3 settings, where you can specify a frame where classes should be imported to. So if your class is MyClass, just call something like this on frame 2:

var myInstance = new MyClass();

Maybe you'll even want a combination of the above.. eg. export all classes to frame 2 and also include an initialization script on frame 2.

share|improve this answer
    
thanks for ur reply! I have tried your second method, my file name is color_match so is it right that the code is var MyInstance = new color_match(); ? But I got an error msg: Error: Error #2136: The SWF file contains invalid data. at color_match/frame2() what should I do? Thanks. –  Nail Dec 24 '12 at 5:56
    
@Nail How does your color_match file look like? Does it purely contain a class definition? Where is it located? Did you set the source-path in the actionscript properties? –  bummzack Dec 26 '12 at 10:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.