Blog
Ejemplo de Scrollbar Flash CS3
9 years, 7 months ago Posted in: Blog Comments Off

Este es un simple ejemplo sobre como crear una scrollbar via actionscript.

Actionscript:
  1. import fl.controls.*;
  2. import fl.events.*;
  3. import flash.display.*
  4. // CREATE CONTAINER - the scrollable obj
  5. var container:Sprite = new Sprite();
  6. container.x = 100;
  7. container.y = 100;
  8.  
  9. container.graphics.beginFill(0xFFCC00);
  10. container.graphics.drawRoundRect(0, 0, 200, 400, 0);
  11. container.graphics.endFill();
  12.  
  13. addChild(container);
  14.  
  15.  
  16.  
  17. // CREATE SCROLLBAR - the scroller
  18. var scrollbar:ScrollBar = new ScrollBar();
  19. scrollbar.direction = ScrollBarDirection.VERTICAL;
  20. scrollbar.move(container.x + container.width, container.y);
  21. scrollbar.setSize(scrollbar.width, container.height/2);
  22. scrollbar.setScrollProperties (scrollbar.height,0,container.height) ;
  23. addChild(scrollbar);
  24.  
  25. // SETUP LISTENER
  26. scrollbar.addEventListener(ScrollEvent.SCROLL ,onScroll);
  27.  
  28.  
  29. function onScroll(event:ScrollEvent){
  30. trace("scrolling " +scrollbar.scrollPosition );
  31. container.y = scrollbar.y - scrollbar.scrollPosition/(container.height/scrollbar.height);
  32. }

Comments are closed.

Image compression on this page is provided by WordPress Image Compressor