Category Archives: flex 3

Flex 3 NetStream video rotation

Why should I rotate a video stream?

Well if you’d like to make some video upload application, let’s assume someone makes a video with it’s phone. The case with a video camera is not the same, almost every camera adjusts it’s rotation correctly, but when it comes to your mobile not always the video contains information about the rotation.

The problem is when the user uploads a rotated video, how I’d rotate it back on the correct position when playing it with a simple FLV player.

The answer is so simple!

You can just use this simple chunk of code:

_video = new Video();
_video.rotation = 90;

and thus you can rotate the video with several degrees.

Passing objects with ExternalInterface from JS to Flex

What if you’d like to pass an object to Flex

To continue the topic of my previous post I’m just going to add that there’s a native way to pass objects from JavaScript to Flex’s actionscript.

I’m not going to describe how to structure a object in JavaScript and/or Flex. Let’s go directly to the example.

The function in .js file should return something that is object in JavaScript:

.js file

function getObject() {
    return { foo : 'bar', zoo : 'tar' };

Continue reading Passing objects with ExternalInterface from JS to Flex

Tips and tricks in ExternalInterface communication!

ActionScript and the rest of the world

In the past, when ActionScript v2 was widely used, the most common way to interact with the other parts of the web application, whether a page refresh, redirect or JavaScript method call was the as2 method getURL. With the simple getURL(‘javascript:someJSMethod…’) the flash movie called the JS function and everything was OK.

Now in ActionScript v3 where everything looks and it is different, everything about communication between JS and Flash/Flex is done by ExternalInterface. The communication can be done in both directions. From JS to Flash and vice versa.


There are two simple methods implemented by ExternalInteface. The first one is addCallback and the second one is call. Here I’m going to write a little more about the second one.

The most common usage is:'jsMethod');

where jsMethod is, as you can guess, a JavaScript method. Something like:


function jsMethod() { alert('test') };

A bit different, but yet again simple, is the call to a js function with parameters:'jsMethod', param1, param2);

where the javascript function can be:

function jsMethod(param1, param2) { alert(param1) };

But what I was writing about is really tricky. What if the jsMethod returns a value? Than in the .js file you’ve the following method:

function jsMethod() { return 'foo bar' };

and when you try this:

var str:String ='jsMethod');;

you get the alert box with the string ‘foo bar’.

Where to use it?

Well this is really useful, because you get the response within the call method, only with the .call instead with .call and than .addCallback. The problem of course appears when you try to use it with AJAX call. Than even if the function returns in the success method of the AJAX call the flash doesn’t get the response.

Than you simply implement the communication with both .call and .addCallback!

ExternalInterface from JavaScript to IE/Firefox

ExternalInterface communication with JavaScript

The most simple way to describe the case is as if you have the ExternalInterface addCallback in the Flex application like that:


ExternalInterface.addCallback("jsFunc", flexFunc);

public flexFunc() : void
{ ... }

and in the javascript code you’ve something like that: Continue reading ExternalInterface from JavaScript to IE/Firefox

Flex 3 DateChooser UTC issue

What I intend to do

The task can be described as it is. There’s a Flex 3 DateChooser component integrated with a custom timeline component. The problem occurs when exporting the data from the flash to the browser. Than I write the unix timestamp to the url of the browser. Of course I’m using date.getTime() in Flex.


Applying getTime() to any object of type Date in Flex results in a unix timestamp with included milliseconds. Of course the server side technology which in our case is PHP should devide by 1000 to remove the milliseconds. Continue reading Flex 3 DateChooser UTC issue