In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Electric Field 3

I tried to publish this swif fast, so its buggy and its not 100% done/right
code is really messy
/**
 * Copyright Thy ( http://wonderfl.net/user/Thy )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oD09
 */

// I tried to publish this swif fast, so its buggy and its not 100% done/right
// code is really messy
package {
    import flash.display.BlendMode;
    import flash.display.Graphics;
    import flash.display.Shader;
    import flash.display.Shape;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.filters.GlowFilter;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextFormat;
    import flash.display.Sprite;
   /**
     * ...
     * @author Thi
     * 
     *
     *
     * k = 8.987551787368 e9  | [Coulumb's constant][N m² / C²]
     * Q or q =               | [C]
     * r = distance           | [m]
     * 
     *
     * V = kQ/r               | [eletric potential] [volts] [N m / C]
     * |Fele| = |V q / r|     | [eletric force] [N]
     * Ep = V q               | [Potencial energy] [J] [N m]
     * |E| = |V / r|          | [Eletric field] [J] [N / C]
     * U = ΔV                 | [delta V] [volts] [N m / C]
     * W[|E|(A->B)] = U q     | [J] [N m]
     *
     * I pretend to make an physics sofware, electric fields
     *
     */
    public class Electric extends Sprite 
    {
        // physics variables
        private var 
        K:Number = 8987551787.368,
        SCALE:Number = 1, SCALE_INV:Number = 1 / SCALE, V_SCALE:Number = 1, FIELD_VIEW:int,
        Q1:Number = Number(/*1.602e−19*/ 1), Q2:Number = 0, Q:Number, PARTICLE:Number = 0,
        R:Number = 1,
        V:Number = K*Q1/R,
        Fele:Number = Math.abs(V * Q2 / R),
        Ep:Number = V * Q2,
        E:Number = Math.abs(V / R),
        U:Number = V - K * Q1 / (R),
        W:Number = U * Q2;
        
        
        // layers
        private var
        layer0:Sprite = new Sprite(), // 
        layer1:Sprite = new Sprite(), // scene (300 . 300) 
        layer2:Sprite = new Sprite(), // charges, mouse
        layer3:Sprite = new Sprite(), // buttons
        layer4:Sprite = new Sprite(); // help
        
        // temp
        private var 
        i:int, j:int, l:int,
        dx:Number, dy:Number, itens:Number;
        
        // static electric scene
        private var
        static_data:BitmapData = new BitmapData(300,300,false, 0xFFFFFF),
        static_bitmap:Bitmap = new Bitmap(static_data, "auto", true),
        static_data2:BitmapData = new BitmapData(300,300,false, 0xFFFFFF),
        static_bitmap2:Bitmap = new Bitmap(static_data2, "auto", true),
        static_data3:BitmapData = new BitmapData(300,300,false, 0xFFFFFF),
        static_bitmap3:Bitmap = new Bitmap(static_data3, "auto", true),
        rect:Rectangle = new Rectangle(0, 0, 300, 300),
        point:Point = new Point(),
        scene_refresh:Boolean;
        
        // electric points
        private var parts:Vector.<Part> = new Vector.<Part>,
        p:Part, part_num:int = 0,
        part_edit:Boolean, part_editing:int = 0;
        
        // fild 3 particles
        private var parts2:Vector.<Part2> = new Vector.<Part2>,
        p2:Part2, part2_num:int = 0;
        
        // layer1 border
        private var border:Shape;
        
        
        
        // texts setup
        public var
        text_libraly:Array = [
            new TextFormat("Tahoma", 16),
            new GlowFilter(uint(
                (0x50*Math.random()) << 16 | 
                (0x50*Math.random()) << 8 | 
                0xFF * (Math.random()* .75 + .25)),
                .9, 4, 4, 2, 3)],
        text_update_count:int = 5;
        // help
        public var 
        help:Help = new Help(text_libraly);
        
        // mouse
        private var
        mouse_moved:Boolean,
        E_SHAPE:Shape = new Shape()
        
        // texts instances
        private var
        T_K:Input = new Input(text_libraly, "K: ", "898755178."),
        T_SCALE:Input = new Input(text_libraly, "scale: ", "10.000"),
        T_Q1:Input = new Input(text_libraly, "Q: ", /*"−1.602e−19"*/ "100000"),
        T_V_SCALE:Input = new Input(text_libraly, "scale: ", "100000"),
        T_FIELD_VIEW:Input = new Input(text_libraly, "field view: ", "00"),
        T_PARTICLE:Input = new Input(text_libraly, "particle speed: ", "000");
        private var
        T_NEW:Static = new Static(text_libraly, "New electric charge");
        private var T_E:Dynamic = new Dynamic(text_libraly, "E: ", "   "),
        T_V:Dynamic = new Dynamic(text_libraly, "V: ", "   ");
        
        
        
        public function Electric() 
        {
            stage.frameRate = 300;
            
            // layers
            addChild(layer0);
            addChild(layer1); // scene (300 . 300)
            addChild(layer2); // charges, mouse
            addChild(layer3); // button
            addChild(layer4); // help
            
            // text instances final setup
            layer3.addChild(T_K);            
            T_K.x = 4; T_K.y = 4;
            T_K.input.text = String(K);
            layer3.addChild(T_SCALE);
            T_SCALE.x = T_K.x + T_K.width + 4;
            T_SCALE.y = 4;
            T_SCALE.input.text = String(SCALE);
            layer3.addChild(T_V_SCALE);
            T_V_SCALE.x = 4; T_V_SCALE.y = 390;
            T_V_SCALE.input.text = "1";
            //
            layer3.addChild(T_Q1);
            T_Q1.x = 300; T_Q1.y = 40;
            T_Q1.input.text = String(Q1)
            //
            layer3.addChild(T_E);
            T_E.x = 4; T_E.y = 426;
            T_E.dyn.text = "lol"
            //
            layer3.addChild(T_PARTICLE);
            T_PARTICLE.x = T_V_SCALE.x + T_V_SCALE.width + 4; T_PARTICLE.y = 390;
            T_PARTICLE.input.text = "0"
            //
            layer3.addChild(T_FIELD_VIEW);
            T_FIELD_VIEW.x = T_PARTICLE.x + T_PARTICLE.width + 4; T_FIELD_VIEW.y = 390;
            T_FIELD_VIEW.input.text = String(0)
            
            // new electric charge
            layer3.addChild(T_NEW);
            T_NEW.x = 300;
            T_NEW.y = 4;
            
            // help final setup
            layer4.addChild(help)
            help.add(T_K, "Coulomb's constant" + "\n" + 
            "8.9876 e+9" + "\n" + 
            "4 π ε0 e-1" + "\n" +
            "[ N m² / C² ]");
            help.add(T_SCALE, "pixels for 1 meter");
            help.add(T_V_SCALE, "electric potential e-4");
            help.add(T_Q1, "Coulomb charge\n6.24151 e+18 protons")
            help.add(T_FIELD_VIEW, "0: none" + "\n" +
            "1: V field (itensity)" + "\n" +
            "2: E field (directions & itensity)" + "\n" +
            "3: V over E (overlay blend)"
            )
            help.add(T_PARTICLE, "Particle speed multiplier e-2")
            
            
            // static electric scene setup
            layer1.addChild(static_bitmap)
            layer1.addChild(static_bitmap2)
            layer1.addChild(static_bitmap3)
            static_bitmap2.blendMode = BlendMode.OVERLAY
            //static_bitmap3.blendMode = BlendMode.INVERT
            static_bitmap.x = (465-300) / 2;
            static_bitmap.y = (465 - 300) / 2;
            static_bitmap2.x = (465-300) / 2;
            static_bitmap2.y = (465 - 300) / 2;
            static_bitmap3.x = (465-300) / 2;
            static_bitmap3.y = (465 - 300) / 2;
            border = new Shape();
            var g:Graphics = border.graphics;
            g.lineStyle(1,0)
            g.drawRect(0,0,300,300);
            border.x = static_bitmap.x; // 82.5
            border.y = static_bitmap.y; // 82.5
            layer1.addChild(border)
            
            // mouse
            layer1.addChild(E_SHAPE);
            //E_SHAPE.blendMode = BlendMode.INVERT
            
            
            
            // listener
            stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
            stage.addEventListener(Event.ENTER_FRAME, enter_frame);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, mv);
            //
            layer1.addEventListener(MouseEvent.MOUSE_DOWN, md)
            stage.addEventListener(MouseEvent.MOUSE_UP, mu)
            
        }
        
        private function key_down(e:KeyboardEvent):void
        {
            if (e.keyCode != 37 && e.keyCode != 39 && e.keyCode != 16)
            {
                text_update_count = 5;
            }
            
        }
        
        private function enter_frame(e:Event):void
        {
            if(--text_update_count == 0)
            {
                // update all texts
                SCALE = Number(T_SCALE.input.text);
                SCALE_INV = 1 / SCALE;
                K = Number(T_K.input.text);
                var h:int = Number(T_FIELD_VIEW.input.text);
                if (Number(h) || h == 0)
                {
                    layer1.addChild(static_bitmap);
                    layer1.addChild(static_bitmap2);
                    layer1.addChild(static_bitmap3);
                    static_bitmap2.blendMode = BlendMode.OVERLAY
                    
                    layer1.addChild(border);
                    if (h == 0)
                    {
                        trace("EH, REMOVEU")
                        layer1.removeChild(static_bitmap);
                        layer1.removeChild(static_bitmap2);
                        static_bitmap3.blendMode = BlendMode.NORMAL
                    } else if (h == 1)
                    {
                        layer1.removeChild(static_bitmap);
                        static_bitmap2.blendMode = BlendMode.NORMAL
                        static_bitmap3.blendMode = BlendMode.DIFFERENCE
                    } else if (h == 2)
                    {
                        layer1.removeChild(static_bitmap2);
                        static_bitmap3.blendMode = BlendMode.DIFFERENCE
                    }
                    else if (h == 3)
                    {
                        static_bitmap2.blendMode = BlendMode.OVERLAY
                        static_bitmap3.blendMode = BlendMode.DIFFERENCE
                    }
                    layer1.addChild(E_SHAPE);
                }
                if(!Number(SCALE)) SCALE = 0, SCALE_INV = 0;
                if (!Number(K)) K = 0;
                PARTICLE = Number(T_PARTICLE.input.text);
                V_SCALE = Number(T_V_SCALE.input.text);
                if (!Number(PARTICLE)) PARTICLE = 0;
                if (!Number(V_SCALE)) V_SCALE = 0;
                if(mouse_moved)
                {
                    mouse_moved = false;
                    // TODO: CALCULATIONS & LINE REFRESH
                }
                // update editing charge
                if (part_edit)
                {
                    
                    p = parts[part_editing];
                    var value:Number = Number(T_Q1.input.text);
                    trace("FEZ,",value)
                    if (Number(value) || value == 0)
                    {
                        p.q = value;
                        p.sinal();
                        scene_refresh = true;
                    }
                    
                }
            }
            // refresh if the charge is really selected
            if (T_NEW.activated && part_edit)
            {
                trace("HUM", part_editing)
                part_edit = false
                parts[part_editing].filters = []
            }
            
            // temps
            var K_BY_C:Number = K / 1
            var VX:Number, VY:Number;
            var EX:Number, EY:Number;
            var V_SCALE2:Number = V_SCALE * .0001;
            var V2:Number;
            var red:uint, green:uint, blue:uint;
            
            // scene refresh
            if (scene_refresh)
            {
                scene_refresh = false;
                static_data.lock();
                static_data2.lock();
                static_data.fillRect(rect, 0xFFFFFF)
                static_data2.fillRect(rect, 0xFFFFFF)
                static_data3.fillRect(rect, 0xFFFFFF)
                /*////////////////////////////////////////////////////////////////////////*/
                var usedXY:Vector.<Number> = new Vector.<Number>(part_num * 2, true);
                i = -1;
                while (++i < part_num)
                {
                    usedXY[i * 2] = parts[i].X * SCALE;
                    usedXY[i * 2 + 1] = parts[i].Y * SCALE + SCALE;
                }
                
                j = -1;
                while (++j < 300)
                {
                    i = -1;
                    while (++i < part_num)
                    {
                        usedXY[i * 2 + 1] -= SCALE_INV;
                    }
                    l = -1;
                    while (++l < 300)
                    {
                        VX = VY = EX = EY = V2 = 0;
                        EY = 127
                        i = -1
                        while (++i < part_num)
                        {
                            dx = (usedXY[i * 2] - SCALE_INV * l)/SCALE;
                            dy = usedXY[i * 2 + 1] / SCALE;
                            R = Math.sqrt(dx * dx + dy * dy);
                            V = K_BY_C * parts[i].q / R; /**/
                            E = V / R; /**/
                            VX += V * dx / R;
                            VY += V * dy / R;
                            EX += E * dx / R
                            EY += E * dy / R
                            V2 += V
                            
                        }
                        //trace("VX = ", EX * V_SCALE2)
                        
                        VX *= V_SCALE2;
                        VY *= V_SCALE2;
                        EX *= V_SCALE2;
                        EY *= V_SCALE2;
                        V2 *= V_SCALE2;
                        
                        EX = int(EX)
                        EY = int(EY)
                        
                        if((EX < 8 && EX > -8) && (EY < 135 && EY > 119))
                        {
                            if(EX*EX + (EY-127)*(EY-127) < 9)
                            {
                                EX = 0xFFFFFF, EY = 0
                            } else
                            {
                                EX = 0xA0A0A0, EY = 0
                            }
                        } else
                        {
                            if (EX < 0) EX = ( -EX) << 16
                            
                            if(EY < 127)
                            {
                                if(EY < 0)
                                {
                                    EY = 0
                                } else 
                                {
                                    EY = EY >> 1
                                }
                            }
                        
                            if(EY > 0)
                            {
                                if (EY > 255) EY = 255
                                if (EY < 127) 
                                {
                                    EY = 127
                                } 
                                EY = EY << 8
                                
                            }
                        }
                        
                        
                        
                        
                        static_data.setPixel(l, j, EX | EY)
                        
                        if (V2 < 0) V2 = -V2;
                        V2 = V2 >> 0
                        red = (V2 >> 16) & 0xFF0000; 
                        green = (V2 >> 8) & 0xFF00; 
                        blue = V2 & 0xFF
                        red = ((red + blue + green) / 3) & 0xFF
                        static_data2.setPixel(l, j, red << 16 | red << 8 | red)
                        
                        
                        
                    }
                }
                trace("ACABOU")
                
                /**/
                static_data.unlock();
                static_data2.unlock();
                
                
                
                
            }
            
            // parts2 update stuff
            j = -1
            while (++j < part2_num)
            {
                
                K_BY_C = K / 1
                VX=0, VY=0;
                EX=0, EY=0;
                V_SCALE2 = V_SCALE * .0001;
                V2=0;            
                VX = VY = EX = EY = V2 = 0;
                
                var kill:Boolean  = false
                
                p2 = parts2[j]
                
                i = -1
                while (++i < part_num)
                {
                    dx = (parts[i].X) - p2.X
                    dy = (parts[i].Y) - p2.Y
                    R = Math.sqrt(dx * dx + dy * dy)
                
                    if (dx*dx <= 2 && dy*dy <= 2)
                    {
                        kill = true
                        break;
                    }
                    V = K_BY_C * parts[i].q / R; /**/
                    E = V / R; /**/
                    VX += V * dx / R;
                    VY += V * dy / R;
                    EX += E * dx / R
                    EY += E * dy / R
                }
                
                if (kill || --p2.time < 0)
                {
                    trace("DEAAAAD")
                    parts2.splice(j, 1)
                    --part2_num
                    --i;
                    continue;
                }
                
                EX *= -V_SCALE2 /**/ * .01;
                EY *= -V_SCALE2 /**/ * .01;
                
                var Emax:Number = EX*EX > EY*EY? EX : EY;
                Emax = Math.abs(Emax);
                
                if(PARTICLE == 0)
                {
                    EX *= 1 / (Emax);
                    EY *= 1 / (Emax);
                } else
                {
                    EX *= PARTICLE;
                    EY *= PARTICLE;
                }


                
                
                
                
                p2.X += EX
                p2.Y += EY
                static_data3.setPixel(p2.X,p2.Y,0x0)
            }
            
            
        }
        
        private function mv(e:MouseEvent):void
        {
            mouse_moved = true;
            // do mouse calculations
            var g:Graphics = E_SHAPE.graphics
            g.clear()
            g.lineStyle(1, 0)
            
            //
            
            var K_BY_C:Number = K / 1
            var VX:Number, VY:Number;
            var EX:Number, EY:Number;
            var V_SCALE2:Number = V_SCALE * .0001;
            var V2:Number;            
            VX = VY = EX = EY = V2 = 0;
            i = -1
            while (++i < part_num)
            {
                dx = (parts[i].X + 82.5) - mouseX
                dy = (parts[i].Y + 82.5) - mouseY
                R = Math.sqrt(dx * dx + dy * dy)
                
                if (dx*dx <= 2 && dy*dy <= 2)
                {
                    continue;
                }
                V = K_BY_C * parts[i].q / R; /**/
                E = V / R; /**/
                VX += V * dx / R;
                VY += V * dy / R;
                EX += E * dx / R
                EY += E * dy / R
            }
            
            VX *= V_SCALE2 * .001;
            VY *= V_SCALE2 * .001;
            EX *= -V_SCALE2 * .1;
            EY *= -V_SCALE2 * .1;
            
            g.lineStyle(1,0x00FFFF)
            g.moveTo(mouseX, mouseY)
            g.lineTo(mouseX + EX, mouseY + EY)
            g.moveTo(mouseX, mouseY)
            g.lineStyle(1,0xFF00FF)
            g.lineTo(mouseX + VX, mouseY + VY)
            
            
            //
            
            
        }
        
        private function md(e:MouseEvent):void
        {
            trace("DOWN CARALHO")
            if (T_NEW.activated)
            {
                trace("CLICKOOOO")
                T_NEW.click();
                // create an new charge
                var value:Number = Number(T_Q1.input.text);
                if (!Number(value) && value != 0) return;
                p = new Part(value, (mouseX - 82.5) * SCALE_INV, (mouseY - 82.5) * SCALE_INV);
                parts.push(p);
                layer2.addChild(p);
                p.x = p.X * SCALE + 82.5;
                p.y = p.Y * SCALE + 82.5;
                part_editing = part_num;
                ++part_num;
                part_edit = true;
                parts[part_editing].filters = [text_libraly[1]];
                p.addEventListener(MouseEvent.CLICK, part_selected);
                scene_refresh = true;
                
                
            } else if (part_edit)
            {
                part_edit = false
                parts[part_editing].filters = []
                
            } else
            {
                p2 = new Part2(0, (mouseX - 82.5) * SCALE_INV,(mouseY - 82.5) * SCALE_INV)
                parts2.push(p2)
                ++part2_num
            }
        }
        
        private function part_selected (e:MouseEvent):void
        {
            part_edit = true;
            i = -1
            while (++i < part_num)
            {
                if (e.target == parts[i])
                {
                    part_editing = i
                    break;
                }
            }
            trace("AE", part_editing)
            T_Q1.input.text = String(parts[part_editing].q)
            parts[part_editing].filters = [text_libraly[1]]
            
            
        }
        
        private function mu(e:MouseEvent):void
        {
            trace("UP POHA")
        }




    }
}
import flash.display.Graphics;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;




