Copy link to clipboard
Copied
I am currently developing a game in a school project using Flash CS4 and Actionscript 3.0. I have searched the web for assistance, but have come up empty. Here is what I am wanting to do...
I have a 3 by 3 grid on screen. Each block in the grid contains a movie clip with four targets which cycle through at 24 fps. Each target with have a different outcome depending on which frame the mouse is clicked. I do not want the animation to stop after the frame is clicked, however. There are several different types of targets in the game. Some add points, some subtract points, one target has the avility to freeze the animations for a set period, and another one is basically an instant game over. Being as how I could not find any aid via the web prior to this post, I am not even positive that this is possible to code in AS3.0. Does anyone know if this is possible, and if so, how would I go about coding it? Any assitance would be great!
//if you positioned all your target already on stage, be sure you named them all, skip the next 2 lines and
var target:Target = new Target();
target.name = "target1";
getChildByName("target1").addEventListener(MouseEvent.CLICK, clickHandler);
getChildByName("target2").addEventListener(MouseEvent.CLICK, clickHandler);
....
function clickHandler(e:MouseEvent):void{
trace(e.currentTarget.name);
// results possibly in "target1"
trace(MovieClip(e.currentTarget).currentFrame);
// results in wh
...Copy link to clipboard
Copied
//if you positioned all your target already on stage, be sure you named them all, skip the next 2 lines and
var target:Target = new Target();
target.name = "target1";
getChildByName("target1").addEventListener(MouseEvent.CLICK, clickHandler);
getChildByName("target2").addEventListener(MouseEvent.CLICK, clickHandler);
....
function clickHandler(e:MouseEvent):void{
trace(e.currentTarget.name);
// results possibly in "target1"
trace(MovieClip(e.currentTarget).currentFrame);
// results in whatever framenumber the animation of the clicked MovieClip is during the click
}
Based on this clickHandler you can easily write other code that deals with the results
Copy link to clipboard
Copied
Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now