Buon giorno ragazzi sono nuova di questo forum e di flash non mastico tanto.
Vi espongo il mio problema: sto modificando il flash media player di jeroenwijering
http://www.jeroenwijering.com/ per avere uno scrolling orizontale della lista di video flv.
Sono riuscita a modificare alcuni script per avere l'autoscrolling orizzontale, solo che questo non si ferma all'inizio della lista e alla fine.
Sarei grata a chiunque di voi voglia aiutarmi a risolvere questo problema.
Ciao, Baci a tutti
di seguito la pagina di script che presumo sia alla base del problema:
/**
- Manages scrolling of a designated MovieClip, automatic or with scrollbar.
- @example
- var myScroller = new com.jeroenwijering.utils.Scroller(myMovie,myMask);
- myscroller.scrollTo(200);
- @author Jeroen Wijering
- @version 1.7
**/
import com.jeroenwijering.utils.Animations;
import com.jeroenwijering.utils.Draw;
class com.jeroenwijering.utils.Scroller {
/** Movieclip that should be scrolled /
private var targetClip:MovieClip;
/ Mask of the movieclip /
private var maskClip:MovieClip;
/ Use automatic scroling, defaults to false /
private var autoScroll:Boolean = false;
/ scrollbar front color /
private var frontColor:Number = 0x000000;
/ scrollbar highlighting color /
private var lightColor:Number = 0x000000;
/ size ratio clip:mask /
private var sizeRatio:Number;
/ scroll interval id for autoscroller and dragging of scrollbar /
private var scrollInterval:Number;
/ corrent scroll index /
private var currentScroll:Number = 0;
/ autoscroll multiplier /
private var AUTOSCROLL_SPEED:Number = 0.1;
/ Movieclip the scrollbar is drawn into /
private var SCROLLER_CLIP:MovieClip;
/ Color object of the scrollbar back /
private var SCROLLER_BACK_COLOR:Color;
/ Color object of the scrollbar front **/
private var SCROLLER_FRONT_COLOR:Color;
/**
- Sets up scrolling behaviour and scrollbar
- @param tgt MovieClip that should be masked
- @param msk Movieclip that shoulld be used as mask
- @param asc (optional) Boolean for using autoscroll
- @param fcl (optional) scrollbar color
- @param hcl (optional) scrollbar rollover color
**/
function Scroller(tgt:MovieClip,msk:MovieClip,asc:Boolean,
fcl:Number,hcl:Number) {
targetClip = tgt;
maskClip = msk;
arguments.length > 2 ? autoScroll = asc: null;
arguments.length > 3 ? frontColor = fcl: null;
arguments.length > 4 ? lightColor = hcl: null;
sizeRatio = maskClip._width/targetClip._width;
if(autoScroll == false) {
drawScrollbar();
} else {
scrollInterval = setInterval(this,"doAutoscroll",0);
}
var isMac = System.capabilities.os.toLowerCase().indexOf("mac" )!=-1;
if(isMac && _root._url.indexOf("http://") > -1) {
flash.external.ExternalInterface.addCallback(
"externalMouseEvent",this,onMacMouseWheel);
} else {
Mouse.addListener(this);
}
};
/** Draw the scrollbar. **/
private function drawScrollbar() {
targetClip._parent.createEmptyMovieClip("scrollbar ",
targetClip._parent.getNextHighestDepth());
SCROLLER_CLIP = targetClip._parent.scrollbar;
SCROLLER_CLIP._x = 3;
SCROLLER_CLIP._y = maskClip._y+30;
SCROLLER_CLIP.createEmptyMovieClip("back",0);
SCROLLER_CLIP.back._alpha = 0;
SCROLLER_CLIP.back._y = maskClip._y+30;
Draw.square(SCROLLER_CLIP.back,maskClip._width,20, frontColor);
SCROLLER_CLIP.createEmptyMovieClip("bar",1);
SCROLLER_CLIP.bar._x = 3;
SCROLLER_CLIP.bar._alpha = 50;
Draw.square(SCROLLER_CLIP.bar,maskClip._width,20,f rontColor);
SCROLLER_CLIP.createEmptyMovieClip("front",2);
SCROLLER_CLIP.front._x = 3;
Draw.square(SCROLLER_CLIP.front,50,20,frontColor);
SCROLLER_CLIP.front.createEmptyMovieClip("bg",1);
SCROLLER_CLIP.front.bg._x = 3;
SCROLLER_CLIP.front.bg._alpha = 0;
Draw.square(SCROLLER_CLIP.front.bg,50,20,frontColo r);
SCROLLER_FRONT_COLOR = new Color(SCROLLER_CLIP.front);
setScrollbarEvents();
};
/** Set use of mousewheel to scroll playlist. **/
public function onMouseWheel(dta:Number) {
scrollTo(currentScroll-dta*20);
};
/** Set use of mousewheel to scroll playlist (MAC). **/
function onMacMouseWheel(dta:Number) {
scrollTo(currentScroll-dta*20);
};
/** Set autoscroll events. **/
private function doAutoscroll() {
if (
maskClip._xmouse>0 && maskClip._xmouse<maskClip._width/
(maskClip._xscale/100) && maskClip._ymouse>0 &&
maskClip._ymouse<maskClip._height/(maskClip._yscale/100)) {
var dif:Number = maskClip._xmouse*(maskClip._xscale/100)-maskClip._width/2;
scrollTo(currentScroll+Math.floor(dif*AUTOSCROLL_S PEED));
}
};
/** All scrollbar mouse events grouped together. **/
private function setScrollbarEvents():Void {
var instance:Scroller = this;
SCROLLER_CLIP.front.onRollOver =
SCROLLER_CLIP.back.onRollOver = function() {
instance.SCROLLER_FRONT_COLOR.setRGB(instance.ligh tColor);
};
SCROLLER_CLIP.front.onRollOut =
SCROLLER_CLIP.back.onRollOut = function() {
instance.SCROLLER_FRONT_COLOR.setRGB(instance.fron tColor);
};
SCROLLER_CLIP.back.onPress = function() {
if(this._xmouse > this._parent.front._x +
this._parent.front._width) {
instance.scrollTo(instance.currentScroll +
instance.maskClip._width/2);
} else if (this._xmouse < this._parent.front._x) {
instance.scrollTo(instance.currentScroll -
instance.maskClip._width/2);
}
};
SCROLLER_CLIP.front.onPress = function() {
this.startDrag(false,0,0,instance.SCROLLER_CLIP.ba r._width - this._width,0);
instance.scrollInterval = setInterval(instance,"scrollTo",100);
};
SCROLLER_CLIP.front.onRelease =
SCROLLER_CLIP.front.onReleaseOutside = function() {
this.stopDrag();
clearInterval(instance.scrollInterval);
};
scrollTo(maskClip._x - targetClip._x);
};
/**
- Scroll the MovieClip to a given Y position.
- @param yps The y position the clip should scroll to.
**/
public function scrollTo(xps:Number):Void {
if(arguments.length == 0 && autoScroll == false) {
xps = SCROLLER_CLIP.front._x*maskClip._width / SCROLLER_CLIP.front._width;
}
else if (xps>targetClip._width-maskClip._width) {
xps = targetClip._width - maskClip._width;
}
Animations.easeTo(targetClip,targetClip._x - xps, maskClip._y);
SCROLLER_CLIP.front._x = xps*SCROLLER_CLIP.front._width / maskClip._width;
currentScroll = xps;
};
/** Remove the scrollbar from stage **/
public function purgeScrollbar() {
clearInterval(scrollInterval);
Mouse.removeListener(this);
scrollTo(0);
SCROLLER_CLIP.removeMovieClip();
};
}