/* ////////////////////////
Particle Class
//////////////////////// */

import flash.display.Sprite;

class Part extends Sprite
{
    
    public var 
    X:Number, Y:Number, // in meters
    VeloX:Number, VeloY:Number, movement:Boolean,
    q:Number = 0;
    
    private var 
    g:Graphics;
    
    public function Part(q:Number = 0, X:Number = 0, Y:Number = 0, VeloX:Number = 0, VeloY:Number = 0, movement:Boolean = false):void
    {
        this.q = q;
        this.X = X; this.Y = Y; 
        this.VeloX = VeloX; this.VeloY = VeloY; this.movement = movement;
        g = this.graphics;
        sinal();
    }
    
    public function sinal():void
    {
        g.clear(); g.lineStyle(1,0);
        g.beginFill(0xFFFFFF);
        g.drawCircle(0,0,5);
        g.endFill();
        //
        if(q > 0)
        {
            g.moveTo(0,-2); g.lineTo(0,2);
            g.moveTo(-2,0); g.lineTo(2.5,0);
        } else if (q < 0)
        {
            g.moveTo(-2,0); g.lineTo(2,0);
        } else
        {
            g.drawEllipse(-2,-2,4,4)
        }
    }

    
}

/* ////////////////////////
Particle 2 Class
//////////////////////// */

