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

forked from: forked from: Star Class

how do i clear old text??????????????????

WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!
if you do a websearch on Google for
Bolt Pattern Calculator 
Measure Wheel Pattern 
Wheel Bolt Pattern
a lot of shit fake virus html webpages come as result
infeecting your pc with annoying fake messages
fake virus warnings 
why is noone doing anything about this 
lock them up, take their money wich they stole from you
WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!
if you have a car wheel with 5 holes how to now measure the borecircle????

i want to draw holes on circle
to solve proble i have a car wheel with 5 holes
thus cannot measure the bolt circle pattern  diameter
when i measure the hole diameter and the distance from hole to hole
the distance from star poit to star point + hole diameter

help me????

bore circle pattern solve
you can not measure bolt-circle diameter on wheels with an odd number of bolt holes
so want to calculate this
help???

Measure th
/**
 * Copyright zahir ( http://wonderfl.net/user/zahir )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/ttvx
 */

// forked from l.dijkman's forked from: Star Class
// how do i clear old text??????????????????


// forked from tkinjo's Star Class
//
// WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!
// if you do a websearch on Google for
// Bolt Pattern Calculator 
// Measure Wheel Pattern 
// Wheel Bolt Pattern
// a lot of shit fake virus html webpages come as result
// infeecting your pc with annoying fake messages
// fake virus warnings 
// why is noone doing anything about this 
// lock them up, take their money wich they stole from you
//WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!WARNING!!!
// if you have a car wheel with 5 holes how to now measure the borecircle????
//
// i want to draw holes on circle
// to solve proble i have a car wheel with 5 holes
// thus cannot measure the bolt circle pattern  diameter
// when i measure the hole diameter and the distance from hole to hole
// the distance from star poit to star point + hole diameter
//
// help me????
//
// bore circle pattern solve
// you can not measure bolt-circle diameter on wheels with an odd number of bolt holes
// so want to calculate this

// help???

/*
Measure the Un-Measurable
When It's Not Possible to Measure Across a Bolt Circle
because of Odd Number of Holes
or Hub or Shaft Interference 

Or to check the hole spacing on a known bolt circle
see
http://www.metalwebnews.com/formulas-tables/coordinates.html
http://www.poodwaddle.com/calc3.swf
*/

package
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.Point;
    import flash.text.*;
    
    [SWF(width="465", height="465", backgroundColor="0xffffff", frameRate="60")] 
    /**
     * Star Class
     * 
     * 星クラス
     * 
     * 使い方は createStar メソッドを参照
     * 
     * @author tkinjo
     */
    public class Main extends Sprite
    {
        private var stageWidth:Number = stage.stageWidth;
        private var stageHeight:Number = stage.stageHeight;
        private var stageCenter:Point = new Point( stageWidth / 2, stageHeight / 2 );
        
        /** --------------------------------------------------
         * component
         */
        private var configPanel:SlidePanel;
        private var numVertexInputTextAndHSlider:InputTextAndHSlider;
        private var outerRadiusInputTextAndHSlider:InputTextAndHSlider;
        private var innerRadiusInputTextAndHSlider:InputTextAndHSlider;
        
        private var canvas:Sprite;
        private var star:Star;
        
        public function Main() 
        {
            canvas = new Sprite();
            addChild( canvas );
            
            createComponent();
            
            createStar();
        }
        
        private function createStar():void {
            
            var starStroke:GraphicsStroke = new GraphicsStroke( 1 );
            starStroke.fill = new GraphicsSolidFill();
            
            star = new Star( numVertexInputTextAndHSlider.value, outerRadiusInputTextAndHSlider.value, 0, null, starStroke );
            star.x = stageCenter.x;
            star.y = stageCenter.y;
            
            canvas.addChild( star );
        }
        
        
        
        
        
        private function createComponent():void {
            
            configPanel = new SlidePanel( 0, 0, stageWidth, 0, 1, 0xffffff, 0.9 );
            addChild( configPanel );
            
            // numVertexInputTextAndHSlider
            numVertexInputTextAndHSlider = createInputTextAndHSlider( "num Holes" );
            numVertexInputTextAndHSlider.round = 5;
            numVertexInputTextAndHSlider.hSlider.minimum = 1;
            numVertexInputTextAndHSlider.hSlider.maximum = 32;
            numVertexInputTextAndHSlider.value = 5;
            numVertexInputTextAndHSlider.addEventListener(Event.CHANGE, function( event:Event ):void {
                    star.numVertex = numVertexInputTextAndHSlider.value;
                } );
            
            // outerRadiusInputTextAndHSlider
            outerRadiusInputTextAndHSlider = createInputTextAndHSlider( "outerRadius", numVertexInputTextAndHSlider );
            outerRadiusInputTextAndHSlider.round = 0.01;
            outerRadiusInputTextAndHSlider.hSlider.maximum = 300.00;
            outerRadiusInputTextAndHSlider.value = 200.00;
            outerRadiusInputTextAndHSlider.addEventListener(Event.CHANGE, function( event:Event ):void {
                    star.outerRadius = outerRadiusInputTextAndHSlider.value;
                } );
        }
        
        private function createInputTextAndHSlider( text:String = "", component:DisplayObject = null ):InputTextAndHSlider {
            
            var inputTextAndHSlider:InputTextAndHSlider = new InputTextAndHSlider( configPanel, 10, ( component != null ) ? component.y + component.height + 10 : 10, text );
            inputTextAndHSlider.label.width     = 70;
            inputTextAndHSlider.inputText.width = 30;
            inputTextAndHSlider.hSlider.width   = 300;
            
            return inputTextAndHSlider;
        }
    }
}



