Brackenwood

Brackenwood

  • March 29, 2017, 09:41:09 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search

News:

Brackenwood update: YES! New stuff is in the works. Big plans for 2016

Pages: [1]   Go Down

Author Topic: Flash vCams here  (Read 38578 times)

0 Members and 2 Guests are viewing this topic.

chluaid

  • Bitey's Daddy
  • Administrator
  • Heroic
  • *****
  • Offline Offline
  • Gender: Male
  • Posts: 5388
    • BiteyCastle
Flash vCams here
« on: September 28, 2008, 04:51:26 PM »

For AS 2.0
Code: (reanimator.camera) [Select]
import flash.geom.Matrix;
import flash.geom.Transform;
import flash.geom.ColorTransform;
var cameraTrans:Transform = new Transform(this);
var stageTrans:Transform = new Transform(this._parent);
var w:Number = Stage.width;
var h:Number = Stage.height;
this._visible = false;
this.onEnterFrame = function () {
this._parent.filters = this.filters;
stageTrans.colorTransform = cameraTrans.colorTransform;
var stageMatrix:Matrix = cameraTrans.matrix;
stageMatrix.invert();
stageMatrix.translate(w*.5, h*.5);
stageTrans.matrix = stageMatrix;
};


For AS 3.0
Code: (Jaehl's AS3 cam, supports filters) [Select]
var cameraTrans:Transform = new Transform(this);
var stageTrans:Transform = new Transform(parent);
visible = false;

stage.addEventListener(Event.ENTER_FRAME, updateStage);
function updateStage(...rest) {
parent.filters = filters;
stageTrans.colorTransform = cameraTrans.colorTransform;
var stageMatrix:Matrix = cameraTrans.matrix;
stageMatrix.invert();
stageMatrix.translate(stage.stageWidth*.5, stage.stageHeight*.5);
stageTrans.matrix = stageMatrix;
};
updateStage();

addEventListener(Event.REMOVED_FROM_STAGE, resetStage);
function resetStage(...rest) {
stage.removeEventListener(Event.ENTER_FRAME, updateStage);
stageTrans.matrix = new Matrix();
stageTrans.colorTransform = new ColorTransform();
parent.filters = new Array();
}


To use these, simply create a movieclip symbol making sure that its Registration point is in the centre (as below):



Inside the symbol, create your vCam artwork (usually an empty square with the same dimensions as your movie) and put the above code on the same frame. Whenever you want to use the camera, simply drag it out of your Flash library onto the Stage. Tweening this camera symbol on the Stage creates camera moves, easy as that :)

vCam 1.0 was created by Sham Bhangal in 2004 for "Prowlies at the River"
reanimator.camera by Jarrad Hope was the first vCam to allow filters and rotation.
Jaehl's AS3 cam was created by request for us here, because he's so awesome.

As has always been the case, Actionscript programmers are encouraged to tweak and make their own enhancements/improvements to the vCam.
Animators and programmers, wherever you use the vCam or improve on it, always show respect by giving credit to the people who created it or contributed to the code.
« Last Edit: November 21, 2010, 10:04:12 PM by chluaid »
Logged

Vector

  • Resident Actionscript Guru
  • Assistant Admin
  • Heroic
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 3803
  • ~ Programmer | National Laser Tag Player | Bent ~
    • Vector's Sector
Re: Flash vCams here
« Reply #1 on: June 14, 2009, 05:42:59 PM »

DISCLAIMER: don't take my word for any of this, as I haven't had the time to learn AS3 in the last year an a half, and haven't had flash installed on my computer for about 9 months, but...

From a quick glance, it would appear that both the AS2 and AS3 cameras above do not clean up after themselves properly. It may not be a problem for the AS2 cam due to the way it keeps its-self operating, however the AS3 cam may leave your screen transformed even after you delete the camera from the stage.

What this means for you is if you want to stop using the camera by deleting it from the stage, you'll need to do a little workaround. After the last frame that you use your camera, add one more. On that frame, have the camera centred, and matching the stage's original width and height. After that frame you can delete the camera.
Logged
~Vector