import flash.display.Sprite;

class Part2 extends Sprite
{
    
    public var 
    X:Number, Y:Number, // in meters
    VeloX:Number, VeloY:Number, movement:Boolean,
    q:Number = 0, time:int = 4000;
    
    private var 
    g:Graphics;
    
    public function Part2(q:Number = 0, X:Number = 0, Y:Number = 0, VeloX:Number = 0, VeloY:Number = 0, movement:Boolean = false):void
    {
        this.q = q;
        this.X = X; this.Y = Y; 
        this.VeloX = VeloX; this.VeloY = VeloY; this.movement = movement;
        g = this.graphics;
        sinal();
    }
    
    public function sinal():void
    {
        g.clear(); g.lineStyle(1,0);
        g.beginFill(0xFFFFFF);
        g.drawCircle(0,0,5);
        g.endFill();
        //
        if(q > 0)
        {
            g.moveTo(0,-2); g.lineTo(0,2);
            g.moveTo(-2,0); g.lineTo(2.5,0);
        } else if (q < 0)
        {
            g.moveTo(-2,0); g.lineTo(2,0);
        } else
        {
            g.drawEllipse(-2,-2,4,4)
        }
    }

    
}

/* ////////////////////////
Text Classes - Input
//////////////////////// */

import flash.text.TextField;
import flash.events.FocusEvent;
class Input extends Sprite
{
    public var
    lib:Array,
    upd:Boolean = true;
    
    private var
    title:TextField = new TextField();
    public var
    input:TextField = new TextField();
    
    public function Input(lib:Array = null, s1:String = null, s2:String = null):void
    {
        this.lib = lib;
        title.defaultTextFormat = input.defaultTextFormat = lib[0];
        input.border = true; input.background = true;
        title.selectable = false; input.type = "input";
        title.text = s1; input.text = s2;
        title.autoSize = TextFieldAutoSize.LEFT;
        input.autoSize = TextFieldAutoSize.LEFT;
        var W:Number = title.width;
        var H:Number = title.height;
        title.autoSize = TextFieldAutoSize.NONE;
        title.width = W; title.height = H;
        title.x = 2; title.y = 4; input.y = 4
        input.x = W + 2;
        W = input.width;
        input.autoSize = TextFieldAutoSize.NONE;
        input.height = H;
        input.width = W;
        input.text = "";
        this.addChild(title)
        this.addChild(input)
        input.addEventListener(FocusEvent.FOCUS_IN, fin);
        //
        var g:Graphics = this.graphics
        g.lineStyle(1,0,1,true)
        g.beginFill(0xFFFFFF)
        g.drawRoundRect(0,0,input.x + W + 4, H + 8, 10, 10)
        g.endFill()
        //
        //this.mouseEnabled = false;
        //title.mouseEnabled = false;
    }
    