import com.bit101.components.*;
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.text.*;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.easing.Cubic;

class Star extends Sprite {
    
    /**
     * 
     */
    public function get numVertex():uint { return _numVertex; }
    public function set numVertex(value:uint):void 
    {
        _numVertex = value;
        draw();
    }
    private var _numVertex:uint;
    
    
    /**
     * 
     */
    public function get outerRadius():Number { return _outerRadius; }
    public function set outerRadius(value:Number):void 
    {
        _outerRadius = value;
        draw();
    }
    private var _outerRadius:Number;
    
    
    
    /**
     * 
     */
    public function get innerRadius():Number { return _innerRadius; }
    public function set innerRadius(value:Number):void 
    {
        _innerRadius = value;
        draw();
    }
    private var _innerRadius:Number;
    
    
    
    /**
     * 
     */
    public function get fill():IGraphicsData { return _fill; }
    public function set fill(value:IGraphicsData):void 
    {
        _fill = value;
        draw();
    }
    private var _fill:IGraphicsData;
    
    
    
    /**
     * 
     */
    public function get stroke():IGraphicsData { return _stroke; }
    public function set stroke(value:IGraphicsData):void 
    {
        _stroke = value;
        draw();
    }
    private var _stroke:IGraphicsData;
    
    
    
    /**
     * 
     */
    public function Star( numVertex:uint, outerRadius:Number, innerRadius:Number, fill:IGraphicsData = null, stroke:IGraphicsData = null ):void {
        
        _numVertex   = numVertex;
        _outerRadius = outerRadius;
        _innerRadius = innerRadius;
        _fill        = fill;
        _stroke      = stroke;
        
        draw();
    }
    
