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

flash project1

Get Adobe Flash player
by eMarin5555 27 Sep 2011
    Embed
/**
 * Copyright eMarin5555 ( http://wonderfl.net/user/eMarin5555 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6aDe
 */

package {
    import flash.ui.Keyboard;
    import flash.ui.KeyLocation;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.text.engine.TextLine;
    import flash.text.TextField;
    import flash.display.Sprite;
    
    public class TreeNode extends Sprite 
    {
         public function TreeNode() 
        {
            var node:Number;

            //node = inPut();
            outPutBox(node);        

        }
       
       /*public function inPut():Number
        {
            
            return node;
        }*/

       public function outPutBox(node:Number):void
        {
            var messageBox:TextField= new TextField();
            var userInput:TextField= new TextField();
            //var node:Number;
            
            addChild(userInput);
            addChild(messageBox);
            
            //create box/set type
            //set type for input to 
            //alllow user to add the node
            userInput.type = "input"
            userInput.border = true;
            userInput.maxChars = 3;
            userInput.restrict = "0-9";

            //position of box
            userInput.x = 200;
            userInput.y = 100;
            
            messageBox.x = 170;
            messageBox.y = 25;
            //size of box
            userInput.width = 50;
            userInput.height = 20;
            
            messageBox.width = 110;
            messageBox.height = 20;
            
            messageBox.text = ("Please enter a number.");
           
            var display:TextField = new TextField();
            var numbers:Number;
            addChild(display);
            
            //create box/no need to set type 
            //user does not have to add anything
            //this is dynmaic
            display.border = true;
            display.multiline = true;
            display.wordWrap = true;
            
            //position of box
            display.x = 25;
            display.y = 150;
            
            //box size
            display.width = 425;
            display.height = 300;
            
            stage.addEventListener(KeyboardEvent.KEY_DOWN, enter);
            
            function enter(e:KeyboardEvent):void
            {
                var i:int;
                 if(e.keyCode == Keyboard.ENTER)
                 {         
                  
                  //put the number user added into node
                  node = Number(userInput.text);
                  
                 /* if(node == 2 || 3 || 5 || 7)
                  {
                      //display.text = "The number " + String(node) + " is a prime number.\n";
                       
                  }     */  
                             
                   var nodeRight:Array = new Array();
                   var nodeLeft:Array = new Array();
                   
                  
                  //go through all possible numbers less then the node
                   for(i =0, numbers = 2; numbers < node; numbers++)
                   {
                          
                        if(node % numbers == 0)
                        //if(numbers != 0)
                       {
                           nodeRight[i] = new TextField();
                           nodeRight[i].width = 20;
                           nodeRight[i].height = 20;
                           nodeRight[i].border = true;
                           
                           nodeRight[i].x = 175;
                           nodeRight[i].y = 155 + i * nodeRight[i].y + i * 25;
                           
                           nodeLeft[i] = new TextField();
                           nodeLeft[i].width = 20;
                           nodeLeft[i].height = 20;
                           nodeLeft[i].border = true;
                           
                           nodeLeft[i].x = 275;
                           nodeLeft[i].y = 155 + i * nodeLeft[i].y + i * 25;

                            //factor(p->nodeLeft, divisor);
                            //factor(p->nodeRight, node/divisor);
                           nodeLeft[i].text = String(numbers);
                           addChild(nodeLeft[i]);

                           nodeRight[i].text = node/numbers;
                           addChild(nodeRight[i]);
                           i++;
                           
                           nodeLeft[i].text = new TreeNode;
                           nodeRight[i].text = new TreeNode;

                       }
                   

                    }
                 }
            }
           
        }
    }
}