    private function fin(e:FocusEvent):void
    {
        input.addEventListener(FocusEvent.FOCUS_OUT, fout);
        this.filters = [lib[1]];
        upd = true;
    }
    
    private function fout(e:FocusEvent):void
    {
       input.addEventListener(FocusEvent.FOCUS_IN, fin);
       this.filters = [];
    }
}

/* ////////////////////////
Text Classes - Dynamic
//////////////////////// */

import flash.text.TextField;
import flash.events.FocusEvent;
class Dynamic extends Sprite
{
    public var
    lib:Array;
    
    private var
    title:TextField = new TextField();
    public var
    dyn:TextField = new TextField();
    
    public function Dynamic(lib:Array = null, s1:String = null, s2:String = null):void
    {
        this.lib = lib;
        title.defaultTextFormat = dyn.defaultTextFormat = lib[0];
        dyn.border = true; dyn.background = true;
        title.selectable = false; dyn.selectable = false;
        title.text = s1; dyn.text = s2;
        title.autoSize = TextFieldAutoSize.LEFT;
        dyn.autoSize = TextFieldAutoSize.LEFT;
        var W:Number = title.width;
        var H:Number = title.height;
        title.autoSize = TextFieldAutoSize.NONE;
        title.width = W; title.height = H;
        title.x = 2; title.y = 4; dyn.y = 4
        dyn.x = W + 2;
        W = dyn.width;
        dyn.autoSize = TextFieldAutoSize.NONE;
        dyn.height = H;
        dyn.width = W;
        dyn.text = "";
        this.addChild(title)
        this.addChild(dyn)
        //
        var g:Graphics = this.graphics
        g.lineStyle(1,0,1,true)
        g.beginFill(0xFFFFFF)
        g.drawRoundRect(0,0,dyn.x + W + 4, H + 8, 10, 10)
        g.endFill()
        //
        this.mouseEnabled = false;
        title.mouseEnabled = false;
    }
}

