Saturday, May 3, 2008

detection Motion script ...so far

hey Ladiez,

I'll probably post this up on the news groups as well, but thought I'd let you know how (terrible :( ) the scripting is going lol..seriously...me stupid

oh...how do you attach actual files to this thing!?

------------------------------------------------------------------

Would it be possible to get some help on a piece of script? Is it even possible to do it this way? Suggestions?

What I want it to do:

Basically if the camera detects enough movement I want it to run a function once (person stands in front of our wall > cam detects movement > activates wall for interaction)

I've given up with the activityLevel tutorials that I've found on the web (they are a little too complicated for me…sad as that seems). So far I have flash detect if there is motion on a cam (a green/red light goes on and off depending on if you’re moving). If the light changes I can have it execute a function (ie goto a differ frame to start animations etc).

The problems:

When I run it, the camera automatically detects change and starts off green (thus executing the function to early)
- was thinking maybe I can set it so that only on the third light-flash it would run the function activateWall() ?

Any ideas what I could do that won’t be to complicated?



------------------------------------------------------------------

In Flash

(instances on stage : "vid" = video object   ,   "light" = movieclip that has two frames 1. green + stop() /2. red)

script in first key:


// Declare Video instance on stage
var vid:Video;

// Declare MovieClip instances on the stage
var light:MovieClip;

// Create a reference to the camera
var userCam:Camera = Camera.get();

//create function to 'activate wall'
function activateWall() {
trace("stop repeating dammit!!!");
}

// Attach the camera output to Video instance
vid.attachVideo(userCam);


// set motionLevel and timer
userCam.setMotionLevel(80, 0500);


//not sure what this is supose to be doing, but works :P
userCam.onActivity = mx.utils.Delegate.create(this, onMotion);


function onMotion(isActive:Boolean) {
light.gotoAndStop( isActive ? 2: 1 );
activateWall();
//gotoAndStop(3)
}

------------------------------------------------------------------




No comments: