The ball example that I did is slow in IE7 on my windows vista.
When I open the swf in the browser on IE and on Safari it is also slow.
In Firefox,opera,safari it is fast when embedded in a page.
When I open the swf in the browser on firefox 2, it starts fast and then goes slow.
In opera when It is embedded in a page it is fast, and when I open it in a browser it is also fast!
Showing posts with label Actionscript. Show all posts
Showing posts with label Actionscript. Show all posts
Monday, February 11, 2008
Sunday, February 10, 2008
Actionscript 3.0 Timer and key events
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
Friday, January 18, 2008
Thursday, January 3, 2008
Flash Flex Actionscript SWF mxmlc compiler
I thought it was cool that you can compile .as files into SWF format without purchasing swf software. Thats cool!
I downloaded the Flex 2 SDK (you can download it here http://www.adobe.com/products/flex/downloads/)
I opened the readme and tried to understand it a little. Unfortunately it wasn't simple enough for me to understand, so I kind of gave up for a while.
However, using Google I found this site Beginners Guide to Getting Started with AS3 (Without Learning Flex).
Wow! that person explained it so well. He gives exapmles of .as files and how to compile them.
The simplest way that he says it is to drag your .as file over the mxmlc.exe file.
If there are errors in your actionscript code, you wont be able to see them
Quoting from his site, here is a simple example of an Actionscript file (.as)
I downloaded the Flex 2 SDK (you can download it here http://www.adobe.com/products/flex/downloads/)
I opened the readme and tried to understand it a little. Unfortunately it wasn't simple enough for me to understand, so I kind of gave up for a while.
However, using Google I found this site Beginners Guide to Getting Started with AS3 (Without Learning Flex).
Wow! that person explained it so well. He gives exapmles of .as files and how to compile them.
The simplest way that he says it is to drag your .as file over the mxmlc.exe file.
If there are errors in your actionscript code, you wont be able to see them
Quoting from his site, here is a simple example of an Actionscript file (.as)
package {
import flash.display.Sprite;
import flash.text.TextField;
public class HelloWorld extends Sprite {
public function HelloWorld() {
var display_txt:TextField = new TextField();
display_txt.text = "Hello World!";
addChild(display_txt);
}
}
}
Subscribe to:
Posts (Atom)