Latest Publications

Shuffle text menu

This is text shuffle class that will help you make a nice flash menu for your site or your applications. I got inspired from a similar class made by Lee Brimelow. You can use it for open source or commercial projects (do anything you want).

Get Adobe Flash player

  text_shuffle.zip (20.8 KiB, 43 hits)

Simple AS3 mp3 player

Last night I was browsing around 365psd.com and I found a very interesting design for an mp3 player. Then I thought it would be a good idea to make it functional with Flash and ActionScript 3.0 and then share it for free on my blog :D

Source files:

  mp3_player.zip (1.4 MiB, 88 hits)

YouTube Playlist Reader

Just wanted to let you guys know that I’ve been working on a YouTube playlist reader (based on the ActionScript 3 YouTube API). With this custom player you can send a YouTube playlist ID and the player will generate the list of videos with thumbnails and other info about the videos.

Just check it out and let me know what you think ;)

UserBooth.com is now live

We just lunched UserBooth.com. Please give us a lot of feedback so we can develop neat features and build the best flash webcam application :)

Password protected content in Flash with ActionScript 3 and PHP

This morning I was browsing through the gotoAndLearn forum and I saw a question about how to make a password protected section in a Flash site. So, I made a quick example and I thought I should share it with all my readers too ;)

You can download the source files from here:

  Password Protected Flash Content (800.5 KiB, 537 hits)

Here you can see the ActionScript 3 code:

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.showDefaultContextMenu = false;
 
//path to the php file on your server
var phpPath:String = "login.php";
 
//make password text field (when you type the characters will be like "******")
pass.displayAsPassword = true;
 
login.addEventListener(MouseEvent.MOUSE_DOWN, loginDown);
 
function loginDown(e:MouseEvent):void{
	//check to see if something in both the user and pass text fields
	if (user.text != "" && pass.text != "") {
		sendLoadData();
	}else{
		trace("Please fill in both username and password");
	}
}
stop();
 
function sendLoadData():void
{
	var dataRequest:URLRequest = new URLRequest(phpPath);
	dataRequest.method = URLRequestMethod.POST;				
 
	// define the custom parameters that will be sent to the .php file
	var params:URLVariables = new URLVariables();
	params.user = user.text;
	params.pass = pass.text;
 
	dataRequest.data = params;
 
	var urlLoader:URLLoader = new URLLoader();
	urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
	urlLoader.addEventListener(Event.COMPLETE, urlLoaderComplete);
 
	try
	{
		urlLoader.load(dataRequest);
	}
	catch (event:Error)
	{
		trace("Incorrect PHP file path.");
	}
}
 
function urlLoaderComplete(event:Event):void
{
	// once all the data has been sent and we'll check for a message sent
	// from the php file to tell us if the operation has ended with success or not
	errorHandler(event.target.data.secure_response);
}
 
function errorHandler(message:Number):void
{
	// check the message that was sent back from the php file
	//trace(message)
	if (message == 1)
	{
		gotoAndStop(2);
	}
	else
	{
		trace("Wrong Username or Password");
	}
}

And here you have the PHP code:

<?
//Your set username and password
$username = "vamapaull";
$password = "mypassword";
 
 
//Variables received from ActionScript
$user=$_POST['user'];
$pass=$_POST['pass'];
 
 
//Chack them against each other
if ($user == $username && $pass == $password){
	print "secure_response=1";
}else{
	print "secure_response=2";
}
 
?>

ActionScript 3 YouTube feed application

A few days ago I made a little application based on the new ActionScript 3 YouTube API and I thought I should share it with those who want to get started with this type of players. In the future I plan to make some more complex applications based on this API so I can sell them on ActiveDen.net

Here you can see the code:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
 
Security.allowDomain("youtube.com","http://youtube.com","www.youtube.com");
 
 
var feedName:String = "MyDamnChannel";
 
 
// This will hold the API player instance once it is initialized.
var player:Object;
 
var playerLoader:Loader = new Loader();
playerLoader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
playerLoader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3"));
 
function onLoaderInit(event:Event):void {
	addChild(playerLoader);
	playerLoader.content.addEventListener("onReady", onPlayerReady);
	playerLoader.content.addEventListener("onError", onPlayerError);
	playerLoader.content.addEventListener("onStateChange", onPlayerStateChange);
	playerLoader.content.addEventListener("onPlaybackQualityChange", 
		onVideoPlaybackQualityChange);
}
 
