Sounds




Here i will show you how to make a cursor in flash (AS2 and AS3).

Navigation


Getting started

Making a cursor in flash is very easy. There are only small differences between AS2  and AS3. We need only a MovieClip for the cursor and some code.


AS2

Drag and drop the cursor MovieClip on the timeline (it has to be on all frames!).  This is the class of the cursor:
public class _cursor extends MovieClip{
    public function onEnterFrame(){
        _x = _root._xmouse;
        _y = _root._ymouse;
        swapDepths(_root.getNextHighestDepth());
    }
}
Somewhere in the maintimeline:
Mouse.hide(); }
Now you have your own cursor in AS2.


AS3

Now, AS2 vas very easy. Making it in AS3 is a little bit different.
package{
    import flash.display.MovieClip;
    import flash.events.Event;
    public class _cursor extends MovieClip{
        public function _cursor():void{
            if(stage){
                this.init();
            }else{
                addEventListener(Event.ADDED_TO_STAGE, this.init);
            }
            return;
        }
        private function init(e:Event=null):void{
            Mouse.hide();
            if(e!=null){
                removeEventListener(Event.ADDED_TO_STAGE, this.init);
            }
            addEventListener(Event.ENTER_FRAME, this.update);
            return;
        }
        private function update(e:Event):void{
             this.x = stage.mouseX+2;
             this.y = stage.mouseY+2;
        }
    }
}
Now you need only to add the cursor to the game (It should be the highest layer!).