 public function DrawText(x:Number
                                ,y:Number
                                ,z:String
                               ,position:uint):TextField{
     
            var tx:TextField = new TextField();
           
            //tx.visible=0;
            tx.text=z;
            //tx.visible=1;
            
            switch(position%3){
                case 1:
                    tx.autoSize="left";
                    tx.x=  x - tx.width/2;
                    break;
                case 2:
                    tx.autoSize="center";
                    tx.x=x-tx.textWidth/2;
                    break;
                case 0:
                    tx.autoSize="right";
                    tx.x=x-tx.textWidth;
                    break;
                default:
                    break;
            }
            switch(int((position-1)/3)){
                case 0:
                    tx.y= y - tx.height/2;
                    break;
                case 1:
                    tx.y=y-tx.textHeight/2;
                    break;
                case 2:
                    tx.y=y-tx.textHeight;
                    break;
                default:
                    break;
            }
            addChild(tx);

            return tx;
        }    
    
    
    
    
    
    
    private function draw():void {
       
       // ALL removeChildren
       while( numChildren ) removeChildAt( 0 ); 
        
        graphics.clear();
        
        
        var drawGraphicsData:Vector.<IGraphicsData> = Vector.<IGraphicsData>([ fill, stroke ]);
        
       
        
        // path
        var exteriorAngle:Number = Math.PI * 2 / numVertex;
        
        var pathData:Vector.<Point> = new Vector.<Point>();
        
        //for ( var i:uint = 0; i < numVertex; i++ ) {
            
            //pathData.push( new Point( Math.sin( exteriorAngle * i  ) * outerRadius, 0 + Math.cos( exteriorAngle * i  ) * outerRadius ) );
           // pathData.push( new Point( Math.sin( exteriorAngle * i ) * innerRadius, Math.cos( exteriorAngle * i ) * innerRadius ) );
        //}
        
        //var path:GraphicsPath = createGraphicsPathAtData( pathData );
        //drawGraphicsData.push( path );
        
        
      
       
         //draw
        graphics.drawGraphicsData( drawGraphicsData );
 for ( var i:uint = 0; i < numVertex; i++ ) {
       graphics.lineStyle(2, 0xFF0000, 1) 
       graphics.drawCircle(outerRadius*Math.sin( exteriorAngle*i) , outerRadius*Math.cos( exteriorAngle*i) ,15);
       graphics.lineStyle(1, 0xFF0000, 1)
 
       //just a test to see if .588 is really the boredistance at 5 holes
       if(numVertex==5){
            graphics.lineStyle(1, 0xcccccc, 1)
            graphics.drawCircle(outerRadius*Math.sin( exteriorAngle*i) , outerRadius*Math.cos( exteriorAngle*i),outerRadius*.587785*2);
       }
 
 
       graphics.lineStyle(1, 0x00ff00, 1)             
       graphics.moveTo(0 , 0);
       graphics.lineTo(outerRadius*Math.sin( exteriorAngle*i) , outerRadius*Math.cos( exteriorAngle*i));



       DrawText(outerRadius*Math.sin( exteriorAngle*i) , outerRadius*Math.cos( exteriorAngle*i),"Angle"+((180-(360/numVertex))/2),1);
       graphics.lineTo(outerRadius*Math.sin( exteriorAngle*(i-1)) , outerRadius*Math.cos( exteriorAngle*(i-1)));
       DrawText(0,10,"Angle"+360/numVertex,1);
       
      
 }
    
       graphics.lineStyle(1, 0xFF0000, 1)
       
           if(numVertex==3){
               DrawText(-100,125,"3 Holes, borecircle=boredistance / 0.866",5);
           }
           if(numVertex==4){
               DrawText(-100,125,"4 Holes, borecircle=boredistance / 0.707",5);
           }
           if(numVertex==5){
               DrawText(-100,125,"5 Holes, borecircle=boredistance / 0.588 \nboredistance = "+(outerRadius*0.587785),5); 
           }
           if(numVertex==6){
               DrawText(-100,125,"6 Holes, borecircle=boredistance / 0.5",5);
           }
           if(numVertex==8){
               DrawText(-100,125,"8 Holes, borecircle=boredistance / 0.383",5);
           }
           if(numVertex==10){
               DrawText(-100,125,"10 Holes, borecircle=boredistance / 0.309",5);
           }
           if(numVertex==12){
               DrawText(-100,125,"12 Holes, borecircle=boredistance / 0.259",5);
           }
           DrawText(-100,155,"r "+outerRadius,5);  
    }
    }
function createGraphicsPathAtData( pathData:Vector.<Point> ):GraphicsPath 
{
    var commands:Vector.<int> = new Vector.<int>();
    var data:Vector.<Number> = new Vector.<Number>();
    
    var pathDataLength:int = pathData.length; 
    
    for ( var i:uint = 0; i < pathDataLength; i++ ) {
        
        if( i != 0 )
            commands.push( GraphicsPathCommand.LINE_TO );
        else if( i == 0 )
            commands.push( GraphicsPathCommand.MOVE_TO );
        
        data.push( pathData[i].x, pathData[i].y );
    }
    
    commands.push( GraphicsPathCommand.LINE_TO );
    data.push( pathData[0].x, pathData[0].y );
    
    return new GraphicsPath( commands, data );
}







/* -----
 * component
 *//*
import com.bit101.components.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.easing.Cubic;
//*/
class LabelEx extends Label {
    
    /**
     * Dispatched after a control value is modified, unlike the textInput event, which is dispatched before the value is modified.
     * @eventType flash.events.Event.CHANGE
     */
    [Event(name = "change", type = "flash.events.Event")] 
    
    /**
     * ...
     * @eventType com.bit101.components.Component.DRAW
     */
    [Event(name = "draw", type = "com.bit101.components.Component")] 
    
    
    
    //private var textField:TextField;
    
    public function LabelEx(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0, text:String = ""):void
    {
        super(parent, xpos, ypos, text);
    }
    
    /**
     * Initializes the component.
     */
    override protected function init():void
    {
        super.init();
        setSize(100, 16);
    }
    
