Saturday, September 29, 2018

Custom cursor in AS3

ad300
Advertisement





Custom cursor this time will be in Actionscript 3.0. The steps are similar, only the code needs to be changed. The rest of the tutorial is pretty much the same as the previous one.

Custom cursor using the timeline

Step 1

Open a new Flash document.
Create your custom cursor object on the stage. But you can create whatever object you wish.
Step 2
Convert your object into a symbol by pressing F8. Then give your symbol an appropriate name, check movie clip for the type and click ok.
**Note the registration point is where your custom cursor point will begin. I have selected the centre point for my cursor, but you will probably need to select the top left point for your cursor.
Step 3
Give your custom cursor the instance name: customcursor_mc.
Step 4
On the timeline insert a new layer called “Actions” like below:




Right click on the first frame and select Actions and add the following code:

Mouse.hide();
customcursor_mc.startDrag(true);

**The first line of code hides the default cursor. While the second line of code make the custom cursor follow the hidden default cursor.

If you run into any problems with the code above use the following code below.


stage.addEventListener(Event.ENTER_FRAME, moveCursor);

function moveCursor(event:Event) {
customcursor_mc.x=mouseX;
customcursor_mc.y=mouseY;
}

Step 5

Test your custom cursor Ctrl + Enter.


Share This
Previous Post
Next Post

Pellentesque vitae lectus in mauris sollicitudin ornare sit amet eget ligula. Donec pharetra, arcu eu consectetur semper, est nulla sodales risus, vel efficitur orci justo quis tellus. Phasellus sit amet est pharetra

0 comments:

Ad Section2

Sponsor

Ad Section