Be a Supporter!
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
AS: Video 2006-03-13 13:44:33 Reply

AS:Main - For the needy and stupid!Welcome to AS: Video I will show you how to implant a live web cam feed into your flashes and how to apply some awesome effects to it!So lets begin!

1-Webcam feed

This is a great way to add some interactivity to anything, it could be used as pre-loader entertainment or expanded and turned into a full video editing suite.

Firstly open flash (duh!). Then open the library (CTRL + L). Next in the top left of the library there is a button which looks like 3 bullet point sand some lines. Click it.
A menu will pop up. At the top of it there is a button which says ‘New Video’. Click this.
Now in your library a new object will be there, it will be called ‘Embedded Video 1’. Drag this onto your stage and resize it to whatever you size you want. There should be a transparent rectangle with 2 lines in it, now on the stage. And give it the instance name ‘webcam’ (no quotes). This will be where our web cam appears.
Now for some actions. Goto the actions panel of whatever frame your ‘webcam’ is in and paste this code:-

myCam = Camera.get();
webcam.attachVideo(myCam);
webcam.smoothing = true;

Time for some explanation.

myCam = Camera.get();

This code creates a variable called myCam. The it finds the systems default webcam/video device and applies it to that variable. Hence the ‘camera get’.

webcam.attachVideo(myCam);

This line gets the variable myCam’ and applies it to the ‘webcam’ object on the stage which we created earlier.

webcam.smoothing = true;

The last line makes the webcam appear less pixellated and more smooth. This line is not necessary, but makes the video higher quality.

Now preview your movie(CTRL+ENTER) and your webcam input should be on the stage where your ‘webcam’ object is.
If it doesn’t want to show up try adjusting your flash player settings by right clicking and selecting ‘settings’.

Some other useful things are:-

webcam.clear(); - This refreshed the video feed.

webcam.height = 4 - This defines the height of the pixels in the video.

webcam.width = 4 - This defines the width of the pixels in the video. 2 – Effects

Now you are all excited about the idea of making a video flash why not make it even better by adding some awesome effects to your flash.

EFFECT 1 - Negative

This is one of my favs. This effect will negative your webcam, so you can view yourself in real-time, in negativity.

This is an all actions effect. Simply open the action panel with your webcam script in and paste this code:-

negative = new Color(_root.webcam);
myColorTransform = {ra:-100, rb:255, ga:-100, gb:255, ba:-100, bb:255};
negative.setTransform(myColorTransform);

Explanations

First line creates a variable ‘negative’ and makes it colour which will be applied to your video object. Change the ‘_root.’ To the path of your video object e.g. _root.ismell.webcam.

Second line creates a new colour transformation and sets its colours. These settings will give a negative effect but they can be changed to give different effects. e.g. ra=+50

The final line finds the negative variable and applies the colour transform to it.

This code can also be applied to a button so that when it is pressed the video changes colour. To Change it back use these actions on a button.

on (release) {
normal = new Color(_root.webcam);
myColorTransform = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0};
normal.setTransform(myColorTransform);
}

EFFECT 2 - Tint

This is a good effect to make things dark or light, and it needs practically no actions.

To start make a new layer above the one you have your video object on and draw a borderless square in the new layer. Resize it to the size of your video object and place it directly over it.
Click your square and open the colour mixer (Shift+F9). Choose back from the mixer and then put its alpha down to 50%. This should make it translucent.
Click your square again and press F8 to convert it to a movie clip. Give it the instance name ‘tint’.
Go into your movie clip and make 3 key frames. Name the first frame ‘black, the second ‘red’ and the last ‘blue’. Goto your second frame and change the squares colour to red, with its alpha still down at 50%. Then do the same for the 3rd but this time in blue.
In every key frame in the movie clip remember to put a stop(); action.
Now make 3 buttons one called black, 1 called blue and another called red. Apply these actions to the ‘Black Button’.

on(release){
_root.tint.gotoAndStop(“black”);
}

These to the red button:-

on(release){
_root.tint.gotoAndStop(“red”);
}

And these to the blue:-

on(release){
_root.tint.gotoAndStop(“blue”);
}

Now when you click on your buttons the video object should appear to change colour. You may need to resize the size of the tint movie clip to get it to look right.

I hope all these tips and advice have helped and I will make more of these if they are popular.
If I missed anything, just say!

,Ali


BBS Signature
Paradox
Paradox
  • Member since: Jan. 28, 2006
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to AS: Video 2006-03-13 13:47:29 Reply

Nice, this may benefit me one day, and I hope it benefits others too.

Claxor
Claxor
  • Member since: Oct. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Video 2006-03-13 13:48:28 Reply

Using some advanced bitmapData stuff, this could get really fun ^^
It's a shame that webcam games doesn't get rated that high, as not too many guys have webcams.

Nice tutorial :D


BBS Signature
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Video 2006-03-13 13:48:32 Reply

Cheers. Soz about the layout it got messed up.lol.


BBS Signature
Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Video 2006-03-13 13:49:46 Reply

I'm not trying to advertise here but my game has this in and it got daily 5th today. Its called window sngista. Take a look at the video suite on it, plz.


BBS Signature
Paradox
Paradox
  • Member since: Jan. 28, 2006
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to AS: Video 2006-03-13 13:51:11 Reply

At 3/13/06 01:49 PM, FlashMasterMx2004 wrote: I'm not trying to advertise here but my game has this in and it got daily 5th today. Its called window sngista. Take a look at the video suite on it, plz.

I don't think pointing out your game here is actually not allowed, and besides, it actually does have something to so with the subject.

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Video 2006-03-13 13:51:49 Reply

Lol, suppose.


BBS Signature
shazwoogle
shazwoogle
  • Member since: Sep. 27, 2004
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Video 2006-03-15 18:33:12 Reply

lol looks cool might play with that soon =D

Not-an-S
Not-an-S
  • Member since: Oct. 31, 2005
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS: Video 2006-04-23 08:21:41 Reply

Great Tutorial, but just wondering, how do you create a still picture from a webcam in your flash movie/game?

PostMasterFlex
PostMasterFlex
  • Member since: Jan. 21, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Video 2006-04-23 08:46:26 Reply

That would be awesome...a bit off topic but this is bothering me, whats the AS to stop all movie clips or graphics from playing?


Beavis-Love

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Video 2006-04-24 15:31:54 Reply

Sorry, but i really don't know. i have looked around but i just cant find out how to capture the video or take snapshots.
You would have to create a new object and tell it to stop, but i'm not sure, sorry. You could say::

_root.mc1.stop();
_root.mc2.stop();

but that could take a while.

,Ali.


BBS Signature
ZpankR
ZpankR
  • Member since: Sep. 7, 2005
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to AS: Video 2006-05-18 14:07:24 Reply

isw the re a way to make an eye toy type game , when the image has movement on a certain pixel it would make something?

Depredation
Depredation
  • Member since: Sep. 5, 2005
  • Offline.
Forum Stats
Member
Level 17
Game Developer
Response to AS: Video 2006-07-07 15:49:57 Reply

At 5/18/06 02:07 PM, ZpankR wrote: isw the re a way to make an eye toy type game , when the image has movement on a certain pixel it would make something?

Sorry for the late reply. Yes there is, kind of. I t cannot detect where the movement is, but it can detect general movement. Here's a link to all the stuff on the Camera Object.

Link


BBS Signature