Hi all,
I am working on an image slider I got over at FlashDen. It uses Zeh Fernando’s MCTween
(http://hosted.zeh.com.br/mctween ), it all works just fine. You can see the slider at
www.bartproeve.com/newsaktuell_referenten
Now when the slider is moving and you leave the active area with your mouse, then the slider continues to move until it has reached it’s point of destination.
Is ist possible to include a function that immediately stops the slider when the mouse leaves the active area?
Plus - what makes it a bit harder - can anybody figure out this function without having the .fla :|? As this is a commercial file, I’m quite sure I’m not allowed to post it here… Of course, I have already contacted the guys who made the file, but they couldn’t help…
Thanks a lot for your help!
B
it should be, but not without looking at the code lol
you would have to put the tweeny commands in an if statement in reference to where the mouse is.
Hi again!
Now this is an excerpt from the MCTween code that is included in the fla. To me, it looks just like what I was looking for:
MovieClip.prototype.stopTween = TextField.prototype.stopTween = Sound.prototype.stopTween = function(props) {
// Removes tweenings immediately, leaving objects as-is. Examples:
// <movieclip>.stopTween ("_x"); // Stops _x tweening
// <movieclip>.stopTween (["_x", "_y"]); // Stops _x and _y tweening
// <movieclip>.stopTween ("_x", "_y"); // Stops _x and _y tweening
// <movieclip>.stopTween (); // Stops all tweening processes
if (typeof (props) == "string") props = [props]; // in case of one property, turn into array
if (props != undefined) {
// 2.22.26: counts all arguments as parameters too
for (var i=1; i<arguments.length; i++) props.push(arguments*);
}
_global.$stopTween(this, props, true);
};
I just don’t know how to call this function from the fla?!?
Thanks for your help…
B
sepu
July 10, 2008, 8:11am
4
use the onReleaseOutside hanlder in your button code …
Hi sepu - which button do you mean? I have an mc that is moved by the MCTween script, so how can I include the stop function?
Hi all (again),
maybe this helps people helping me - this is another excerpt from the code, I think functions are defined from here:
class HScroller extends MovieClip {
// # Customize #
// left and right margins; fade element will be shown
private static var margin:Number = 100;
// thumbs horizontal space
private static var ts:Number = 0;
// thumb width
private static var tw:Number = 150;
// fade color
private static var fcol:Number = 0xffffff;
// scroll speed (1 - 8)
private static var speed:Number = 1;
// use round values for thumbs scrolling
private static var rval:Boolean = false;
// # end #
//
private var Mask:MovieClip;
private var Thumbs:MovieClip;
private var LF:MovieClip;
private var RF:MovieClip;
//
private var w:Number;
private var h:Number;
private var mcidx:Number = 0;
private var node:XMLNode;
private var hand:Function;
private var items:Number = 0;
private var spos:Number = -1;
private var tm:Number = 0;
private var se:Boolean = false;
private var tsw:Number = 0;
//
public function HScroller() {
if (speed>8) {
speed = 8;
} else if (speed<1) {
speed = 1;
}
//
w = this._width;
h = this._height;
this._xscale = this._yscale=100;
//
Mask = eval(this._target+"/a");
Mask._alpha = 0;
this.hitArea = Mask;
Thumbs = undefined;
LF = this.attachMovie("IDFade", "_LF_MC_", this.getNextHighestDepth());
RF = this.attachMovie("IDFade", "_RF_MC_", this.getNextHighestDepth());
RF._rotation = 180;
//
this.resize();
}
private function onLoad() {
LF.colorTo(fcol);
RF.colorTo(fcol);
}
public function resize() {
Mask._x = 0;
Mask._y = 0;
Mask._width = w;
Mask._height = h;
//
LF._x = 0;
LF._y = 0;
LF._xscale = margin;
LF._height = h;
//
RF._x = w;
RF._y = h;
RF._xscale = margin;
RF._height = h;
//
if (Thumbs != undefined) {
delete Thumbs.onEnterFrame;
if (tsw>w-2*margin) {
if (Thumbs._x>margin) {
Thumbs._x = margin;
} else if (Thumbs._x<w-margin-tsw) {
Thumbs._x = w-margin-tsw;
}
} else {
Thumbs._x = Math.round((w-tsw)/2);
}
}
}
public function setData(n:XMLNode, f:Function) {
se = false;
node = n;
hand = f;
//
if (Thumbs == undefined) {
slideIn();
} else {
slideOut();
}
}
private function slideOut() {
function hnd() {
with (this._parent) {
slideIn();
}
}
Thumbs.xSlideTo(w, 1.5, "easeInOutQuart", undefined, hnd);
}
private function slideIn() {
generate();
var xpos:Number = margin;
if (spos>=0) {
var aw:Number = ts-tm+2*spos*(tw+ts-tm);
xpos = Math.round(w/2-aw/2-(tw-ts+tm)/2);
if (tsw>w-2*margin) {
if (xpos>margin) {
xpos = margin;
} else if (xpos<w-margin-tsw) {
xpos = w-margin-tsw;
}
} else {
xpos = Math.round((w-tsw)/2);
}
}
function hnd() {
with (this._parent) {
se = true;
}
}
Thumbs.xSlideTo(xpos, 1.5, "easeInOutQuart", undefined, hnd);
}
private function generate() {
Thumbs = remove(Thumbs);
Thumbs = create();
Thumbs.setMask(Mask);
toFront(LF);
toFront(RF);
//
var mc:MovieClip;
items = 0;
spos = -1;
tsw = 0;
var n:XMLNode = node.firstChild;
for (; n != null; n=n.nextSibling) {
mc = Thumbs.attachMovie("IDThumbnail", "THUMB"+items, Thumbs.getNextHighestDepth());
var lbh:Number = mc.LHeight;
tm = 2*mc.Margin;
mc.width = tw;
mc.height = h-lbh;
mc.setData(n, hand);
mc._x = items*(tw+ts-tm);
mc._y = 0;
if (n.attributes.selected != undefined) {
spos = items;
}
tsw += tw+ts-tm;
//
items++;
}
tsw -= ts;
Thumbs._x = -tsw;
}
//
private function create():MovieClip {
var mc:MovieClip;
mc = this.createEmptyMovieClip("_movie_clip_"+(mcidx++), this.getNextHighestDepth());
return mc;
}
private function remove(mc:MovieClip) {
if (mc != undefined) {
mc.removeMovieClip();
}
return undefined;
}
private function toFront(mc) {
mc.swapDepths(this.getNextHighestDepth());
}
//
private function onMouseMove() {
if (!this.hitTest(_root._xmouse, _root._ymouse, true) || !se || tsw<=w-2*margin) {
return;
}
var offset:Number = margin+tw;
var xm:Number = this._xmouse<offset ? 0 : (this._xmouse>w-offset ? w-2*offset : this._xmouse-offset);
var tox:Number = margin+xm*(w-tsw-2*margin-tm)/(w-2*offset);
var xpos:Number = Thumbs._x;
Thumbs.onEnterFrame = function() {
if (Math.abs(xpos-tox)<1) {
delete this.onEnterFrame;
this._x = Math.round(tox);
return;
}
xpos += (tox-xpos)/(150-speed);
this._x = rval ? Math.round(xpos) : xpos;
};
}
//
public function set width(nw:Number) {
w = nw;
this.resize();
}
public function set height(nh:Number) {
h = nh;
this.resize();
}
public function get width():Number {
return w;
}
public function get height():Number {
return h;
}
}
Can anybody say how to implement a stop-on-roll-out-function - and how and where to call it?
Thanks all!
B