开发者

AS3 How to create scrollBar for Movieclip in actionscript 3

I am trying to scroll a movieclip with a scroll bar....I have tried ULscrollBar but it ends up only works for text...

Are there anyway to scroll MC by using only AS3 in flex environme开发者_StackOverflow社区nt...? Thanks.


I honestly don't know what Flex can and can't do, but what I do in Flash is

stage.addEventListener (MouseEvent.MOUSEWHEEL, MouseWheel, false, 0, true);
function MouseWheel (e:MouseEvent) {
  if (e.delta > 0) {
    mc.y += 10;
  } else {
    mc.y -= 10;
  }
}

The MOUSEWHEEL listener runs everytime the mouse wheel is moved up or down. The delta tells you whether the mouse wheel went up or down. It can either be negative or positive, I don't remember whether negative is when the wheel goes up or when it goes down, same with positive.

Or you can add 2 buttons, one that scrolls up when you click it and one that scrolls down.


  • Make sure your movie clip is exported for actionscript
  • Drag a new scrollPane component to the stage
  • Skin the scrollbars and the background if you need to
  • Create a new instance of your movie clip programmatically
  • Set the source property of the scrollPane to your movie clip
  • This took 2 minutes, less then you expected, so reward yourself with a cup of coffee
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