PDA

View Full Version : Mouse Effects Using Your Computers Built In Cursor


orange gold
01-26-2009, 09:44 PM
ok... this challenge is to get little snipes of code that just messa round with the built in mouse...

for example...
make your mouse blink between mouse show and mouse hide to make a blinking effect, or get a half see through mouse, what ever you can think off!!!!!!

rules...

actionscript 2
code only
have fun!




snipets code showcase:

(the best code snipets written will go here next to the user who created them)

orange gold
01-26-2009, 09:57 PM
well i tried sumthing like this but its not working... it willnt even trace my interval ... any ideas???

code:


show2 = 1
_root.onEnterFrame = function() {
myTimer = setInterval(wait, 2000);
myTimer2 = setInterval(wait2, 2000);
if (show2 == 1) {
Mouse.hide();
function wait() {
show2 = 2
}
}
if (show2 == 2) {
Mouse.show();
function wait2() {
show2 = 1
}
}
trace(myTimer)
trace(myTimer2)
}

orange gold
01-26-2009, 10:04 PM
ok i just modified it through variables instead of setinterval blah blah blah!

lol

here it is!!!

my code snippet #1 (blinking mouse with adjustable speed)

p.s. set the mouseblinkspeed = to about 2.001 at fps 120 and you almost get my 50% alpha mouse


mouseblinkspeed = 30 // speed that the mouse blinks at
show2 = 1
myTimer = 1
myTimer2 = 1
_root.onEnterFrame = function() {
myTimer = myTimer + 1
myTimer2 = myTimer2 + 1
if (show2 == 1) {
Mouse.hide();
if (myTimer >= mouseblinkspeed) {
show2 = 2
myTimer = 1
myTimer2 = 1
}
}
if (show2 == 2) {
Mouse.show();
if (myTimer2 >= mouseblinkspeed) {
show2 = 1
myTimer = 1
myTimer2 = 1
}
}
}

xxneon
02-11-2009, 09:01 PM
with this it will change the mouse cursor from arrow to hand cursor to arrow .. and keep doing that on a set interval.. but the only thing i noticed is it only works when you move the mouse.. if the mouse is stationary it stops alternating.. I am thinking there is no way around this since the same behavior happens when you disable a buttons actions when you click
var toggle_int:Number;
var interval_speed = .5; //seconds

MovieClip.prototype.drawRect = function(x,y,w,h,c,a){
this.moveTo(x,y);
this.beginFill(c,a);
this.lineTo(x+w,y);
this.lineTo(x+w,y+h);
this.lineTo(x,y+h);
this.lineTo(x,y);
this.endFill();
}

function toggleHandCursor(toggle:Boolean){
if(toggle == true){
this.createEmptyMovieClip("hit_area",this.getNextHighestDepth());
hit_area.drawRect(0,0,1,1,0,0);
hit_area.onRollOver = function(){};
onMouseMove();
}else{
hit_area.removeMovieClip();
}
updateAfterEvent();
intervalToggle(!toggle);
}

function onMouseMove(){
hit_area._x = _xmouse-hit_area._width/2;
hit_area._y = _ymouse-hit_area._height/2;
updateAfterEvent();
}

function intervalToggle(_toggle:Boolean){
clearInterval(toggle_int);
toggle_int = setInterval(this,"toggleHandCursor",interval_speed*1000,_toggle);
}

intervalToggle(true);

xxneon
02-12-2009, 01:57 PM
got it .. once the mouse has focus .. it will make the mouse change now..

the difference with this version though is it only creates 1 hit area clip.. and then just positions it off stage so that the roll out behaviour is called.. making the mouse revert back to the arrow..
var toggle_int:Number;
var interval_speed = .5; //seconds

MovieClip.prototype.drawRect = function(x,y,w,h,c,a){
this.moveTo(x,y);
this.beginFill(c,a);
this.lineTo(x+w,y);
this.lineTo(x+w,y+h);
this.lineTo(x,y+h);
this.lineTo(x,y);
this.endFill();
}

function toggleHandCursor(toggle:Boolean){
if(toggle == true){
hit_area.onRollOver = function(){};
onMouseMove = move;
onMouseMove();
}else{
hit_area._x = -50;
delete onMouseMove;
}
updateAfterEvent();
intervalToggle(!toggle);
}

function move(){
hit_area._x = _xmouse-hit_area._width/2;
hit_area._y = _ymouse-hit_area._height/2;
updateAfterEvent();
}

function intervalToggle(_toggle:Boolean){
clearInterval(toggle_int);
toggle_int = setInterval(this,"toggleHandCursor",interval_speed*1000,_toggle);
}

this.createEmptyMovieClip("hit_area",this.getNextHighestDepth());
hit_area.drawRect(0,0,1,1,0,0);
intervalToggle(true);

orange gold
03-09-2009, 08:47 PM
ohhh i like this code hehe
keep up the good work