niedziela, 7 listopada 2010

Movable popups - for other components than TitleWindow

Creating draggable/movable popup window in Flash Builder 4 is an easy task as long as you use TitleWindow component and, of course, PopUpManager class which, as I thought, handles the dragging part - but that's not the case! It is, in fact, implemented in TitleWindow class, so if you want to have draggable custom component inheriting from Group for example, you have to handle it Yourself.

Additionally if You want to go other way around - prevent TitleWindow from moving - you can set the titleWindow.moveArea visible property to 'false'

As I needed this for my own project, I've created a MovableGroup component (based on Group component). I copied most of the code from the TitleWidow, so it has the same properties, and generates the same events(windowMoveStart,windowMoving,windowMove,windowMoveEnd), so I can't say I wrote it realy ;). Maybe it'll be usefull for someone - the source is attached.

The main difference is that the moveArea (skin element, that is default the titleBar in TitleWindow) is set as 'this' by default (so you can move the component by clicking anywhere on it) - you can change it of course and set a diffrent InteractiveObject


czwartek, 18 marca 2010

Actionscript class to calculate sunrise and sunset time

Here is a simple Actionscript class that calculates the sunrise and sunset time for given date and coordinates ( latitude , longitude ) . It's based on the algorithm I found on National Oceanic & Atmospheric Administration , and implemented in AS.

It seems to generate accurate results, but I have not tested it extensively..

It needs some improvements (like DST, and solar noon calculation), and I should improve it soon I hope ;).

I'd like to put up an example of usage using google maps in the next few days if I'll have some time for it..

SunriseSunsetCalculator.as

wtorek, 9 marca 2010

mp4 h.264 netstream buffering problem

As I was creating a simple video queue class to pre-buffer the video content, I couldn't get the videos to play until the whole movie loaded, the "NetStream.Buffer.Full" was triggered when whole movie downloaded. Setting different values of bufferTime on stream object didn't helped.

The problem as it occurred after some googling, was the encoding. I used h.264 mp4's for all my videos, and in my ignorance I didn't know they act differently from plain old flv.

For h.264 encoded videos to buffer properly "the "moov atom" needs to be located at the beginning of the file. ", as I just discovered in David Hassoun's article "Exploring Flash Player support for high-definition H.264 video and AAC audio" (page 2)

The tools the author pointed to fix the problem are:
I haven't tried them out yet, but I hope one of them will fix the problem..
Just a quick note from the battlefield ;)