How to Photograph your user

How to Photograph your userAfter my first four semesters as an art major using mostly digital media, it was pretty apparent that I was going to be a web designer when I grew up but I wanted more, I wanted to program, I wanted to learn… Actionscript! While trying to come up with an idea for a senior semester project Flash MX was released. One of the major changes in this release was the ‘Settings…’ menu (found by right clicking [PC] or control clicking [MAC] inside a Flash movie). Settings menu choiceThis menu selection brings up a Flash player settings window that includes the camera and microphone permissions settings. The user can allow their computer connected camera and/or microphone to be accessed via Flash player. What does this mean? Flash Communication Server was not released at first and the camera and microphone features were not listed in any Flash manuals when MX debuted, so I wandered bookstores for weeks looking through Flash books and trying to find the hidden camera and microphone setting meaning.Flash Movie settings window Then inside the Macromedia Flash MX 2004 Actionscript Bible the Camera() object was finally defined. This object allows Flash to access and control a user’s camera in order to facilitate teleconferencing using Flash Communication Server, plus it can even detect motion. The only thing the Camera() object doesn’t seem to do is take ‘still’ photos.
Still photos could allow the developer to add their user to an animation or game and thereby enhance the user experience. But how? First you acquire the camera using the Camera.get() method. This allows the Flash file to access the camera directly.Flash attached camera settings This method with return null if the user has disabled access via the settings menu. If the user has not ever set the access settings for the specific Flash file or web site, they will be prompted on load of the file to either give access to their camera or not. I recommend warning the user way ahead of time that their camera will be accessed. Now you can attach the accessed camera to a Movie Clip in your Flash movie and then animate and adjust the movie clip via Actionscript.Grabbed picture Now you are ready to access an undocumented feature via a camera disconnection. Setting the attached camera null leaves a residual image of the last frame grabbed. Why is the feature undocumented? We can only wonder at Macromedia’s ways, but never question…
Click through for a sample photo movie (remember to enable your camera) and a code snippet of what you will need to enable the still photo capability. I do not have Flash communication server and do not say any image associated with the movie.
If you use this in one of your Flash projects please link to my site and give credit where it is due, thanks.



The code and how to use it:
>>In the first frame of the animation place the following action script:

cam = Camera.get();
vid.attachVideo(cam);
pic = true;
doPicture = function () {
if (pic) {
vid.attachVideo(null);
} else {
vid.attachVideo(cam);
}
pic = !(pic);
};

Name the second frame of the animation ‘photoLoop’ and loop from the frame after back to it. This way you can allow the user to create their perfect photo.
The library of the FLA contains an empty embedded video object and a button.
Add the embedded video to stage and give it an instance name of ‘vid’.

Attach the following action script to the button:

on (release) {
doPicture();
_root.pause = !(_root.pause);
}

You can also create the video and button via actionscript for a more pure experience. I used this effect to create an art installation that I will post in the future. Also remember: If you use this in one of your Flash projects please link to my site and give credit where it is due, thanks.

6 Responses to “How to Photograph your user”


Comments are currently closed.