I apologize for the elementary problem here. I haven’t touched AS3 since around Christmas and I’m drawing huge blanks trying to get back to where I was (which admittedly was not very advanced at all. Still just a beginner). I was hoping someone would kick me in the *** and help me see why I’m a giant idiot here.
Anyway, just making a very simple movie. There will be an image on the stage. When the user moves the cursor over it, I want to display the x and y coordinates of the cursor. Simple, right?
I created a quick movie, through the image on the stage, and wrote this quick code, which I thought would work. Clearly it did not. Could someone give me a hand?
package {
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
public class Script extends Sprite {
private var textfield:TextField=new TextField;
stage.addEventListener(Event.ENTER_FRAME, coordinates);
private function coordinates(e:Event):void {
if (content_mc.hitTestPoint(mouseX,mouseY,true)) {
addChild(textfield);
textfield.x = 500;
textfield.y = 480;
textfield.autoSize = TextFieldAutoSize.LEFT
textfield.text="Your coordinates are: " mouseX, mouseY;
}
}
}
}