Category Archives: micro tutorial

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.

Toggle the visibility with jQuery

When it comes to quick JavaScriopt effects one of the most common is to hide and show different elements in the DOM. That occurs in almost every site. If there’s a dynamic menu, there’s for sure attached mouse event that shows/hides some sub menus and so on.

Of course you can achieve this in both jQuery and pure JavaScript approaches. If you use JS it’s something like that;

document.getElementById('element_id').style.display = 'block';
document.getElementById('element_id').style.display = 'none';

where the first row shows how to show an element, and the second one how to hide it in turn. Continue reading Toggle the visibility with jQuery →

Writing a jQuery plugin – (part 1). Good practices!

JavaScript flexibility

In JS you have the natural flexibility to extend an object you have previously declared. Even more you can extend any native objects! That makes the writing of a jQuery, or whatever javascript library, plugins to be very easy.

As you may know in JS you can have object declared like that:

var obj = { a : 1, b : 2 };

That is an object with two properties a and b which values are respectively 1 and 2. If you’d like to extend this object later you can just write:

obj.c = 3

and now the object looks like that:

{ a : 1, b : 2, c : 3 }

That’s perfect when you’d like to write plugins to jQuery. Continue reading Writing a jQuery plugin – (part 1). Good practices! →

jQuery CSS functions. Part 1 – offset()

What are jQuery CSS functions?

Well these are function which help you modify different CSS properties with JavaScript. You know you can do that in “pure” evangelistic JS, but normally every library comes with its own bunch of functions that do the job. In fact in jQuery the things are little bit more complicated because the returned value of those CSS modifiers is yet again a object of the element you modify, which is the same object as this you’ve selected with one of the selectors in jQuery.

This is extremely useful when it comes to chains and you chain several functions using the dot operator. Thus you call more and more functions for every selector and perform a modifier every time you call them.

Continue reading jQuery CSS functions. Part 1 – offset() →