THE PASZ.COM BLOG

Thursday, June 14, 2007

Some Ugly Flash Code

This code truly encapsulates some of the worst features of the ActionScript 2 APIs. Guess what it does...


var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
video_1.attachVideo(stream_ns);
stream_ns.play("1.flv");
attachAudio(stream_ns);
var audio_sound:Sound = new Sound(this);
audio_sound.setVolume(0);


.
.
.
.
.
.
.
ANSWER: It loads an external FLV and mutes its volume.

Today, for the first time I had to do exactly that (in the past I always used a component, or embedded video). It seems pretty ridiculous that I have to instantiate 4 object -- NetConnection, NetStreem, Sound and a Video object you have to create in the library -- to achieve this basic goal. The documentation of these APIs is also pretty poor. I only figured out the muting part by scouring random message boards that Google coughed up. Yeesh!

I also had a lot of trouble getting this to work with MTASC. It looks like the best approach will be to create a standalone video playback module that I load into my main project.

If you need to deal with this stuff, I recommend this blog post, which has some good tidbits in the discussion.

Preloading Images in JavaScript

Ok, this may be old news for some people, but since I'm working in Flash about 90% of the time these days, I'm always looking for tricks to make my life easier when I have to do JavaScript stuff. Here's a function that will preload an array of images:

function imagePreLoad(images)
{
    var image = new Array();

    for (var i = 0; i < images.length; i++)
    {
        image[i] = new Image();
        image[i].src = images[i];
    }
}


Now here's a question: Is it possible to update the progress of the download or fire a callback when it's complete, like you can do in Flash?

Monday, June 11, 2007

Improved Full Screen Mode in Flash 9

There is certainly an abundance of riches on Adobe Labs this morning. But perhaps lost in the shuffle is news from the Flash Player team about an improved full screen mode that uses hardware acceleration to improve performance. Hopefully this will improve video performance in full screen mode. Perhaps it is also a small step toward getting 3D hardware acceleration into Flash.

Kaourantin.net has more info.