Flash vCam AS3
Announcing vCam AS3 v1.1 for Flash! For those who aren't familiar with vCam, I'll offer a brief explanation. In 2005, Sham Bhangal and Dave Dixon released the original vCam or "virtual camera" for Flash. Let's say a Flash developer is working on an animation and wants the animation to pan from left to right. Without the vCam, the developer would have to create tweens for each layer in the timeline. Using the vCam, however, the developer can animate a single vCam instance on the timeline to create the same pan. Simply place the vCam on the left side of the stage and create a motion tween to the right side of the stage. Publish out the file and the scene pans with a single tween! The original vCam can also be used to adjust size and add color transformations.
Now vCam AS3 brings a new array of options with added features including:
- Rotation
- Blur
- Brightness/Contrast
- Hue/Saturation
- and more!
Sham and Dave were very generous and offered the original vCam free of charge. Therefore I am also offering this new version for free. Have fun all!
Version 1.1 has been optimized and the bitmap data processing has been removed.
Download vCam AS3 v1.1 FLA (Requires Flash CS3 and Actionscript 3)
*** Note: A bug in Flash CS3 causes stage.stageHeight to be -100 the actual stageHeight if the bandwidth profiler is open. Either close the profiler or view the SWF outside flash.
The animation below shows the vCam AS3 animated on the stage:
The animation below is the resulting swf file:
Artwork by Josh Menas | Composited by Tim Allen 64 comments
64 Comments so far
Leave a reply

