Hi,
Last night, for first time decided to start using Classes to add my code instead of adding it directly in Flash and I really thought I knew how to handle this since I have created some re-usable classes before where you target an object by passing parameter etc, but for some reason I’m a little confused.
For instance I thought that if I had one function (method) in my class and I wanted to call it from my .fla file all I needed to do was to create an instance of the class and then call my method.
Something like this:
Class
package apps.calculator{
import com.greensock.*;
import flash.display.*;
public class Sample extends MovieClip {
// recMc is on the stage in my .FLA file
recMc.addEventListener(MouseEvent.CLICK, moveIt,false,0,true);
public function Sample():void {
trace("This is the constructor");
}
public function moveIt(event:MouseEvent):void {
recMc.x = 500;
}
}
}
.FLA file:
import apps.calculator.*;
var moveMc: Sample = new Sample();
moveMc.moveIt();
But this doesn’t work I get a message that says that it is missing arguments.
Can someone be so kind and give me some advice on how to use my code directly on a class and what are the differences of doing this versus putting the code directly on my .fla file and if it’s even a good practice to do this?
Thanks a lot!