    /**
     * Creates and adds the child display objects of this component.
     */
    override protected function addChildren():void
    {
        super.addChildren();
        
        for ( var i:uint = 0; i < numChildren; i++ ) {
            
            var child:DisplayObject = getChildAt( i );
            
            if ( child is TextField ) {
                
                // textField = child as TextField;
                break;
            }
        }
    }
}

class InputTextEx extends InputText {
    
    /**
     * Dispatched after a control value is modified, unlike the textInput event, which is dispatched before the value is modified.
     * @eventType flash.events.Event.CHANGE
     */
    [Event(name = "change", type = "flash.events.Event")] 
    
    /**
     * ...
     * @eventType com.bit101.components.Component.DRAW
     */
    [Event(name = "draw", type = "com.bit101.components.Component")] 
    
    //private var textField:TextField;
    
    public function InputTextEx(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0, text:String = "", defaultHandler:Function = null)
    {
        super( parent, xpos, ypos, text, defaultHandler );
    }
    
    /**
     * Creates and adds child display objects.
     */
    override protected function addChildren():void
    {
        super.addChildren();
        
        for ( var i:uint = 0; i < numChildren; i++ ) {
            
            var child:DisplayObject = getChildAt( i );
            
            if ( child is TextField ) {
                
                //TextField = child as TextField;
                break;
            }
        }
        
        textField.autoSize = TextFieldAutoSize.LEFT;
    }
    
    protected override function onChange(event:Event):void
    {
        super.onChange( event );
        dispatchEvent( event );
    }
}

class HSliderEx extends HSlider {
    
    /**
     * Dispatched after a control value is modified, unlike the textInput event, which is dispatched before the value is modified.
     * @eventType flash.events.Event.CHANGE
     */
    [Event(name = "change", type = "flash.events.Event")] 
    
    /**
     * ...
     * @eventType com.bit101.components.Component.DRAW
     */
    [Event(name = "draw", type = "com.bit101.components.Component")] 
    
    public function HSliderEx(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number =  0, defaultHandler:Function = null):void
    {
        super(parent, xpos, ypos, defaultHandler);
    }
}

class InputTextAndHSlider extends Sprite {
    
    /**
     * Dispatched after a control value is modified, unlike the textInput event, which is dispatched before the value is modified.
     * @eventType flash.events.Event.CHANGE
     */
    [Event(name = "change", type = "flash.events.Event")]
    
    
    
    /**
     * label
     */
    public function get label():Label {
        
        return _label;
    }
    private var _label:Label;
    
    
    
    /**
     * inputText
     */
    public function get inputText():InputTextEx {
        
        return _inputText;
    }
    private var _inputText:InputTextEx;
    
    
    
    /**
     * hSlider
     */
    public function get hSlider():HSliderEx {
        
        return _hSlider;
    }
    private var _hSlider:HSliderEx;
    
    
    
    /**
     * round
     */
    public var round:int = 20;
    
    
    
    /**
     * value
     */
    public function get value():Number {
        
        return _value;
    }
    public function set value( tempValue:Number ):void {
        
        hSlider.value = tempValue;
        
        _value = Math.round( hSlider.value * Math.pow( 10, round ) ) / Math.pow( 10, round );
        
        if ( !isNaN( value ) )
            inputText.text = value.toString();
        
        dispatchEvent( new Event( Event.CHANGE ) );
    }
    private var _value:Number;
    
    
    
    /**
     * 
     * @param    parent
     * @param    xpos
     * @param    ypos
     * @param    text
     */
    public function InputTextAndHSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, text:String = ""):void
    {
        parent.addChild( this );
        x = xpos;
        y = ypos;
        
        // label
        _label = new LabelEx( this, 0, 0, text );
        
        // inputText
        _inputText = new InputTextEx( this );
        inputText.restrict = "-0-9.";
        updateInputTextPosition( label );
        
        // hSlider
        _hSlider = new HSliderEx( this );
        hSlider.backClick = true;
        updateHSliderPosition( inputText );
        
        
        
        // hSlider eventlistener
        label.addEventListener(Component.DRAW, function( event:Event ):void {
                updateInputTextPosition( label );
            } );
        
        // inputText eventlistener
        inputText.addEventListener(Event.CHANGE, function( event:Event ):void {
                value = parseFloat( inputText.text );
            } );
        inputText.addEventListener(Component.DRAW, function( event:Event ):void {
                updateHSliderPosition( inputText );
            } );
        inputText.addEventListener(FocusEvent.FOCUS_OUT, function( event:FocusEvent ):void {
                if ( isNaN( value ) )
                    inputText.text = "0";
            } );
        
        // hSlider eventlistener
        hSlider.addEventListener(Event.CHANGE, function( event:Event ):void {
                value = hSlider.value;
            } );
    }
    
    
    
    /**
     * 
     * @param    component
     */
    private function updateInputTextPosition( component:DisplayObject ):void {
        
        inputText.y = component.y + ( component.height - inputText.height ) / 2;
        inputText.x = ( component.x + component.width ) + ( inputText.y - component.y );
    }
    
    
    
    /**
     * 
     * @param    component
     */
    private function updateHSliderPosition( component:Component ):void {
        
        hSlider.y = component.y + ( component.height - hSlider.height ) / 2;
        hSlider.x = ( component.x + component.width ) + ( hSlider.y - component.y );
    }
}



