views:

109

answers:

2

I've got a custom AS3 scrollbar that I need to modify. The scroll thumb (the draggable part of a scrollbar) is currently just done by drawing a rectangle. But I need it to look more like a real scrollbar. Not sure how to modify the below code to import/use a scroll thumb image:

  scrollThumb = new Sprite();
  scrollThumb.graphics.lineStyle();
  scrollThumb.graphics.beginFill(0x0066ff); 
  scrollThumb.graphics.drawRect(0, 0, 1, 1);
  addChild(scrollThumb);

I know that I would embed an image by doing something like this:

[Embed(source="images/image1.png")] private static var Image1Class:Class;

But then how do I set the scrollThumb = to the image?

Thanks!

A: 

I think it should be as simple as:

scrollThumb = new Image1Class() as Sprite;
addChild(scrollThumb)
davr
A: 

Images get called in as BitmapDatas so you need to do

addChild(new Bitmap(new Image1Class(0, 0)));

or if you want to manipulate it as a Sprite:

scrollThumb = new Sprite;
scrollThumb.addChild(new Bitmap(new Image1Class(0, 0)));
addChild(scrollThumb);
Chris Burt-Brown