/* ////////////////////////
Text Classes - Static
//////////////////////// */

import flash.text.TextField;
class Static extends Sprite
{
    public var
    lib:Array,
    activated:Boolean;
    
    private var
    title:TextField = new TextField();
    
    public function Static(lib:Array = null, s1:String = null):void
    {
        this.lib = lib;
        title.defaultTextFormat = lib[0];
        title.selectable = false;
        title.text = s1;
        title.autoSize = TextFieldAutoSize.LEFT;
        var W:Number = title.width;
        var H:Number = title.height;
        title.autoSize = TextFieldAutoSize.NONE;
        title.width = W; title.height = H;
        title.x = 2; title.y = 4;
        this.addChild(title)
        this.addEventListener(MouseEvent.CLICK, click);
        //
        var g:Graphics = this.graphics
        g.lineStyle(1,0,1,true)
        g.beginFill(0xFFFFFF)
        g.drawRoundRect(0,0,title.x + W + 4, H + 8, 10, 10)
        g.endFill()
        //
        //this.mouseEnabled = false;
        title.mouseEnabled = false;
    }
    
    public function click(e:MouseEvent = null):void
    {
        if (activated)
        {
            this.filters = [];
        } else
        {
            this.filters = [lib[1]];
        }
        activated = !activated
    }
}