class ClearColorPanel extends Sprite {
    
    private var _backgroundColor:Number;
    public function get backgroundColor():Number { return _backgroundColor; }
    public function set backgroundColor(value:Number):void 
    {
        _backgroundColor = value;
        draw();
    }
    
    
    
    private var _backgroundAlpha:Number;
    public function get backgroundAlpha():Number { return _backgroundAlpha; }
    public function set backgroundAlpha(value:Number):void 
    {
        _backgroundAlpha = value;
        draw();
    }
    
    private var _width:Number;
    public override function get width():Number { return _width; }
    public override function set width(value:Number):void 
    {
        _width = value;
        draw();
    }
    
    private var _height:Number;
    public override function get height():Number { return _height; }
    public override function set height(value:Number):void 
    {
        _height = value;
        draw();
    }
    
    
    
    
    
    public function ClearColorPanel( x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, alpha:Number = 1, backgroundColor:int = 0, backgroundAlpha:Number = 0.1 ) {
        
        this.x = x;
        this.y = y;
        _width = width;
        _height = height;
        this.alpha = alpha;
        _backgroundColor = backgroundColor;
        _backgroundAlpha = backgroundAlpha;
        
        draw();
    }
    
    public function draw():void {
        
        graphics.clear();
        graphics.beginFill( backgroundColor, backgroundAlpha );
        graphics.drawRect(0, 0, width, height );
        graphics.drawCircle(10,x,y);
        graphics.endFill();
    }
}

class SlidePanel extends Sprite {
    
    private var panel:ClearColorPanel;
    private var openCloseSwitchButton:PushButton;
    private var open:Boolean;
    
    
    public override function set width(value:Number):void 
    {
        super.width = value;
        panel.width = value;
        openCloseSwitchButton.x = width - 20;
    }
    
    public override function set height(value:Number):void 
    {
        super.height = height;
        panel.height = value;
    }
    
    
    public function SlidePanel( x:Number = 0, y:Number = 0, width:Number = 0, height:Number = 0, alpha:Number = 1, backgroundColor:int = 0, backgroundAlpha:Number = 0.1 ) {
        
        this.x = x;
        this.y = y;
        
        panel = new ClearColorPanel( 0, 0, width, height, alpha, backgroundColor, backgroundAlpha );
        super.addChild( panel );
        
        openCloseSwitchButton = new PushButton(super, width - 20, 0);
        super.addChild( openCloseSwitchButton );
        openCloseSwitchButton.width = 20;
        openCloseSwitchButton.addEventListener(MouseEvent.CLICK, openCloseSwitchButtonClickHandler );
        
        openCloseSwitchButton.label = "-";
        open = true;
    }
    
    private function openCloseSwitchButtonClickHandler( event:MouseEvent ):void {
        
        // hide
        if ( open )
            show();
            
        // show
        else
            hide();
    }
    
    private function show():void {
        
        open = false;
        openCloseSwitchButton.label = "+";
        BetweenAS3.tween(panel, {y: -panel.height}, null, 0.5, Cubic.easeInOut ).play();
    }
    
    private function hide():void {
        
        open = true;
        openCloseSwitchButton.label = "-";
        BetweenAS3.tween(panel, { y: 0 }, null, 0.5, Cubic.easeInOut ).play();
    }
    
    
    override public function addChild(child:DisplayObject):DisplayObject 
    {
        return panel.addChild(child);
    }
    
    override public function addChildAt(child:DisplayObject, index:int):DisplayObject 
    {
        return panel.addChildAt(child, index);
    }
    
    
    
    
    
}