Pues con el siguiente código lo podemos hacer con un MovieClip:
import fl.events.ScrollEvent;
import flash.geom.Rectangle;
import flash.geom.Point;
var totalHeight:Number = mcListing.height;
var croppedHeight:Number = 418; //ancho de visulizacion
var rect:Rectangle;
rect = new Rectangle(0, 0, mcListing.width, croppedHeight);
mcListing.scrollRect = rect;
//Aqui va el código que añade los movieclips hijos al mcListing
cmpntScrollBar.setScrollProperties(croppedHeight, 0, totalHeight - croppedHeight);
cmpntScrollBar.setSize(cmpntScrollBar.width, croppedHeight);
cmpntScrollBar.update();
import flash.geom.Rectangle;
import flash.geom.Point;
var totalHeight:Number = mcListing.height;
var croppedHeight:Number = 418; //ancho de visulizacion
var rect:Rectangle;
rect = new Rectangle(0, 0, mcListing.width, croppedHeight);
mcListing.scrollRect = rect;
//Aqui va el código que añade los movieclips hijos al mcListing
cmpntScrollBar.setScrollProperties(croppedHeight, 0, totalHeight - croppedHeight);
cmpntScrollBar.setSize(cmpntScrollBar.width, croppedHeight);
cmpntScrollBar.update();
Siendo "mcListing" el movieclip que contendrá la lista, "rect" la ventana de visualización y "cmpntScrollBar" el scrollbar del escenario
Ahora falta el evento del scrollBar, para que el rectangulo de visualización se mueva por el mcListing
cmpntScrollBar.addEventListener(ScrollEvent.SCROLL , scrollArticle);
function scrollArticle(evt:ScrollEvent):void{
// Get access to the current scroll rectangle.
var rect:Rectangle = mcListing.scrollRect;
rect.y = cmpntScrollBar.scrollPosition;
// Reassign the rectangle to the TextField to "apply" the change.
mcListing.scrollRect = rect;
}
function scrollArticle(evt:ScrollEvent):void{
// Get access to the current scroll rectangle.
var rect:Rectangle = mcListing.scrollRect;
rect.y = cmpntScrollBar.scrollPosition;
// Reassign the rectangle to the TextField to "apply" the change.
mcListing.scrollRect = rect;
}
et voilá!!
Sacado de: http://www.sitepoint.com/forums/flash-actionscript-150/uiscrollbar-movieclip-scrollrect-528663.html
No hay comentarios:
Publicar un comentario