chluaid

  • Bitey's Daddy
  • Administrator
  • Heroic
  • *****
  • Offline Offline
  • Gender: Male
  • Posts: 5388
    • BiteyCastle
Re: Flash vCams here
« Reply #2 on: June 14, 2009, 11:32:33 PM »

yeah that's how I've been doing it but there's a way to do this in AS. Anthony Eden gave me the fix for Waterlollies but I seem to have misplaced the cam from that movie. It removes any stage transform when the cam clip is removed from the stage. I'm waiting for him to get back to me (which is why I PMd you about it) so when he does, I'll update the code above.
Logged

adzy-2k6

  • Senior Member
  • ****
  • Offline Offline
  • Posts: 725
Re: Flash vCams here
« Reply #3 on: June 15, 2009, 03:45:30 AM »

Couldnt you copy the cam from the waterlollies source file, or have you deleted it?. Odds are, that is the quickest way we will get it back :)
Logged

chluaid

  • Bitey's Daddy
  • Administrator
  • Heroic
  • *****
  • Offline Offline
  • Gender: Male
  • Posts: 5388
    • BiteyCastle
Re: Flash vCams here
« Reply #4 on: June 16, 2009, 01:31:02 PM »

Couldnt you copy the cam from the waterlollies source file, or have you deleted it?. Odds are, that is the quickest way we will get it back :)

I could but it's on my old computer which doesn't have a monitor, keyboard or mouse, since I'm using them all on my brand new machine. Probably easier to ask Jaehl or Snepo point out the problem and edit the post ;D
Logged

Jaehl

  • Mobal Gloderator
  • Global Moderator
  • Veteran
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1419
  • /* No comment */
    • Jaehl.com
Re: Flash vCams here
« Reply #5 on: June 16, 2009, 06:28:16 PM »

Ta-da!  ;D

Code: [Select]
import flash.geom.Matrix;
import flash.geom.Transform;
import flash.geom.ColorTransform;
var cameraTrans:Transform = new Transform(this);
var stageTrans:Transform = new Transform(this.parent);
var w:Number = stage.stageWidth;
var h:Number = stage.stageHeight;

stage.addEventListener(Event.ENTER_FRAME, updateStage);
function updateStage(...rest) {
//this._parent.filters = this.filters;
stageTrans.colorTransform = cameraTrans.colorTransform;
var stageMatrix:Matrix = cameraTrans.matrix;
stageMatrix.invert();
stageMatrix.translate(w*.5, h*.5);
stageTrans.matrix = stageMatrix;
};
updateStage();

this.addEventListener(Event.REMOVED_FROM_STAGE, resetStage);
function resetStage(...rest) {
stage.removeEventListener( Event.ENTER_FRAME, updateStage);
stageTrans.matrix = new Matrix();
}
« Last Edit: October 29, 2009, 11:05:55 PM by Jaehl »
Logged

chluaid

  • Bitey's Daddy
  • Administrator
  • Heroic
  • *****
  • Offline Offline
  • Gender: Male
  • Posts: 5388
    • BiteyCastle
Re: Flash vCams here
« Reply #6 on: June 16, 2009, 11:08:58 PM »

I hope you're earning a lot of money somewhere man :)
Logged

Jaehl

  • Mobal Gloderator
  • Global Moderator
  • Veteran
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1419
  • /* No comment */
    • Jaehl.com
Re: Flash vCams here
« Reply #7 on: June 17, 2009, 12:47:27 AM »

D: Oh God, don't even mention money, I'm so ridiculously poor right now! :P
Logged

TheEYE

  • Lurys Fey Daemyt
  • Assistant Admin
  • Heroic
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 5759
  • That which you have seen can never be unseen.
Re: Flash vCams here
« Reply #8 on: June 17, 2009, 09:53:20 AM »

That's AS3 correct Jaehl?
If you weren't already a MotM, you would be for this alone my friend, good on ya bud!  ;D
Logged
Ambition is the last refuge of failure. -Arthur Wilde

Jaehl

  • Mobal Gloderator
  • Global Moderator
  • Veteran
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1419
  • /* No comment */
    • Jaehl.com
