-
Can't seem to call my class right
I'm trying to make a class that when activated in the main timeline it'll just trace a function constantly when it starts and then trace one on mouse up and on mouse down.
I put it in the main timeline like so:
var Target_this:targeting = new targeting();
then call it in an if statement over here which is in event.ENTER_FRAME:
if(targeting_init && player.hitTestPoint(mouseX, mouseY)){
//add new event listeners
//calling the targeting function in the external script
Target_this.target_main();
//change the player to display targeting mode
player.gotoAndStop(2);
//now remove the old ones, remember to add these back
removeEventListener(Event.ENTER_FRAME, main);
removeEventListener(MouseEvent.MOUSE_DOWN, mouse_down);
removeEventListener(MouseEvent.MOUSE_UP, mouse_up);
//reset the system here
targeting_counter = 0;
start_targeting_counter = false;
}
but it doesn't activate any of the event listeners and it only calls it once but if I try and make the target_main an event.enter_frame it won't recognize it.
What am I doing wrong? I attached all the code of my class under this. I'm really stumped.
Code:
package{
//This is always used as the stage is like one big movie clip
import flash.display.MovieClip;
//Click on the event in the addeventlistener to find what you have to import and now ou can pull everything from that class into this script. It brings in the preexisting class.s
import flash.events.Event;
import flash.events.MouseEvent;
//We're extending the movieclip class because we're adding functionality to it
public class targeting extends MovieClip{
//put all your variables and junk here, event listeners too
//addEventListener(Event.ENTER_FRAME, target_main);
public function target_main():void{
addEventListener(MouseEvent.MOUSE_DOWN, target_mouse_down);
addEventListener(MouseEvent.MOUSE_UP, target_mouse_up);
trace("Mah nuts!");
}
public function target_mouse_down(MouseEvent:Event):void{
trace("Mouse Down");
}
public function target_mouse_up(MouseEvent:Event):void{
trace("Mouse UP!");
}
}
}
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|