/**
* Copyright greentec ( http://wonderfl.net/user/greentec )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/iFnP
*/
package {
import flash.events.Event;
import flash.display.Sprite;
import flash.text.*;
import flash.events.MouseEvent;
import com.bit101.components.Slider;
public class FlashTest extends Sprite {
public var i:uint;
public var val:Number=0.5+Math.random()*0.4;
public var xst_:int=30;
public var yst_:int=300;
public var n:uint=250;
public var s:Slider;
public var t2:TextField
public function FlashTest() {
s=new Slider(Slider.HORIZONTAL,this,0,0,onClick);
s.maximum=0.9;
s.minimum=0.1;
s.value=val;
s.x=50;
s.y=360;
s.backClick=true;
addChild(s);
draw();
var f:TextFormat=new TextFormat();
f.size=20;
var t:TextField=new TextField();
t.defaultTextFormat=f;
t.width=300;
t.text="y=4x(1-x) : logistic equation";
t.x=40;
t.y=330;
t.mouseEnabled=false;
addChild(t);
t2=new TextField();
t2.defaultTextFormat=f;
t2.width=100;
t2.text=String(s.value);
t2.x=50;
t2.y=375;
t2.textColor=0x0000ff;
addChild(t2);
stage.addEventListener(MouseEvent.MOUSE_UP,onClick);
}
public function draw():void
{
graphics.lineStyle(0,0,1);
graphics.moveTo(xst_,yst_);
for(i=0;i<n;i++)
{
val=4*val*(1-val);//chaos equation : y=4x(1-x)
graphics.lineTo(xst_+i*1.5,yst_-(val*200));
}
}
public function onClick(e:Event=null):void
{
graphics.clear();
val=s.value;
t2.text=String(val);
draw();
}
}
}