Fantastic! I’ll link to this article on my next blog update. Nice demo too! Thanks for keeping the vCam alive
-Adam
Thank you so much for adding those new features! I’m so happy to be using this in my next flash animation.
Hi! Terrific piece of code.
The only thing, the AS3 (unlike AS2) version seems to be distorted, is this possible?
Just open the fla, and it seems strechted, even though I leave the vcam the same size as the stage (100% x 100%)… but i don’t see why, any ideas?
It’s a bug in Flash CS3. You need to make sure the bandwidth profiler is closed when viewing it in Flash. For some reason if bandwidth profiler is open the value of stage.stageHeight is -100 what it should be. Try closing the profiler or running the swf outside of Flash and it should show up fine.
@bryan: Unbelievable, you are right
… thanks alot!
Thanks so much for making this available.
This is brilliant!
Hey there,
great vCam! I only have one question: is it possible to trigger events like buttons on the Stage? Somehow it´s not working when vCam is attached?
Greetings
Very nice! Thanks for sharing.
Damn thats good.
Amazing, thanks a bunch.
This an excellecent peice of code actually…and it makes flash animators lives so much easier
This is great, But when I use the one for as 2.0 buttons don’t work.
What a brilliant idea! Well done on this
Never mind. I think I figured it out. When the video is stretched to be larger than it should be (which firefox and internet explorer do when you open the file using them) the camera doesn’t stretch with it, cutting off some of the video. If you were to upload it to your website and not stretch it out to be larger than it should be, it should work fine.
This looks excellent, but I have one question if you don’t mind answering.
Does the AS3 camera shift the coordinates of the stage slightly like Sham Bhangal’s original?
Wow, that’s real good, sometimes so small things make us so happy, isn’t it? Very good job. Thank YOU!
Anyone know an easy way to make this work with movieclip buttons/interactions on the stage? It’s a very neat tool, but I was hoping to incorporate some interactivity as well
Brilliant! You’re a legend!
em:
“Brilliant! You’re a legend!”
Yes, kind of: you must remember this vcam is based in a “hack” by Sham Bhangal whom made it for the one and only Adam Philips, a legend of flash animation. In fact, read the “credits” in the animation-demos.
Of course, we must thank this tweak, as the original camera hasnt been updated since i dont remember when.
Hail to the king.
i think this is a great idea,i just wish there was a MX version
[...] Today i’m just going to share one of the most useful tools for animators in Flash. It is the virtual camera class. Although i lean more to the technical side i can’t help but admire [...]
Hi there! Great, lovely hack. Does anyone know how to make it work with the keyboard?
I want to be able to move the viewfinder up/down/left/right while the movie is running.
The only immediate solution I can think of is maybe using tweening and setInterval…but that solution is kind of ugly and devoid of true “dynamic” positioning
Isn’t there another way to achieve this that’s more elegant?
Any ideas, guys? Any more geniuses out there?
BTW, just moving the viewfinder using viewfinder._x and a keylistener w/o any tweening won’t work
Thanks for a great app.
This is amazing i love it you sir and or maddam are a geniues
how can I change the colors like the swf file??
I don’t found any tuto on the web, and sorry for my bad english xD
do you know if this will work with flash cs4 when it comes out or do you have to code a new one for cs4?
CS4 uses Actionscript 3 so it should port over fine.
This is a great stuff. Did anyone see a flash game with using vCam? I am curious to see a game using this code. But it seems that we ave an interactivty problem here.
WOW this is sooo cool
i could never get the vcam to work for me until now!
I just have to figure out how to control this one and ill be on easy street, yay!
Thank you so much! this is so helpful for a beginner
[...] me; hand drawn in Flash CS3. Those fancy camera movements you’re seeing are achieved by the vCam actionscript tool. Voice overs were done by friends of mine, and a few of the smaller parts were done by myself. [...]
Aside from this being really cool,, which it is. What is the benefit of using this versus, scaling and tweening a main movieclip on the stage?
I dont see any DOF or lens flare.
I could be wrong, i am often.
wow cool thanks for the source file.
Regards
Omair Rais
http://www.omairarts.com
Love this code! Thanks a lot guys, this will come in very handy.
Brilliant! Simply brilliant. I teach flash programming at High school and my students showed me this fantastic tool. Thank you so much for giving it away freely. Now my students and I can animate in a much faster time frame. Thanks again.
Thank you sooo much for this updated Vcam. Do you know where I can find a tutorial for this though?
Amazing, great job.
Okay this is amazing. I just wanted to let you know. Thank you.
It is very useful thing! Many thanks to the author!!!!!
you can’t press buttons on the stage when the camera is active. Is there any way to fix this?
@Andrea
in September 12th, 2008 6:13 am
try using x instead of _x
Great update! Glad to see that the vcam has been ported to AS 3.0. My only complaint is the same one that Robert reported – once a swf which uses vcam has been published, you cannot change the display dimensions of the swf (e.g., swf published at 640×480, but you want to display it on an html page at 550×400). Although this didn’t seem to be an issue with the old vcam, this version of vcam does not seem to adapt well to that (new vcam stays static, keeping the publish dimensions). The workaround is to publish at whatever settings the swf will be displayed at on the web page, but this is not always desirable. Any suggestions on this?
Otherwise, great job! Thanks so much!
thanks for the catch. I’ll get in there and fix it….
Great! I love it, i tried vcam for as2 and it rocks. but this is even better, now animating and side scrollers will be even easier to make!
super easy and useful, thank you!
Can someone please tell me why i cant use any filter effects , it wont reconise it
Thanks for sharing this idea with us. vCam is really cool.
Man I am so glad I finally found this! I would like to know if I have to use actionscript and coding to make the camera do whatever I need and I also need to know If I have to put it inside of each and every scene. If I want to make it smaller-to-scale, should I use free-transform?
I love you. LOL, this helps soooo much.
Thanks alot!
Works great except for one thing;
I’ts probably just the shit computer I’m sitting at right now, but I’m getting som fpsdrops when I use the vcam(I’m using it in a platform game and sets vCam_mc.x = player_mc.x).
Is there any unnecessary code I can remove if I’m only using the vCam for that or should I change the code that makes it follow the player to something better? I’m new to flash and this is the only way I could think of except moving the vCam when I move the hero, but that felt slower.
Thanks again and thanks again again in advance=)
// Erik
I’m currently trying to make a basic platformer game with two players. The problem is, I don’t know how to use two vcams, and make them follow the mcs’ on two different sections of the screen.
e.g
| First VCAM | Second VCAM |
| | |
| | |
| mc1 mc2|mc1 mc2 |
Can anyone help me?
[...] VCAM. Who said you needed PaperVision3D to have a camera? Might be another addition to my ActionScript toolbox alongside greensock’s Tweenmax… [...]
Sweet, thanks for updating this for AS3, Works fine in CS4 btw, you should add that since its a plus point… unless you did somewhere i didnt see, i dont know i hate reading.
Also, any chance of making this a component instead of a fla file? I think thats the only “problem” with it, not that i am trying to look for a down side. It is still super awesome coolio.
It’s easier for animators to apply filters/color transforms if I leave it as a MovieClip. Filters aren’t available in the properties panel for components.
Hi Brian,
I have a couple of questions. Because of the changes adobe has made to Flash the Quick time exports horribly. I am a timeline animator/instructor and when I export I get all kinds of frame drops. My work around is to export my sound as a qt and export my swf for the visual and take it into After effects put it together and export a great looking QT from there. However I can’t get the vcam to work when I do this. Any suggestions? Should I ask Adam how he exports his stuff?
I hope to continue to work with my community college students with the vcam.
I wish Apple and Adobe would have a cease fire…and fix the flash Quick time.
Thanks Brian,
Pam
Hi I have been using the vcam for an animation project and up until today it has been working just fine- now when I opened my file today and tried exporting the SWF file to preview- it’s stuck on frame 4- the camera is not working even on a new document that I created a simple animation to test it…have any suggestions on how to fix this???
Thanks,
Melissa
I love using the camera…I’ve used it so many times and it’s saved me SO much time.
Now though, I am trying to use this camera to control what is shown to a player.
The camera is located on left.swf and right.swf (but i’m just going to focus on left.swf because both are identical)
Currently I have the camera moving based on the character movement, and that works perfectly when I load it on it’s own.
BUT, when I load it into my main.swf it loses the ability to access “stage”
I’ve been able to fix this before by adding
//code
if(stage != null) {
init();
}
addEventListener(Event.ADDED_TO_STAGE, init);
function init(event:Event = null):void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//stage.addEventListeners would be put here
}
//end code
but adding that to the camera didn’t work because it references stage outside of functions accessed by event listeners.
Can anyone help me with this?
hey does AS3 work with AS2 flash file?
Nope, it’s strictly AS3. You might be able to find the original AS2 vCam here.
Hey, great work there! I’m finishing up a game with it, the only problem I’m getting is when adding a middle ground in the scene. The performance drops drastically. I’ve set up the background and foreground for parallax scrolling, and it works great, but when I add the mid ground, everything almost stops. Any idea why? What can I do to improve this? I’ve tried even using the Hardware acceleration publish setting from Flash CS4, but doesn’t change a bit.
Thanks for nay help! o/
First I discovered this amazing virtual cam in AS2 thanks to Sham Bhangal & Adam Phillips collaboration. I would like to adapt it in AS3 and you did it perfectly!
Many many thanks,
Robin
u stink doesnt work with .avi files when i publish
Before you go making comments like this you might want to consult Adobe’s documentation. AVI’s do not compile ActionScript code. Export a Quicktime(renders actionscript animation) from Flash then convert it to an AVI using a video editor.
Thx soooooooooooo Much For ths now my tpi animation rocks