By Zevan | December 20, 2008
CLICK HERE TO COPY
Actionscript:
var currentBtn:MovieClip;
var nav:Sprite = new Sprite();
nav.x = nav.y = 20;
addChild(nav);
createBtns();
nav.addEventListener(MouseEvent.CLICK, onClickBtn);
function createBtns():void{
for (var i:int = 0; i<10; i++){
var btn:MovieClip = new MovieClip();
with(btn.graphics) beginFill(0x666666), drawRect(-10,-10,20,20);
btn.x = i * (btn.width + 10);
btn.buttonMode = true;
[...]
By Zevan | December 19, 2008
CLICK HERE TO COPY
Actionscript:
var file:FileReference = new FileReference();
stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void {
file.save("some text. \nsome more text", "actionsnippet.txt");
}
This is possibly my favorite feature of flash 10. Save any kind of file to the users computer...
The first argument is for the data to put in the file, this can be a String, ByteArray or XML [...]
Posted in misc | Tagged actionscript, flash |
By Zevan | December 18, 2008
CLICK HERE TO COPY
Actionscript:
addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
var boolA:Boolean = false;
var boolB:Boolean = false;
if (mouseX> 200){
boolA = true;
}else{
boolA = false;
}
if (mouseY <200){
boolB = true
}else{
[...]
By Zevan | December 17, 2008
CLICK HERE TO COPY
Actionscript:
trace((new Date()).getTime() + Math.random()*0xFFFFFF);
A hacky way to get a unique ID, although this isn't, perfect it works well enough. For a project that you really expect to get huge amounts of traffic... you might consider using php's uniqid() function and passing it into your swf. That said, the odds of two users [...]