Loading...
Archive for the ‘Flash’ Category
  1. (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: , , , , , , , , ,
  2. (Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

    Pane v1.3

    1. Multiples instancias
    2. Integración con la rueda del ratón (al parecer no funciona en MacOs X)

    Clase Pane.as

    1. import mx.utils.Delegate;
    2. class Pane {
    3.     var mask: MovieClip,
    4.         sc1: MovieClip,
    5.         sc2: MovieClip,
    6.         origin: MovieClip,
    7.         sBar: MovieClip,
    8.         Target: MovieClip;
    9.     var sTotal: Number,
    10.         top: Number,
    11.         h: Number,
    12.         w: Number;
    13.     var ml: Object;
    14.     var delayer: Number;
    15.     function Pane(clip, width, height, pos) {
    16.         delayer = 0;
    17.         ml = new Object();
    18.         Mouse.addListener(ml);
    19.         this.origin = clip;
    20.         this.w = width;
    21.         this.h = height;
    22.         mask = clip._parent.createEmptyMovieClip("masking_" + clip._name, clip._parent.getNextHighestDepth());
    23.         mask._x = clip._x;
    24.         mask._y = clip._y;
    25.         mask.lineStyle(1, 0x000000, 100, true, "none", "round", "miter", 1);
    26.         mask.beginFill(0x000000);
    27.         mask.moveTo(0, 0);
    28.         mask.lineTo(width, 0);
    29.         mask.lineTo(width, height);
    30.         mask.lineTo(0, height);
    31.         mask.moveTo(0, 0);
    32.         clip.setMask(mask);
    33.         sc1 = clip._parent.attachMovie("paneScrollButon", "sc1_" + clip._name, clip._parent.getNextHighestDepth());
    34.         sc1._x = (pos == "left") ? Math.ceil(clip._x - sc1._width) : Math.ceil(clip._x + width);
    35.         sc1._y = Math.ceil(clip._y);
    36.         sc1.onPress = function() {
    37.             var nombre: MovieClip = this._parent["sBar_" + this._name.substr(4, this._name.length)];
    38.             nombre.onEnterFrame = track;
    39.             this.onEnterFrame = function() {
    40.                 if (nombre._y > nombre._top) {
    41.                     nombre._y -= 10;
    42.                 } else {
    43.                     nombre._y = nombre._top;
    44.                 }
    45.             };
    46.         };
    47.         sc1.onRelease = sc1.onReleaseOutside = function() {
    48.             delete this.onEnterFrame;
    49.         };
    50.         sc2 = clip._parent.attachMovie("paneScrollButon2", "sc2_" + clip._name, clip._parent.getNextHighestDepth());
    51.         sc2._x = (pos == "left") ? Math.ceil(clip._x - sc1._width) : Math.ceil(clip._x + width);
    52.         sc2._y = Math.ceil((clip._y + height) - sc1._height);
    53.         sc2.onPress = function() {
    54.             var nombre: MovieClip = this._parent["sBar_" + this._name.substr(4, this._name.length)];
    55.             nombre.onEnterFrame = track;
    56.             this.onEnterFrame = function() {
    57.                 if (nombre._y < nombre._bottom) {
    58.                     nombre._y += 10;
    59.                 } else {
    60.                     nombre._y = nombre._bottom;
    61.                 }
    62.             };
    63.         };
    64.         sc2.onRelease = sc1.onReleaseOutside = function() {
    65.             delete this.onEnterFrame;
    66.         };
    67.         sTotal = clip.sTotal = Math.ceil(sc2._y - (sc1._y + sc1._height));
    68.         sBar = clip._parent.attachMovie("paneScrollBar", "sBar_" + clip._name, clip._parent.getNextHighestDepth());
    69.         sBar.Target = clip;
    70.         sBar._x = Math.ceil(sc1._x);
    71.         sBar._y = Math.ceil(sc1._y + sc1._height);
    72.         sBar._height = (((height * 100) / clip._height) / 100) * height;;
    73.         sBar.onRelease = sBar.onReleaseOutside = function() {
    74.             this.isPressed = false;
    75.             this.stopDrag();
    76.         };
    77.         var left: Number = Math.ceil(sc1._x);
    78.         var top: Number = Math.ceil(sc1._y + sc1._height + 1);
    79.         var bottom: Number = Math.ceil((sc1._y + sTotal + sc1._height) - (sBar._height) - 1);
    80.         sBar._top = top;
    81.         sBar._left = left;
    82.         sBar._bottom = bottom;
    83.         sBar.delayer = 0;
    84.         sBar.isPressed = false;
    85.         sBar.onPress = function() {
    86.             this.startDrag(false, this._left, this._top, this._left, this._bottom);
    87.             this.onEnterFrame = track;
    88.             this.delayer = 0;
    89.             this.isPressed = true;
    90.         };
    91.         function track() {
    92.             var percent: Number = Math.round((this._y - this._top) * 100) / (this._bottom - this._top);
    93.             var nombre: MovieClip = this._parent[this._name.substr(5, this._name.length)];
    94.             var mask: MovieClip = nombre._parent["masking_" + nombre._name];
    95.             var diff: Number = nombre._height - mask._height;
    96.             var newVal = ( - ((diff * percent) / 100)) + mask._y;
    97.             nombre._y += (newVal - nombre._y) * 0.4;
    98.             this.delayer = this.isPressed == false ? this.delayer + 1 : this.delayer;
    99.             if (this.delayer == 10) {
    100.                 delete this.onEnterFrame
    101.             }
    102.         }
    103.         ml.onMouseWheel = Delegate.create(this, wheel);
    104.     }
    105.     private function _track() {
    106.         var percent: Number = Math.round((sBar._y - sBar._top) * 100) / (sBar._bottom - sBar._top);
    107.         var diff: Number = origin._height - mask._height;
    108.         var newVal = ( - ((diff * percent) / 100)) + mask._y;
    109.         origin._y += (newVal - origin._y) * 0.4;
    110.         delayer++;
    111.         if (delayer == 10) {
    112.             delete sBar.onEnterFrame
    113.         }
    114.     }
    115.     private function wheel(delta) {
    116.         var ob: MovieClip = this.origin._parent;
    117.         var obj: MovieClip = this.mask;
    118.         if (ob._xmouse > = obj._x && ob._xmouse < = obj._x + this.w && ob._ymouse > = obj._y && ob._ymouse < = obj._y + this.h) {
    119.             delayer = 0;
    120.             if (delta < 0) {
    121.                 sBar.onEnterFrame = Delegate.create(this, _track);
    122.                 if (sBar._y + 25 < sBar._bottom) {
    123.                     sBar._y += 25;
    124.                 } else {
    125.                     sBar._y = sBar._bottom;
    126.                 }
    127.             } else {
    128.                 sBar.onEnterFrame = Delegate.create(this, _track);
    129.                 if (sBar._y - 25 > sBar._top) {
    130.                     sBar._y -= 25;
    131.                 } else {
    132.                     sBar._y = sBar._top;
    133.                 }
    134.             }
    135.         }
    136.     }
    137.     public function is() {
    138.         return true;
    139.     }
    140.     public function die() {
    141.         this.mask.removeMovieClip();
    142.         this.sBar.removeMovieClip();
    143.         this.sc1.removeMovieClip();
    144.         this.sc2.removeMovieClip();
    145.     }
    146.     public function hide() {
    147.         this.mask._visible = false;
    148.         this.sBar._visible = false;
    149.         this.sc1._visible = false;
    150.         this.sc2._visible = false;
    151.         this.origin._visible = false;
    152.     }
    153.     public function show() {
    154.         this.mask._visible = true;
    155.         this.sBar._visible = true;
    156.         this.sc1._visible = true;
    157.         this.sc2._visible = true;
    158.         this.origin._visible = true;
    159.     }
    160.     public function reset() {
    161.         sBar._x = Math.ceil(sc1._x);
    162.         sBar._y = Math.ceil(sc1._y + sc1._height);
    163.         origin._y = sc1._y;
    164.         show();
    165.     }
    166.     public function resize() {
    167.         sBar._height = (((h * 100) / origin._height) / 100) * h;
    168.         sBar._left = Math.ceil(sc1._x);
    169.         sBar._top = Math.ceil(sc1._y + sc1._height + 1);
    170.         sBar._bottom = Math.ceil((sc1._y + sTotal + sc1._height) - (sBar._height) - 1);
    171.     }
    172. }

    Uso

    1. var newPane:Pane = new Pane(clip:MovieClip, Width:Number, height:Number, type:String);

    Donde:

    • clip => MovieClip que se enmascarará
    • width => Ancho del cuadro a crear
    • height => Alto del cuadro a crear
    • type => De que lado estara la barra de scroll (left / right)

    Métodos

    • is:BooleanDevuelve verdadero en caso de existir la instancia
    • hide:VoidOculta el objeto Pane
    • show:VoidVuelve a mostrar el objeto Pane
    • reset:VoidRegresa el scrollbar al inicio (arriba)
    • resize:VoidRegenera el tamaño del scroll (útil en contenido dinámico)

    Descargar Pane.zip


    Tags: , , , , ,

Powered by ExtJS Theme flavored Wordpress.