function onPlayerReady(event:Event):void {
	// Event.data contains the event parameter, which is the Player API ID 
	//trace("player ready:", Object(event).data);
 
	// Once this event has been dispatched by the player, we can use
	// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
	// to load a particular YouTube video.
	player = playerLoader.content;
	player.x = 300;
	player.y = 30;
	player.setSize(580,345);
}
 
function onPlayerError(event:Event):void {
	// Event.data contains the event parameter, which is the error code
	//trace("player error:", Object(event).data);
}
 
function onPlayerStateChange(event:Event):void {
	// Event.data contains the event parameter, which is the new player state
	//trace("player state:", Object(event).data);
}
 
function onVideoPlaybackQualityChange(event:Event):void {
	// Event.data contains the event parameter, which is the new video quality
	//trace("video quality:", Object(event).data);
}
 
 
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
 
lb.addEventListener(Event.CHANGE, itemChange);
 
function itemChange(e:Event):void
{
	player.loadVideoById(lb.selectedItem.data,0);
}
 
var xml:XML;
 
function onLoaded(e:Event):void
{
 
	var defaultNS:Namespace = new Namespace("http://www.w3.org/2005/Atom");
 
	xml = new XML(e.target.data);
	var il:XMLList = xml.defaultNS::entry;
	for(var i:uint=0; i<il.length(); i++)
	{
 
		var ytId:String = il[i].defaultNS::id.slice(42,53);
		lb.addItem({data:ytId, label:il[i].defaultNS::title});
	}
}
 
loader.load(new URLRequest("http://gdata.youtube.com/feeds/api/users/"+feedName+"/uploads"));

Download FLA:

  ActionScript 3 YouTube feed application (607.8 KiB, 615 hits)

Enjoy!

YouTube playlist with thumbnails

After I made the first YouTube player I thought it’s a good idea if I make another version with thumbnails inside each playlist item. So I started to work on the project, then I posted it on ActiveDen.net and then it got approved (on 8 October 2009, after nearly 1 month from the first YouTube playlist project). I don’t know how or why but right now this new player it’s the best seller in my ActiveDen portfolio.  I’ll try to make some more YouTube projects and see how this will turn out.youtube playlist with thumbnails

UserBooth (beta) – Flash Webcam Application – Photo maker

A few weeks ago I made a little Flash application named “Photo Booth”. Then I started to work with a friend of mine on a bigger project that will be very useful for those site owners who want to easily integrate a webcam application into their sites.
The project name is UserBooth. Right now we are still working on the application so please use it, take snapshots and let us know about your experience with the app. We need your feedback ;)

userbooth

YouTube API video player with playlist

A few days ago I had some free time on my hands and I thought it will be nice if I designed a little YouTube video player based on the YouTube API and upload it to activeden.net so others can buy and use it in their projects.
The video player has some nice features like:

  • xml based playlist
  • playlist with or without scroll bar (depending on the amount of tracks)
  • volume control
  • play / pause button
  • preview track and next track buttons
  • shuffle button
  • repeat button
  • medium screen
  • full screen
  • progress bar
  • video time

If you want to check it out you can find it here
youtube-player-with-playlist

Photo Booth – Flash Webcam Image Capture

EDIT: From this little experiment a new project called UserBooth came to life ;)

Two days ago I made a little flash app that will allow anyone to take a picture with a webcam connected to a computer. Everything worked fine in AS3. It was only when I got to the php part of the project when I felt like I should ask for help. And I did, I asked a friend or mine (Mihai Bojin) who in a few minutes explained to me exactly what I needed to know in order to get this project working as it should (a big part of the php code is made by him).
The project is now open source and you can find the code and the source fines underneath ;)

You can download the source files from here:

  Photo Booth (52.8 KiB, 8,719 hits)

Here you can see the working application:
vamapaull.com/photobooth

Here you can see the ActionScript 3.0 code:

import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
 
var snd:Sound = new camerasound(); //new sound instance for the "capture" button click
 
var bandwidth:int = 0; // Maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second.
var quality:int = 100; // This value is 0-100 with 1 being the lowest quality. 
 
