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:

This movie requires Flash Player 9

The animation below is the resulting swf file:

This movie requires Flash Player 9

Artwork by Josh Menas  |  Composited by Tim Allen

64 comments

64 Comments so far

  1. Phillips March 31st, 2008 11:29 pm

    Fantastic! I’ll link to this article on my next blog update. Nice demo too! Thanks for keeping the vCam alive :)

    -Adam

  2. Jeff Schoch April 2nd, 2008 3:25 am

    Thank you so much for adding those new features! I’m so happy to be using this in my next flash animation.

  3. Blu Loo April 3rd, 2008 11:11 am

    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?

  4. bryan April 3rd, 2008 12:17 pm

    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.

  5. Blu Loo April 3rd, 2008 12:23 pm

    @bryan: Unbelievable, you are right :-) … thanks alot!

  6. Ben April 4th, 2008 12:43 am

    Thanks so much for making this available.

  7. Pasquale April 5th, 2008 3:28 am

    This is brilliant!

  8. tisi April 6th, 2008 2:07 pm

    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

  9. pault107 April 14th, 2008 3:43 pm

    Very nice! Thanks for sharing.

  10. Elite April 17th, 2008 1:08 am

    Damn thats good.

  11. Oscar April 29th, 2008 11:41 am

    Amazing, thanks a bunch.

  12. mortis5000 May 2nd, 2008 6:40 pm

    This an excellecent peice of code actually…and it makes flash animators lives so much easier

  13. hat-man May 4th, 2008 1:38 am

    This is great, But when I use the one for as 2.0 buttons don’t work.

  14. Dark Vyper May 8th, 2008 7:30 am

    What a brilliant idea! Well done on this :)

  15. Robert May 13th, 2008 2:04 am

    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.

  16. AV May 24th, 2008 4:16 am

    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?

  17. impzloty May 28th, 2008 7:28 am

    Wow, that’s real good, sometimes so small things make us so happy, isn’t it? Very good job. Thank YOU!

  18. vee June 9th, 2008 6:18 pm

    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 :)

  19. em June 15th, 2008 9:00 pm

    Brilliant! You’re a legend!

  20. Arturo Dabdoub July 12th, 2008 9:41 am

    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.

  21. GamerBlade July 29th, 2008 7:50 am

    i think this is a great idea,i just wish there was a MX version :(

  22. Virtual Camera AS3 September 2nd, 2008 12:11 pm

    [...] 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 [...]

  23. Andrea September 12th, 2008 6:13 am

    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.

  24. Deremix September 25th, 2008 8:23 pm

    This is amazing i love it you sir and or maddam are a geniues

  25. kud October 1st, 2008 12:28 am

    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

  26. MarkP October 8th, 2008 6:10 pm

    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?

  27. bryan October 10th, 2008 12:33 pm

    CS4 uses Actionscript 3 so it should port over fine.

  28. Özgür ALTAY October 17th, 2008 10:44 am

    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.

  29. Shandelle November 18th, 2008 2:20 am

    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!

  30. richard k December 2nd, 2008 7:54 pm

    Thank you so much! this is so helpful for a beginner

  31. Kenny’s World: Episode 1 at Ghosteo Net December 15th, 2008 6:42 pm

    [...] 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. [...]

  32. jp February 4th, 2009 9:20 pm

    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.

  33. Omair Rais February 7th, 2009 5:26 pm

    wow cool thanks for the source file.

    Regards
    Omair Rais
    http://www.omairarts.com

  34. Josh February 19th, 2009 4:02 am

    Love this code! Thanks a lot guys, this will come in very handy.

  35. Kit March 4th, 2009 10:00 am

    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.

  36. Pokenerd March 25th, 2009 10:19 pm

    Thank you sooo much for this updated Vcam. Do you know where I can find a tutorial for this though?

  37. Fsmv March 29th, 2009 5:59 pm

    Amazing, great job.

  38. Artur April 8th, 2009 5:36 pm

    Okay this is amazing. I just wanted to let you know. Thank you.

  39. Pavel June 29th, 2009 9:11 am

    It is very useful thing! Many thanks to the author!!!!!

  40. Gurflob July 3rd, 2009 8:54 pm

    you can’t press buttons on the stage when the camera is active. Is there any way to fix this?

  41. SparK July 9th, 2009 9:44 am

    @Andrea
    in September 12th, 2008 6:13 am

    try using x instead of _x

  42. Matt August 2nd, 2009 4:27 pm

    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!

  43. Sdanektir August 6th, 2009 12:16 pm

    thanks for the catch. I’ll get in there and fix it….

  44. Sepiantum August 9th, 2009 11:37 pm

    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!

  45. kennethc August 21st, 2009 10:35 pm

    super easy and useful, thank you!

  46. Gizmo September 12th, 2009 8:38 pm

    Can someone please tell me why i cant use any filter effects , it wont reconise it :(

  47. Luke Alexander September 14th, 2009 1:32 pm

    Thanks for sharing this idea with us. vCam is really cool.

  48. Skyler Skinner September 17th, 2009 10:42 pm

    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?

  49. Halfmoon September 19th, 2009 5:34 am

    I love you. LOL, this helps soooo much.

  50. Zedzo September 26th, 2009 6:16 pm

    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

  51. n00bflasher November 14th, 2009 9:34 am

    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?

  52. [...] VCAM. Who said you needed PaperVision3D to have a camera? Might be another addition to my ActionScript toolbox alongside greensock’s Tweenmax… [...]

  53. Flashman 10 December 6th, 2009 8:21 pm

    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.

  54. bryan January 11th, 2010 1:37 pm

    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.

  55. pam January 12th, 2010 6:22 am

    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

  56. Melissa February 10th, 2010 4:43 pm

    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

  57. Yenni February 18th, 2010 7:50 pm

    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?

  58. Matt April 9th, 2010 9:37 pm

    hey does AS3 work with AS2 flash file?

  59. bryan April 12th, 2010 12:15 pm

    Nope, it’s strictly AS3. You might be able to find the original AS2 vCam here.

  60. Jean April 29th, 2010 10:34 pm

    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/

  61. Fritig May 6th, 2010 1:56 pm

    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

  62. dude May 6th, 2010 6:37 pm

    u stink doesnt work with .avi files when i publish

  63. bryan May 17th, 2010 4:34 pm

    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.

  64. Cool dude May 20th, 2010 4:39 pm

    Thx soooooooooooo Much For ths now my tpi animation rocks

Leave a reply