Rollover vibration effect help!

Hi there,

I’ve been using flash for about a week now and have been sifting through online tutorials to get me up to speed and I’m really loving it.

As a noob to action script iv kind of jit a brick wall. Theres a tutorial on the site for making something vibrate, say a button, but i want to initiate this effect when someone rolls over it. I have the code for the vibration and iv looked up the code for rollover but i cant seem to get them to work with each other.

Here’s the code for the vibrating effect…

onClipEvent (load) {
//movie width/height
height = 200;
width = 300;
//------------------------//
//makes everything random //
//------------------------//
this._x = Math.round(Math.random()*width);
this._y = Math.round(Math.random()*height);
var temp = this._alpha=Math.random()*100;
this._xscale = this._yscale=temp;
//setting initiaion position
cx = this._x;
cy = this._y;
}
onClipEvent (enterFrame) {
//causes the object to be offset
this._x = cx+(1+Math.random()*5);
this._y = cy+(1+Math.random()*5);
}

Any help would be amazing :slight_smile:

Thanks for your time :thumb2:

Luke

 
//movie width/height
height = 200;
width = 300;
//------------------------//
//makes everything random //
//------------------------//
with(mc) {
    _x = Math.round(Math.random()*width);
    _y = Math.round(Math.random()*height);
    _xscale = _yscale= _alpha = Math.random()*100;
    //setting initiaion position
    cx = _x;
    cy = _y;
}
mc.onRollOver = function() {
    mc.onEnterFrame = function() {
        //causes the object to be offset
    this._x = cx+(1+Math.random()*5);
    this._y = cy+(1+Math.random()*5);
    }
}

Assuming that your MovieClip instance that you want it to be vibrated is mc.

Hi there, thanks for getting back to e, sorry its taken a couple of days to reply iv had connections issues. I tried doing it and made the button a movie clip with an instance name mc but i get this…

Error Scene=Scene 1, layer=Layer 1, frame=1:Line 2: Statement must appear within on/onClipEvent handler
height = 200;
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement must appear within on/onClipEvent handler
width = 300;
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 7: Statement must appear within on/onClipEvent handler
with(mc) {
Error Scene=Scene 1, layer=Layer 1, frame=1:Line 15: Statement must appear within on/onClipEvent handler
mc.onRollOver = function() {
Total ActionScript Errors: 4 Reported Errors: 4

Any ideas?

you cannot use the above code on a button, it would go in the main movie.

I’ve tried converting the button to a movie clip and then putting in a na actions layer with the code. I also tried putting the code onto the actual movie itself but it either tells me that the instance doesn’t exist (i’ve made sure the instance name is mc so it should right?) or it looks really small. either way the effect doesnt seem to work. Im sure this is really simple to you guys so i appologise for being stupid with this but any more pointers would be really appreciated.

Thanks so much for your time :slight_smile:

i put the code in a fla for you maybe this wil help you understand

(the file is mx2004 but you can open it in 8)