var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(320,240,30,false); // setMode(videoWidth, videoHeight, video fps, favor area)
var video:Video = new Video();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
addChild(video);
 
var bitmapData:BitmapData = new BitmapData(video.width,video.height);
 
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
addChild(bitmap);
 
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
 
function captureImage(e:MouseEvent):void {
	snd.play();
	bitmapData.draw(video);
	save_mc.buttonMode = true;
	save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
	save_mc.alpha = 1;
}
 
save_mc.alpha = .5;
 
function onSaveJPG(e:Event):void{
	var myEncoder:JPGEncoder = new JPGEncoder(100);
	var byteArray:ByteArray = myEncoder.encode(bitmapData);
 
	var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
 
	var saveJPG:URLRequest = new URLRequest("save.php");
	saveJPG.requestHeaders.push(header);
	saveJPG.method = URLRequestMethod.POST;
	saveJPG.data = byteArray;
 
	var urlLoader:URLLoader = new URLLoader();
	urlLoader.addEventListener(Event.COMPLETE, sendComplete);
	urlLoader.load(saveJPG);
 
	function sendComplete(event:Event):void{
		warn.visible = true;
		addChild(warn);
		warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
		warn.buttonMode = true;
	}
 
}
 
function warnDown(e:MouseEvent):void{
	navigateToURL(new URLRequest("images/"), "_blank");
	warn.visible = false;
}
 
warn.visible = false;

Here you have the php code:

<?php
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
	$jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
	$img = $_GET["img"];
	$filename = "images/poza_". mktime(). ".jpg";
	file_put_contents($filename, $jpg);
} else{
	echo "Encoded JPEG information not received.";
}
?>

Stop-Motion Video – Street Delivery

Last night I was at an event here in Bucharest named “Street Delivery
I took some pictures and today I made a little Stop-Motion video.

Here you have the video:

The littke trip from this weekend

This weekend I got away for a little trip to the back sea with some friends of mine.
First we got to Vama Veche and then we got to Neptun where we met some girls and had some drinks at a very interesting restaurant.
I’ve taken some pictures and here you can see them:

Photo-walk with Ramona

A few days ago I went out for a photo-walk here in Bucharest with a girl that I know from flickr. She is a great photographer and she is very smart (at least that’s my first impression :lol: )
We had a lot of fun and we made lots of pictures. Below I posted a slideshow with her making different face expressions.

Oded Antman Portfolio Site

A few days ago I got a project from a GAF client of mine. This was a portfolio site for Oded Antman. I had to use the slideshow pro component (a great component to use in portfolio sites like this).
After a few days of learning the API for this component and after I did some coding I found out that the component has a little bug, a bug that had something to do with the “navAppearance” method. My client simply wanted the fist slideshow when you enter the site to be without the navigation bar visible but when a gallery was changed and the navAppearance variable was changed, I started to get a lot of bugs in my project (by the way, I was working with the ActionScript 3 component version 1.9.3). I tried to get an answer from the slideshow pro forums (but I didn’t had the time to waste, the project had to be delivered very fast) and then I tried to find a way to get rid of the bug with other codding methods but without any good results.
Finally the client decided that it is not a big problem and I finally delivered the project.
This is the site I talked about:
odedantman.com

After a few days I got a message on the forum from one of the slideshow pro support guys saying:
“Yeah, this is probably because the navigation wasn’t really intended to be changed mid-stream. As in, changing it to hidden for one album then switching it to something else thereafter. If you can you should keep one style of navigation appearance for your slideshow.”

oded-antman

The design was not made by me, my job was just to code the site. The site system is very dynamic. It uses slideshow pro director as a CMS system and all the menu items can be easily changed in the control panel.
I’m happy the client understood the problem and we finished the project without problems ;)

dorm2dorm.com

Last week I finished working on some flash pieces for a client from GAF
First I did the banner/header for this site dorm2dorm.com
Then this little app where I implemented some nice AS3 based animations dorm2dorm.com/storage_boxes

I did a lot of modifications to satisfy the clients requests but in the end I think we got some nice results ;)

d2d

YouTube Playlist – ActionScript 2 YouTube API

