flash on 2012-11-18
/**
* Copyright DakeNemui ( http://wonderfl.net/user/DakeNemui )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wdC3
*/
package {
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.text.TextField;
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
import flash.utils.getTimer;
var gravity_text:TextField = new TextField();
var show_me_the_information_please:TextField = new TextField();
var difference_text:TextField = new TextField();
/information speed/
var real_time:Boolean = true;
var timer:Timer = new Timer(4000);
show_me_the_information_please.x = 110;
show_me_the_information_please.y = 20;
show_me_the_information_please.height = 500;
show_me_the_information_please.width = 700;
show_me_the_information_please.selectable = false;
var SPRITE_1:Sprite = new Sprite();
SPRITE_1.graphics.beginFill(0x000000);
SPRITE_1.graphics.drawCircle(0,0,25);
SPRITE_1.x = 70;
SPRITE_1.y = 429;
var gravity:Number = 0.00030;
var dx:Number = 0.0;
var dy:Number = -.5;
var lastTime:int = getTimer();
addEventListener(Event.ENTER_FRAME, animateBall);
if ( real_time == false )
timer.start();
show_me_the_information_please.text = "gravity : "+(int)(gravity*10001)+"m/s"+'\n'+"difference : "+timeDiff+'\n'+'\n'+"y : "+SPRITE_1.y+'\n'+"dy : "+dy;
show_me_the_information_please.appendText('\n'+"dy*diff : "+timeDiff*dy+'\n'+'\n'+"x : "+SPRITE_1.x+'\n'+"dx : "+dx+'\n'+"dx*diff : "+timeDiff*dx);
addChild(show_me_the_information_please);
var timeDiff:int = getTimer() - lastTime;
function animateBall(event:Event) : void
{
timeDiff = getTimer() - lastTime;
lastTime += timeDiff;
dy += timeDiff * gravity;
timer.addEventListener(TimerEvent.TIMER,information);
if ( real_time == true )
information_real();
if ( SPRITE_1.y <= 430 )
{
SPRITE_1.x += timeDiff * dx;
SPRITE_1.y += timeDiff * dy;
}
else
{
dy = -.5;
SPRITE_1.y = 429;
}
}
function information(event:TimerEvent) : void
{
show_me_the_information_please.text = "gravity : "+(int)(gravity*10001)+"m/s"+'\n'+"difference : "+timeDiff+'\n'+'\n'+"y : "+SPRITE_1.y+'\n'+"dy : "+dy;
show_me_the_information_please.appendText('\n'+"dy*diff : "+timeDiff*dy+'\n'+'\n'+"x : "+SPRITE_1.x+'\n'+"dx : "+dx+'\n'+"dx*diff : "+timeDiff*dx);
addChild(show_me_the_information_please);
}
function information_real() : void
{
show_me_the_information_please.text = "gravity : "+(int)(gravity*10001)+"m/s"+'\n'+"difference : "+timeDiff+'\n'+'\n'+"y : "+SPRITE_1.y+'\n'+"dy : "+dy;
show_me_the_information_please.appendText('\n'+"dy*diff : "+timeDiff*dy+'\n'+'\n'+"x : "+SPRITE_1.x+'\n'+"dx : "+dx+'\n'+"dx*diff : "+timeDiff*dx);
addChild(show_me_the_information_please);
}
addChild(SPRITE_1);
addChild(show_me_the_information_please);
}
}
}