NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .

Maus Schubsen

Code Actionscript 2.0

Instanz-Aktion

onClipEvent (load) {
speedx = 0;
speedy = 0;
}
onClipEvent (enterFrame) {
// continuously slow down speed
speedx = speedx / 1.2;
speedy = speedy / 1.2;
this._x = this._x + speedx;
this._y = this._y + speedy;
}
on (rollOver) {
// direct speed away from mouse
speedx = (this._x - _root._xmouse) * 1.1;
speedy = (this._y - _root._ymouse) * 1.1;
}

Code Actionscript 3.0

square.addEventListener(Event.ENTER_FRAME, enterFrame); square.addEventListener(MouseEvent.MOUSE_OVER, rollOver); var speedx = 0; var speedy = 0; function enterFrame(event:Event) { // continuously slow down speed speedx = speedx / 1.2; speedy = speedy / 1.2; event.target.x = square.x + speedx; event.target.y = square.y + speedy; } function rollOver(e:MouseEvent) { // direct speed away from mouse speedx = (e.target.x - mouseX) * 1.1; speedy = (e.target.y - mouseY) * 1.1; }

Infos

Das Quadrat wird von der Maus weggestossen. Beim Drüberrollen wird die Geschwindigkeit von der Maus weg gerichtet. In jedem Durchgang wird die Geschwindigkeit um das 1.2fache abgebremst.

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share