I did some projects for some of my clients where I had to use the YouTube API to load videos in flash from the YouTube website. I remember I spent a lot of time trying to find a working example that I could use on my project. I first tried to work with the ActionScript 3 chromeless YouTube API (a friend of mine did a fast example using Flex and this API) but just when I thought the project is done, I got a message back from the client saying that he can not use the player because it’s working through some JavaScript code and his users can’t embed the player on myspace, facebook and stuff like that. Then I had to start form scratch but this time I had to make it work with ActionScript 2 (at the time there was very little documentation about this on code.google.com)… after some hours of research and experiments I finally made the YouTube player in ActionScript 2 and I delivered the project without problems. Now I want to share with all of you the code that I used to get a project like this done. I have uploaded a zip archive with all the files you need if you want to get started with a similar project.

Click here if you want to see how this YouTube Playlist app looks like ;)

  YouTube Playlist (22.3 KiB, 1,495 hits)

Here you can see some of the projects I did using this API:
meeetv.com project
actionext.com project, I did 4 players for this client with 4 different skins and very similar code on all 4 of them.

Photos from Abobe Flex Camp Timisoara, Romania

Yesterday I was in Timisoara attending to a conference hosted by Adobe Romania. I saw a lot of great things and some interesting projects done by romanian developers. Here I have uploaded some pictures from this event ;)

After this event we (Me, Costi, Biro and his girlfriend) got out for a walk in Timisoara so we can make see the city and take some pictures. Thank you Biro for being our guide! ;)

Odd or Even number in ActionScript

I was making a project for a client of mine where I had to make a list with two different colors for the items (like the iTunes list) so I started to think of a possible way to make this. It was clear enough I need to know the odd or the even number in order to do that. So I started to do some google search and I got over this blogpost by Keith Peters. I have to say, this is a very interesting way of thinking :D

iseven = ((num & 1) == 0)

Makes sense when you look at binary numbers:

001 = 1
010 = 2
011 = 3
100 = 4
101 = 5

Each of the odd numbers has a 1 in the far right column. The even numbers have 0 there. Mask it with “& 1″ and you can see which it is.

So I made a for loop and used this code. It works exactly how it was intended to work!!
Thanks Keith Peters for your blogpost :D

Turntable

Yesterday I took this shot and today it got accepted on iStock.
The image is done with my Canon 400D and my 50mm lens with Canon 430EX flash.

Drawing app

Right now I’m still reading “Learning ActionScript 3.0” book so I can improve my AS 3 skills. In the “Draving with pixels” chapter there is a great example of a little drawing application that I like. Here you can see the code for that little application:

var mouseIsDown:Boolean;
var erasing:Boolean;
 
var canvas:Sprite = new Sprite();
addChild(canvas);
 
var w:Number = stage.stageWidth;
var h:Number = stage.stageHeight;
var bmd:BitmapData = new BitmapData(w, h, false, 0xffffffff);
var bm:Bitmap = new Bitmap(bmd);
canvas.addChild(bm);
 
var brush:Sprite = createBrush(0x66cc00);
var eraser:Sprite = createBrush(0xffffff);
 
function createBrush(col:uint):Sprite{
	var sp:Sprite = new Sprite();
	sp.graphics.beginFill(col, 1);
	sp.graphics.drawCircle(0, 0, 30);
	sp.graphics.endFill();
	return sp;
}
 
canvas.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
canvas.addEventListener(MouseEvent.MOUSE_UP, onUp);
this.addEventListener(Event.ENTER_FRAME, onLoop);
 
function onDown(e:MouseEvent):void{
	mouseIsDown = true;
	if(e.shiftKey)
		erasing = true;
}
 
function onUp(e:MouseEvent):void{
	mouseIsDown = false;
	erasing = false;
}
 
function onLoop(e:Event):void{
	if(mouseIsDown && erasing){
		eraser.x = mouseX;
		eraser.y = mouseY;
		bmd.draw(eraser, eraser.transform.matrix);
	}else if(mouseIsDown){
		brush.x = mouseX;
		brush.y = mouseY;
		bmd.draw(brush, brush.transform.matrix);
	}
}

And if you click here you can see the result (click to draw and hold the shift key + click to erase)
This book has a lot of good examples and it’s very easy to understand. I recommend it to anyone how wants to start with ActionScript 3.0 ;)