Java LiveConnect part 3 : Flash Test
James Polanco contributed an ActionScript version of this code. Just like the Java version, aside from a small amount of boiler plate connection code and small syntactical changes, it’s the same code. Weighing in at a svelte 694 bytes and taking just 215ms to execute, this version is the clear winner.
The ActionScript (Flash) version:
package {
import flash.display.Sprite;
import flash.external.ExternalInterface;
public
{
public
{
// create external interace
ExternalInterface.addCallback("countPrimes", countPrimes);
}
public :int
{
var i:int, c:int, prime_count:int = 2;
for(i = 2; i < size; i++)
{
for(c = 2; c < i; c++)
{
if(i % c == 0)
{
prime_count++;
break;
}
}
}
return prime_count;
}
}
}