Author Archives: Zevan

HTML5 Canvas Tutorial

If you haven’t tried the html5 canvas tag yet, I suggest you give it a try. It falls under the same category as ActionScript’s Graphics and BitmapData classes. It is however much much simpler. One great thing about it is it runs really fast on IOS5. Have a look at some of these demos to [...]

Posted in html5, javascript | Tagged , , , , | Leave a comment

Gumowski/Mira Pseudo-Soundwave

CLICK HERE TO COPY
Actionscript:

[SWF(width = 600, height = 600)]

var a:Number = 0.02;

var b:Number = .9998;

 

var xn1:Number = 5;

var yn1:Number = 0;

var xn:Number, yn:Number;

 

var scale:Number = 10;

var iterations:Number = 20000;

var step:Number = stage.stageWidth / iterations;

 

function f(x:Number):Number{

    var x2:Number = x * x;

    return a * x + (2 * (1 - a) * x2) [...]

Posted in BitmapData, Graphics, Math, graphics algorithms | Leave a comment

Closest Point on a Line

CLICK HERE TO COPY
Actionscript:

// from

// http://www.gamedev.net/topic/444154-closest-point-on-a-line/

 

function getClosestPoint(A:*, B:*, P:*, segmentClamp:Boolean=true):Point {

    var AP:Point = new Point(P.x - A.x, P.y - A.y),

        AB:Point = new Point(B.x - A.x, B.y - A.y);

    var ab2:Number=AB.x*AB.x+AB.y*AB.y;

    var ap_ab:Number=AP.x*AB.x+AP.y*AB.y;

    var t:Number=ap_ab/ab2;

    if (segmentClamp) {

        if (t<0.0) {

      [...]

Posted in Math | Leave a comment

Stereoscopic Papervision

Cross your eyes to see 3D third image:

Posted in 3D | Tagged | 1 Comment

ActionSnippet.zip

Who would like a zip of the folder I used when making this site fla files and all? If you want one, post a comment and I'll send it to you.
Actually have a little new content for the site coming, at least one new post.
If you don't get yours within a day of posting... just [...]

Posted in Uncategorized | 43 Comments

New Site zReference

Actionsnippet has been pretty inactive for the last few months. I took a short break from blogging, but I'm starting up again on a new site... go check it out: zReference

Posted in misc | Tagged | 3 Comments

Quick IE Test

Found this today, not related to actionscript but rather nice. It allows you to take a screen shot of your website in IE... if your on a mac without windows this is a quick way to test in a pinch:
http://ipinfo.info/netrenderer/index.php

Posted in Uncategorized | 6 Comments

Circle Fitting

CLICK HERE TO COPY
Actionscript:

var circs:Array = []

var circNum:int = 600;

addEventListener(Event.ENTER_FRAME, onAdd);

function onAdd(evt:Event):void {

    if (circs.length <circNum){

        makeGrowable();

    }

}

 

function makeGrowable(){

   

    var s:MovieClip = MovieClip(addChild(new MovieClip()));

    s.x = Math.random() * stage.stageWidth;

    s.y = Math.random() * stage.stageHeight;

    with(s.graphics){

        lineStyle(0,0);

        drawCircle(0,0,10);

    [...]

Posted in Graphics, misc, motion | Tagged , , , | 6 Comments

Fill in the Blank

CLICK HERE TO COPY
Actionscript:

var story:String = "Fill in the _____.";

 

 

var txt:TextField = new TextField();

txt.defaultTextFormat = new TextFormat("Georgia", 20);

txt.width = stage.stageWidth;

txt.multiline = true;

txt.wordWrap = true;

txt.text = story;

addChild(txt);

 

var alph:Array = "abcdefghijklmnopqrstuvwxyz".split("");

var keys:Object = {};

for (var i:int = 0; i<alph.length; i++){

    keys[65 + i] = alph[i];

}

stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);

function onKeyPressed(evt:KeyboardEvent):void{

     

    if (evt.keyCode == Keyboard.ENTER){

      [...]

Posted in TextField, UI | Tagged , , | 3 Comments

Epicycloid Again

CLICK HERE TO COPY
Actionscript:

var xp:Number = 0;

var yp:Number = 0;

var t:Number = 0;

var a:Number = 100;

var b:Number = 10;

x = stage.stageWidth / 2;

y = stage.stageHeight / 2;

 

graphics.lineStyle(0,0x000000);

addEventListener(Event.ENTER_FRAME, onRun);

function onRun(evt:Event):void {

    var p:Number = ((a + b)/b)*t

    xp = (a + b) * Math.cos(t) - b * Math.cos(p);

    yp = (a + b) [...]

Posted in Uncategorized | Tagged , , | 1 Comment