/* ////////////////////////
Text Classes - Help
//////////////////////// */

import flash.text.TextField;
import flash.events.FocusEvent;
class Help extends Sprite
{
    public var
    lib:Array, targets:Vector.<Target> = new Vector.<Target>();
    
    private var
    title:TextField = new TextField(),
    length:int = 0, i:int, j:int = 0,
    g:Graphics, H:Number;
    
    public function Help(lib:Array = null):void
    {
        this.lib = lib;
        g = this.graphics;
        title.defaultTextFormat = lib[0];
        title.selectable = false;
        this.mouseEnabled = false;
        this.mouseChildren = false;
        title.mouseEnabled = false;
    }
    
    public function add(target:Sprite = null, string:String = null):void
    {
        targets.push( new Target(target, string) );
        ++ length;
        target.addEventListener(MouseEvent.ROLL_OVER, fin);
        target.addEventListener(MouseEvent.ROLL_OUT, fout);
    }
    
    private function fin(e:MouseEvent):void
    {
        if (j != 0) return;
        i = -1
        while (++i < length)
        {
            if (e.target == targets[i].target)
            {
                title.text = targets[i].string;
                title.multiline = true
                title.autoSize = TextFieldAutoSize.LEFT;
                var W:Number = title.width;
                H = title.height;
                trace(H)
                title.autoSize = TextFieldAutoSize.NONE;
                title.width = W; title.height = H;
                title.x = 2; title.y = 4;
                this.addChild(title)
                g = this.graphics;
                g.lineStyle(1, 0, .3, true);
                g.beginFill(0xFFFFFF);
                g.drawRoundRect(0, 0, title.x + W + 4, H + 8, 10, 10);
                g.endFill();
                j = i;
                //
                var X:Number = targets[i].target.x
                var Y:Number = targets[i].target.y
                if (X + this.width + 5 > 465)
                {
                    X = 465 - this.width - 5
                } else
                {
                    X += 5
                }
                if (Y + targets[i].target.height + this.height + 5 > 465)
                {
                    trace(H)
                    Y -= (targets[i].target.height + H - 19 + 5)
                } else
                {
                    Y += targets[i].target.height + 5
                }
                this.x = X
                this.y = Y
                return;
            }
        }
    }
    
    private function fout(e:MouseEvent):void
    {
        if (e.target == targets[j].target)
        {
            this.removeChild(title);
            g.clear();
            j = 0;
        }
    }
}

class Target extends Sprite
{
    public var 
    target:Sprite,
    string:String;
    
    public function Target(target:Sprite = null, string:String = null):void
    {
        this.target = target;
        this.string = string;
    }
}