Ben een beetje aan het proberen om compnenten te maken.
Deze is voor een button. Nu wil ik een LINK meegeven...
Hoe in te bouwen?
//
// ------------------------------------------------------
// AnimatedRollover Component, v1.0
// ------------------------------------------------------
// updated march 19 2002
// Martijn de Visser - <martijn@rubberduck.nl>
// ------------------------------------------------------
// This component will on rollover animate from frame 1
// to _totalframes of the movie clip it is dropped on.
// When the mouse rolls out, it will animate back to the
// beginning of the movieclip.
// ------------------------------------------------------
// Public methods:
// enable() enables the component
// disable() disables the component
// isEnabled() returns state of component
// addListener(object) adds listener
// removeListener(object) removes listener
//
// Supported listeners method(s):
// onAnimRoll(rotation) sends current frame of target clip to all listeners
//
#initclip
// construct
AnimatedRolloverClass = function () { this.listenersList = [];this.enabled = true;this.init();};
// register class
Object.registerClass("AnimatedRollover", AnimatedRolloverClass);
AnimatedRolloverClass.prototype.init = function() {
if (this._targetInstanceName.length>0) {
this.rolloverTarget = this.targetInstance=this._parent[this._targetInstanceName];
this._visible = false;
if (this.rolloverTarget instanceof MovieClip) {
this.forward = true;
this.animate = false;
this.currentFrame = 1;
this.rolloverTarget.stop();
this.maxFrames = this.rolloverTarget._totalFrames;
this.rolloverTarget.parent = this;
this.rolloverTarget.onRollOver = this.myRollOver;
this.rolloverTarget.onRollOut = this.myRollOut;
this.rolloverTarget._focusrect = false;
this.rolloverTarget.useHandCursor = false;
} else {
trace("AnimatedRollover Component: no target movieclip found...");
this.enabled = false;
}
}
};
// initialize component
// enterframe routine to perform animation
AnimatedRolloverClass.prototype.onEnterFrame = function() {
if (this.animate) {
if (this.forward) {
// play forward routine
if (this.currentFrame<this.maxFrames) {
this.currentFrame++;
this.sendAnimRollEvent(this.currentFrame);
this.rollOverTarget.gotoAndStop(this.currentFrame);
} else {
this.animate = false;
}
} else {
// play backwards routine
if (this.currentFrame>1) {
this.currentFrame--;
this.sendAnimRollEvent(this.currentFrame);
this.rollOverTarget.gotoAndStop(this.currentFrame);
} else {
this.animate = false;
}
}
}
};
// mouse enters target clip
AnimatedRolloverClass.prototype.myRollOver = function() {
if (this.parent.enabled) {
this.parent.forward = true;
this.parent.animate = true;
}
};
// mouse leaves target clip
AnimatedRolloverClass.prototype.myRollOut = function() {
if (this.parent.enabled) {
this.parent.forward = false;
this.parent.animate = true;
}
};
// disable rollover behaviour
AnimatedRolloverClass.prototype.disable = function() {
this.enabled = false;
};
// enable rollover behaviour
AnimatedRolloverClass.prototype.enable = function() {
this.enabled = true;
};
// return enabled state
AnimatedRolloverClass.prototype.isEnabled = function() {
return this.enabled;
};
// add listener method
AnimatedRolloverClass.prototype.addListener = function(ref) {
this.listenersList[ref] = ref;
};
// remove listener method
AnimatedRolloverClass.prototype.removeListener = function(ref) {
delete this.listenersList[ref];
};
// send follow event to all listeners
AnimatedRolloverClass.prototype.sendAnimRollEvent = function(frame) {
// walk through listeners list
for (var i in this.listenersList) {
// invoke onAnimRoll handler in listener
this.listenersList[i].onAnimRollover(frame);
}
};
#endinitclip
Deze is voor een button. Nu wil ik een LINK meegeven...
Hoe in te bouwen?
//
// ------------------------------------------------------
// AnimatedRollover Component, v1.0
// ------------------------------------------------------
// updated march 19 2002
// Martijn de Visser - <martijn@rubberduck.nl>
// ------------------------------------------------------
// This component will on rollover animate from frame 1
// to _totalframes of the movie clip it is dropped on.
// When the mouse rolls out, it will animate back to the
// beginning of the movieclip.
// ------------------------------------------------------
// Public methods:
// enable() enables the component
// disable() disables the component
// isEnabled() returns state of component
// addListener(object) adds listener
// removeListener(object) removes listener
//
// Supported listeners method(s):
// onAnimRoll(rotation) sends current frame of target clip to all listeners
//
#initclip
// construct
AnimatedRolloverClass = function () { this.listenersList = [];this.enabled = true;this.init();};
// register class
Object.registerClass("AnimatedRollover", AnimatedRolloverClass);
AnimatedRolloverClass.prototype.init = function() {
if (this._targetInstanceName.length>0) {
this.rolloverTarget = this.targetInstance=this._parent[this._targetInstanceName];
this._visible = false;
if (this.rolloverTarget instanceof MovieClip) {
this.forward = true;
this.animate = false;
this.currentFrame = 1;
this.rolloverTarget.stop();
this.maxFrames = this.rolloverTarget._totalFrames;
this.rolloverTarget.parent = this;
this.rolloverTarget.onRollOver = this.myRollOver;
this.rolloverTarget.onRollOut = this.myRollOut;
this.rolloverTarget._focusrect = false;
this.rolloverTarget.useHandCursor = false;
} else {
trace("AnimatedRollover Component: no target movieclip found...");
this.enabled = false;
}
}
};
// initialize component
// enterframe routine to perform animation
AnimatedRolloverClass.prototype.onEnterFrame = function() {
if (this.animate) {
if (this.forward) {
// play forward routine
if (this.currentFrame<this.maxFrames) {
this.currentFrame++;
this.sendAnimRollEvent(this.currentFrame);
this.rollOverTarget.gotoAndStop(this.currentFrame);
} else {
this.animate = false;
}
} else {
// play backwards routine
if (this.currentFrame>1) {
this.currentFrame--;
this.sendAnimRollEvent(this.currentFrame);
this.rollOverTarget.gotoAndStop(this.currentFrame);
} else {
this.animate = false;
}
}
}
};
// mouse enters target clip
AnimatedRolloverClass.prototype.myRollOver = function() {
if (this.parent.enabled) {
this.parent.forward = true;
this.parent.animate = true;
}
};
// mouse leaves target clip
AnimatedRolloverClass.prototype.myRollOut = function() {
if (this.parent.enabled) {
this.parent.forward = false;
this.parent.animate = true;
}
};
// disable rollover behaviour
AnimatedRolloverClass.prototype.disable = function() {
this.enabled = false;
};
// enable rollover behaviour
AnimatedRolloverClass.prototype.enable = function() {
this.enabled = true;
};
// return enabled state
AnimatedRolloverClass.prototype.isEnabled = function() {
return this.enabled;
};
// add listener method
AnimatedRolloverClass.prototype.addListener = function(ref) {
this.listenersList[ref] = ref;
};
// remove listener method
AnimatedRolloverClass.prototype.removeListener = function(ref) {
delete this.listenersList[ref];
};
// send follow event to all listeners
AnimatedRolloverClass.prototype.sendAnimRollEvent = function(frame) {
// walk through listeners list
for (var i in this.listenersList) {
// invoke onAnimRoll handler in listener
this.listenersList[i].onAnimRollover(frame);
}
};
#endinitclip