1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
import mx.transitions.Tween ;
import mx.transitions.easing.* ;
MovieClip.prototype.drawRectangle = function (w, h, color) {
if (!isNaN(w)) this.w = w ;
if (!isNaN(h)) this.h = h ;
if (!isNaN(color)) this.color = color ;
this.clear() ;
this.beginFill(this.color, 100) ;
this.lineTo(this.w, 0) ;
this.lineTo(this.w, this.h) ;
this.lineTo(0, this.h) ;
this.lineTo(0, 0) ;
this.endFill() ;
}
var tw:Tween ;
var mc = createEmptyMovieClip("monRectangle", 1) ;
mc.drawRectangle(200, 10, 0xFF0000) ;
mc._x = 25 ;
mc._y = 25 ;
mc.onRollOver = function () {
if (tw.isPlaying) tw.stop() ;
tw = new Tween (this, "h", Back.easeOut, this.h, 250, 24) ;
tw.addListener(this) ;
}
mc.onRollOut = function () {
if (tw.isPlaying) tw.stop() ;
tw = new Tween (this, "h", Bounce.easeOut, this.h, 10, 24) ;
tw.addListener(this) ;
}
mc.onMotionChanged = function ( tw ) {
trace (tw) ;
this.drawRectangle(null, this.h) ;
} |
Partager