PDA

View Full Version : Need help transferring code...


LePsycho
11-18-2008, 01:08 PM
Hi, I've got a portfolio prototype I'm making, and have found out I need to have seperate .as files for all the actionscript whereas in my portfolio I wrote all the AS on the timeline on an actions layer.

I tried making a new .as file and copy pasting the code to it, deleting the old code bar for a stop(); then linking the .as to the page through the properties tab, but it came up with a bunch of errors in the .as file when I ran it about accessing undefined movie clips etc.

What have I done wrong this time? :p

Any help, or even a step by step guide, would be appreciated!

POV
11-18-2008, 01:26 PM
Hi, creating a class is not that easy :rolleyes: Please read some beginner tutorials for AS3.

Brucebannor
11-18-2008, 01:27 PM
Hi a simple copy and paste won't due here, you need to include a package, class, etc..


package
{
// Imports Go Here //
public class Main extends MovieClip // or Sprite
{
// Variables Go Here //
public function Main()
{
// Name your document Class "Main" in Flash //
// This function will fire first //
}

// Other Functions Go Here //
}
}

POV
11-18-2008, 01:27 PM
Didn't read it but the subject seems right:
http://www.actionscript.org/resources/articles/698/1/Make-your-own-reusable-classes-using-Flash-and-AS3/Page1.html