PDA

View Full Version : Flash Code Help



TiharO
March 23rd, 2010, 12:54 PM
I am making a custom cursor flash. In each frame there is a different crusor. I got the code that make the real cursor dissapear and my custom one follow the mouse. Im try to create some code that knows when I click and geos to the next frame and stop there so the custom cursor can be viewed. I need help creating the code to do that.

Thanks,
TiharO

beezleboss
March 23rd, 2010, 01:07 PM
So you want to move onto the next frame of the custom cursor movie clip when the user clicks?

If so, it's quite simple:



stage.addEventListener(MouseEvent.CLICK, mseClk);

function mseClk(e:MouseEvent):void
{
cursorMovieClipName.gotoAndStop(cursorMovieClipNam e.currentFrame + 1);
}


Replace 'cursorMovieClipName' with the instance name of the cursor movie clip.

TiharO
March 23rd, 2010, 01:20 PM
[AS]
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE,follo w);
function follow(evt:MouseEvent){
cursor.x = mouseX;
cursor.y = mouseY;
function mseClk(evt:MouseEvent):void
{
cursorMovieClipName.gotoAndStop(cursor.currentFram e + 1);
}}
[AS/]
This is the code I have but for some reason it doesn't work.

Description: 1021: Duplicate function definition.
Source: function follow(evt:MouseEvent){
im confuzzeld

beezleboss
March 23rd, 2010, 01:29 PM
try this:



Mouse.hide();

stage.addEventListener(MouseEvent.MOUSE_MOVE, follow);
stage.addEventListener(MouseEvent.CLICK, mseClk);

function follow(evt:MouseEvent)
{
cursor.x = mouseX;
cursor.y = mouseY;
}

function mseClk(evt:MouseEvent):void
{
cursor.gotoAndStop(cursor.currentFrame + 1);
}


See if that works (sorry, I'm not a PC with Flash installed so I'm doing it off the top of my head)

Also, if this does work it'll eventually reach the end of the timeline inside the movie clip so you'll need to loop it.

TiharO
March 23rd, 2010, 01:37 PM
It still doesn't work:anger:. I put the code on every frame.

Description: 1021: Duplicate function definition.

Source: function follow(evt:MouseEvent)

beezleboss
March 23rd, 2010, 01:42 PM
I put the code on every frame.


Description: 1021: Duplicate function definition.

That's sort of self explanatory


Source: function follow(evt:MouseEvent)

I think it's a problem with something you did previously.

Try and get a grasp on some actionscript basics cos it'll really help in the long run :)