Juan Carlos Clemente
1986-06-13
zetta
Website Photo
zetta

class flash.Window.as Beta

(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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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

1
2
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

Descargar windowBeta.zip
[tags]flash, actionscript, class, window, opensource[/tags]

One Response to “class flash.Window.as Beta”

  1. Infected-FX Says:

    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)

Leave a Reply