Posted in January 16, 2010 ¬ 6:43 amh.vamapaull1 Comment »
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
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.showDefaultContextMenu = false;
//path to the php file on your servervar 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 fieldsif(user.text!= ""&& pass.text!= ""){
sendLoadData();
}else{trace("Please fill in both username and password");
}}stop();
function sendLoadData():void{var dataRequest:URLRequest = newURLRequest(phpPath);
dataRequest.method = URLRequestMethod.POST;
// define the custom parameters that will be sent to the .php filevar params:URLVariables = newURLVariables();
params.user = user.text;
params.pass = pass.text;
dataRequest.data = params;
var urlLoader:URLLoader = newURLLoader();
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 otherif($user==$username&&$pass==$password){print"secure_response=1";}else{print"secure_response=2";}?>
Posted in January 12, 2010 ¬ 8:13 amh.vamapaull2 Comments »
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 = newLoader();
playerLoader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
playerLoader.load(newURLRequest("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);}varloader:URLLoader = newURLLoader();
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 = newNamespace("http://www.w3.org/2005/Atom");
xml = newXML(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(newURLRequest("http://gdata.youtube.com/feeds/api/users/"+feedName+"/uploads"));
Posted in November 27, 2009 ¬ 9:24 amh.vamapaullNo Comments »
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.
Posted in November 17, 2009 ¬ 9:01 pmh.vamapaull1 Comment »
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
Posted in September 16, 2009 ¬ 1:06 pmh.vamapaullNo Comments »
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)
Posted in August 6, 2009 ¬ 6:22 amh.vamapaull59 Comments »
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
importflash.display.Bitmap;
importflash.display.BitmapData;
import com.adobe.images.JPGEncoder;
var snd:Sound = new camerasound(); //new sound instance for the "capture" button clickvarbandwidth:int = 0; // Maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second.varquality: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 = newVideo();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
addChild(video);
varbitmapData:BitmapData = newBitmapData(video.width,video.height);
var bitmap:Bitmap = newBitmap(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 = newURLRequestHeader("Content-type", "application/octet-stream");
var saveJPG:URLRequest = newURLRequest("save.php");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
var urlLoader:URLLoader = newURLLoader();
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(newURLRequest("images/"), "_blank");
warn.visible = false;
}
warn.visible = false;
Here you have the php code:
<?phpif(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.";}?>
Posted in May 4, 2009 ¬ 2:43 pmh.vamapaull2 Comments »
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:
Posted in April 28, 2009 ¬ 2:03 amh.vamapaull1 Comment »
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 )
We had a lot of fun and we made lots of pictures. Below I posted a slideshow with her making different face expressions.
Posted in April 26, 2009 ¬ 6:26 amh.vamapaullNo Comments »
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.”
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
Posted in April 1, 2009 ¬ 7:59 amh.vamapaull3 Comments »
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
Posted in March 20, 2009 ¬ 10:26 pmh.vamapaull12 Comments »
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
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.
Posted in March 15, 2009 ¬ 10:50 amh.vamapaull4 Comments »
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!
Posted in February 25, 2009 ¬ 4:07 pmh.vamapaull5 Comments »
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
“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
Posted in February 4, 2009 ¬ 4:43 amh.vamapaullNo Comments »
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 = newSprite();
addChild(canvas);
var w:Number = stage.stageWidth;
var h:Number = stage.stageHeight;
var bmd:BitmapData = newBitmapData(w, h, false, 0xffffffff);
var bm:Bitmap = newBitmap(bmd);
canvas.addChild(bm);
var brush:Sprite = createBrush(0x66cc00);
var eraser:Sprite = createBrush(0xffffff);
function createBrush(col:uint):Sprite{var sp:Sprite = newSprite();
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);
}elseif(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
Posted in November 10, 2008 ¬ 8:56 amh.vamapaullNo Comments »
I found this somewhere on tumblr, it was a gif animation. This is a very interesting idea. I really love it. But it seems to work better with this mouse over effect