--More--
Alt-Ctrl- SCR LOCK

ctrl-zetta

class flash.Window.as Beta

2007-07-20 18:18:09 by zetta in Flash (1 comment) permalink

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Window v.alpha

Clase Window.as

  1. import mx.utils.Delegate;
  2. import mx.transitions.Tween;
  3. import mx.transitions.easing.Regular;
  4. class Window {
  5. var width:Number;
  6. var height:Number;
  7. var home:MovieClip;
  8. var im:MovieClip;
  9. function Window(home:MovieClip,width:Number, height:Number) {
  10. this.width = width;
  11. this.height = height;
  12. this.home = home;
  13. }
  14. public function draw(x:Number,y:Number,params:Object):Void{
  15. var num:Number = home.getNextHighestDepth();
  16. this.im = this.home.attachMovie("window","customWindow"+num,num);
  17. this.im._y = y;
  18. this.im._x = x;
  19. this.im.bar._width = this.width;
  20. if(params.showbar == false) this.im.bar._visible = false;
  21. this.im.content._width = this.width;
  22. this.im.content._height = this.height;
  23. if(params.draggable != false){
  24. this.im.bar.onPress =  Delegate.create (this, startDrag);
  25. this.im.bar.onRelease = Delegate.create(this,stopDrag);
  26. this.im.bar.onReleaseOutside = Delegate.create(this,stopDrag);
  27. }
  28. this.im.content.onPress =  Delegate.create (this, top);
  29. if((params.forceDrag == true && params.showbar == false) || (params.allDraggable == true)){
  30. this.im.content.onPress =  Delegate.create (this, startDrag);
  31. this.im.content.onRelease = Delegate.create(this,stopDrag);
  32. this.im.content.onReleaseOutside = Delegate.create(this,stopDrag);
  33. }
  34. }
  35. private function top():Void{
  36. this.im.swapDepths(this.home.getNextHighestDepth());
  37. }
  38. private function startDrag():Void{
  39. this.setProperty(this.im.content,"_alpha", 25, .5);
  40. this.top();
  41. this.im.startDrag(false);
  42. }
  43. private function stopDrag():Void{
  44. this.setProperty(this.im.content,"_alpha", 100, .5);
  45. this.im.stopDrag();
  46. }
  47. private function setProperty(target:MovieClip,property:String,value:Number,time:Number):Void{
  48. var set:Tween = new Tween(target, property, Regular.easeOut, target[property], value, time, true);
  49. }
  50. public function get xny():Object{
  51. return {x : this.im._x, y : this.im._y};
  52. }
  53. public function addContent(add:MovieClip):Void{
  54. //todo
  55. }
  56. }

Uso

  1. var w1:Window = new Window(target:MovieClip,width:Number,height:Number);
  2. w1.draw(x:Number,y:Number);

Donde:

  • target => Donde se construira la ventana
  • width => Ancho de la ventanta
  • height => Alto de la ventana

Métodos

  • draw:VoidDibuja la ventana en las coordenadas especificadas

Propiedades

  • xny
  • Devuelve un objeto con las coordenadas actuales de la ventana

Descargar windowBeta.zip


Tags: , , , , , , , , ,
del.icio.us digg reddit
CLI2 Theme by Rod McFarland.