Re: Flash vCams here
« Reply #9 on: June 17, 2009, 11:31:29 AM »

No problem :D

And yeah, it's AS3. Here's the AS2 version:
Code: [Select]
import flash.geom.Matrix;
import flash.geom.Transform;
import flash.geom.ColorTransform;
var cameraTrans:Transform = new Transform(this);
var stageTrans:Transform = new Transform(this._parent);
var w:Number = Stage.width;
var h:Number = Stage.height;
this._visible = false;
this.onEnterFrame = function() {
this._parent.filters = this.filters;
stageTrans.colorTransform = cameraTrans.colorTransform;
var stageMatrix:Matrix = cameraTrans.matrix;
stageMatrix.invert();
stageMatrix.translate(w*.5, h*.5);
stageTrans.matrix = stageMatrix;
}

this.onUnload = function() {
stageTrans.matrix = new Matrix();
}
Logged

Jeemanx

  • Woodfolk
  • *
  • Offline Offline
  • Posts: 37
Re: Flash vCams here
« Reply #10 on: June 17, 2009, 10:26:29 PM »

I thought I'd ask here whether there are any tutorials on how to implement these cameras in flash (CS4)?

I've followed Adam's directions in this thread but can't get anything working. I've also downloaded the older example from the links page with Adam's 'waterfall' scene, but the code seems totally different to the examples shown here.

'pologies for the n00bness - but I'd never even thought of having a camera to move around in flash before today.. :)

[EDIT] It's OK - I got it to work. I didn't have the correct publish settings in my scene.. D'oh!
« Last Edit: June 17, 2009, 11:55:44 PM by Jeemanx »
Logged
"What's so bad about being drunk?"
"Ask a glass of water."

Darkswift2204

  • Junior Member
  • **
  • Offline Offline
  • Posts: 98
Re: Flash vCams here
« Reply #11 on: June 24, 2009, 07:57:49 AM »

Hey i need help i do what adams says but i cant get it to work. Do i have to make a square and make the square a symbol or what?

Jaehl

  • Mobal Gloderator
  • Global Moderator
  • Veteran
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1419
  • /* No comment */
    • Jaehl.com
Re: Flash vCams here
« Reply #12 on: June 24, 2009, 09:09:30 AM »

Make a rectangle that's exactly the same size as the movie itself, turn it into a movieclip, open it up, and stick the code on the first frame. :)
Logged

Jaehl

  • Mobal Gloderator
  • Global Moderator
  • Veteran
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 1419
  • /* No comment */
    • Jaehl.com
Re: Flash vCams here
« Reply #13 on: October 29, 2009, 11:05:37 PM »

Update: The vCam now supports filters!
Code: (AS3) [Select]
var cameraTrans:Transform = new Transform(this);
var stageTrans:Transform = new Transform(parent);
visible = false;

stage.addEventListener(Event.ENTER_FRAME, updateStage);
function updateStage(...rest) {
parent.filters = filters;
stageTrans.colorTransform = cameraTrans.colorTransform;
var stageMatrix:Matrix = cameraTrans.matrix;
stageMatrix.invert();
stageMatrix.translate(stage.stageWidth*.5, stage.stageHeight*.5);
stageTrans.matrix = stageMatrix;
};
updateStage();

addEventListener(Event.REMOVED_FROM_STAGE, resetStage);
function resetStage(...rest) {
stage.removeEventListener(Event.ENTER_FRAME, updateStage);
stageTrans.matrix = new Matrix();
stageTrans.colorTransform = new ColorTransform();
parent.filters = new Array();
}
Logged

tkinney

  • Fledgling
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 2
  • Hey. :)
Re: Flash vCams here
« Reply #14 on: August 13, 2016, 12:28:17 PM »

 
Update: The vCam now supports filters!
Thanks for updating the vCam y'all. I appreciate it! :)
Also, you can add this line at the end:
Code: (AS3) [Select]
this.visible = false; :P
Logged
Pages: [1]   Go Up
 

Page created in 0.113 seconds with 25 queries.