Posts Tagged 'wonderfl'

How to check if URL is not MP3 ?

Since flash player can’t send HEAD requests, you have to resort to dirty tricks if you want to check URL content type. In this example, we are going to try and figure out if some URL points to playable sound. Since we’re dealing with unknown URL, chances are that its domain does not permit us to access raw data, so we can’t really use URLLoader – we need to actually load whatever URL points to into Sound object. However, if you thought that you could just catch i/o error 2124, like you would do with image Loader, for example, you’re in for big surprise: it does not fire. Instead, Sound object fires progress and complete events, and is even happy to play (although you will not hear any noise, or anything at all).

So, how do we detect that our Sound object is actually broken? First thing you’ll notice is that even after complete event it is still buffering. Unusual, but the same thing happens with really short sounds, so this check is not reliable. The other thing is that extract() method obviously fails to return any samples. This in itself is again not enough, since it does happen with partially loaded sounds too. However, the combination of the two seems to hit the nail:

private function onComplete(e:Event):void {
   var s:Sound = e.target as Sound;
   if (s.isBuffering && (s.extract(new ByteArray(), 1, 0) < 1)) {
      // url does not point to playable sound
   }
}

See this method in action at wonderfl.net :)

Less than two weeks left to enter COLT contest

Last chance :)Just to remind you all, free COLT license + a chance to win some Apple hardware are only available until June 25. So download COLT, make your video, upload to youtube, send us the link. Do it now! While you still can :)

No, seriously. We’re very curious to see what kind of crazy ideas people can come up with. Check out this latest submission going wild with Kinect API and Away3D.

By the way, huge thanks goes to wonderfl.net for spreading the word free of charge:

we love Flash and Web developers community… so we’re gonna show your ads for Free (Masakazu Ohtsuka, KAYAC Inc)

Flash and Web developers, we at Code Orchestra love you too! And we hate when you waste your time compiling stuff. In fact, we hate it so much that next COLT release will build your projects up to 3 times faster (and we are talking both livecoding and production builds here). While these news are relevant to Windows users only, I’m sure there are lots of FlashDevelop users out there who will enjoy faster builds OOTB (if they install my COLT plugin).

[ᴘᴏʟʟ] Left or right?

What is better way to fill Mandelbrot exterior? Colors were intentionally left dull, please vote for best geometry:

left or right?

In case you want to check more locations, click here.

Picking random points in elliptic arc or sector

This was the result of random flashkit thread encounter and has no much real life value, probably. The closest thing I found to what that guy was asking for was this 2009 post explaining the trick to pick random point in the circle, but it is remarkably easy to extend it to the ellipse, or even arbitrary elliptic arc or sector. It is interesting in that you pick correct point on 1st try versus, for example, 4/π ≈ 1.27-th try if you simply select random point in ellipse bounding box and reject outliers – and some extra Math.xxx calls pay for that.

How to draw numbered billiard balls

This blog desperately needs more posts, but I hardly have any subjects to write at length about. And this is where wonderfl comes to the rescue – some of those codes are so complicated that one could give two hours talk about them. This code is that kind of code, and tonight I am going to explain just one small part of it – drawing numbered billiard balls. Continue reading ‘How to draw numbered billiard balls’


Old stuff

July 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Oh, btw…