Posted By

orazal on 02/08/08


Tagged

position grid


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

orazal


Reposition thumbs on grid


 / Published in: ActionScript
 

  1. Stage.align = "TL";
  2. var total:Number = 20;
  3. var thumbWidth:Number = 100;
  4. var thumbHeight:Number = 60;
  5. buildThumbs();
  6. function buildThumbs():Void {
  7. for (var i:Number = 0; i<total; i++) {
  8. var thumb_mc:MovieClip = this.createEmptyMovieClip("thumb"+i+"_mc", i);
  9. with (thumb_mc) {
  10. beginFill(0x222222,100);
  11. lineStyle(0.5,0xCCCCCC,100);
  12. moveTo(0,0);
  13. lineTo(thumbWidth,0);
  14. lineTo(thumbWidth,thumbHeight);
  15. lineTo(0,thumbHeight);
  16. lineTo(0,0);
  17. }
  18. var label_txt:TextField = thumb_mc.createTextField("label_txt", 0, 0, 0, 0, 0);
  19. label_txt.text = i+1;
  20. label_txt.autoSize = true;
  21. label_txt.textColor = 0xFFFFFF;
  22. }
  23. positionInGrid();
  24. Stage.addListener(this);
  25. }
  26. function positionInGrid():Void {
  27. var limit:Number = Math.floor(Stage.width/thumbWidth);
  28. for (var i:Number = 0; i<total; i++) {
  29. var thumb_mc:MovieClip = this["thumb"+i+"_mc"];
  30. var column:Number = i%limit;
  31. var row:Number = Math.floor(i/limit);
  32. thumb_mc._x = column*thumbWidth;
  33. thumb_mc._y = row*thumbHeight;
  34. }
  35. }
  36. function onResize() {
  37. positionInGrid();
  38. }

Report this snippet  

You need to login to post a comment.