class flash.Window.as Beta One comment Posted: 20.7.2007 | By: zetta
Window v.alpha
Clase Window.as
- import mx.utils.Delegate;
- import mx.transitions.Tween;
- import mx.transitions.easing.Regular;
- class Window {
- var width:Number;
- var height:Number;
- var home:MovieClip;
- var im:MovieClip;
- function Window(home:MovieClip,width:Number, height:Number) {
- this.width = width;
- this.height = height;
- this.home = home;
- }
- public function draw(x:Number,y:Number,params:Object):Void{
- var num:Number = home.getNextHighestDepth();
- this.im = this.home.attachMovie("window","customWindow"+num,num);
- this.im._y = y;
- this.im._x = x;
- this.im.bar._width = this.width;
- if(params.showbar == false) this.im.bar._visible = false;
- this.im.content._width = this.width;
- this.im.content._height = this.height;
- if(params.draggable != false){
- this.im.bar.onPress = Delegate.create (this, startDrag);
- this.im.bar.onRelease = Delegate.create(this,stopDrag);
- this.im.bar.onReleaseOutside = Delegate.create(this,stopDrag);
- }
- this.im.content.onPress = Delegate.create (this, top);
- if((params.forceDrag == true && params.showbar == false) || (params.allDraggable == true)){
- this.im.content.onPress = Delegate.create (this, startDrag);
- this.im.content.onRelease = Delegate.create(this,stopDrag);
- this.im.content.onReleaseOutside = Delegate.create(this,stopDrag);
- }
- }
- private function top():Void{
- this.im.swapDepths(this.home.getNextHighestDepth());
- }
- private function startDrag():Void{
- this.setProperty(this.im.content,"_alpha", 25, .5);
- this.top();
- this.im.startDrag(false);
- }
- private function stopDrag():Void{
- this.setProperty(this.im.content,"_alpha", 100, .5);
- this.im.stopDrag();
- }
- private function setProperty(target:MovieClip,property:String,value:Number,time:Number):Void{
- var set:Tween = new Tween(target, property, Regular.easeOut, target[property], value, time, true);
- }
- public function get xny():Object{
- return {x : this.im._x, y : this.im._y};
- }
- public function addContent(add:MovieClip):Void{
- //todo
- }
- }
Uso
- var w1:Window = new Window(target:MovieClip,width:Number,height:Number);
- 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
Tags: Flash, actionscript, class, delegate, flash, movieclip, opensource, public function, transitions, window

Está genial bro, esto se puede prestar para que se delimite el área para arrastrar las ventanitas, para que no se pierdan si las arrastras mucho oooh! incluso se me ocurre ponerle el easing x)