|
-
Update well i've tried a few new things but still no luck... any ideas?
-
UPDATE : STILL NOT WORKING the bummer although the code is a lot cleaner now.. but i still don't understand what i'm doing wrong...
here is the whole code.. including the motion tracking code
Code:
//Motion tracker
import flash.display.*;
import flash.geom.*;
// INIT
trackdot.inTrans = false;
setInterval(detection, 110);
ScreenSizeX = 800.0;
ScreenSizeY = 480.0;
// Connect the webcam
cam = Camera.get();
this.vid.attachVideo(cam);
now = new BitmapData(cam.width, cam.height);
before = new BitmapData(cam.width, cam.height);
rect = new Rectangle(0, 0, cam.width, cam.height);
trace("cam.width="+cam.width+" cam.height="+cam.height);
sizeDif = ScreenSizeX / cam.width;
pt = new Point(0, 0);
// Show The MonoColor image
//coverRect = new Rectangle(0, 0, 130, 120);
function detection() {
if (!cam.muted) {
now.draw(vid);
now.draw(before, new Matrix(), new ColorTransform(), 'difference');
now.threshold(now, rect, pt, '>', 0xff333333, 0xffff0000);
now.fillRect(coverRect, 0xff000000);
before.draw(vid);
//
re = now.getColorBoundsRect(0xffffffff, 0xffff0000, true);
//trace(r.toString());
ColorChange = now.threshold(now, re, new Point(re.x, re.y), '==', 0xffff0000, 0xffff0000);
//trace(ColorChange);
if (re.x<160 && ColorChange>10) {
trackdotNewY = (re.height/2+re.y)*sizeDif;
}
if (re.y<120 && ColorChange>10) {
trackdotNewX = re.width/2+re.x;
trackdotNewX = ScreenSizeX-(trackdotNewX*sizeDif);
}
tweenPlayer(trackdotNewY, trackdotNewX);
}
}
// display the motion detection bitmap
bitmaporb_mc.attachBitmap(now, 10);
vx = 75;
vy = 75;
//r = tackdot._width/2;
//HIT-TESTFUNCTIONS
function hitAndHover(target, hover):Void {
_root[hover] = 0;
if (trackdot.hitTest(target)) {
_root[hover]++;
target.gotoAndPlay("OverState");
trace("Hovertimer"+_root[hover]);
} else {
target.gotoAndPlay("NormalState");
_root[hover] = 0;
trace("NOT..HOVER");
}
}
function Thumbs_hitAndPlay(target,hover,sName,sPos):Void{
if (_root[hover]==20) {
_root.populateCONTENT(sName,sPos);
target.gotoAndPlay("Selected");
trace("Activated");
_root[hover] = 0;
}
};
function tweenPlayer(param, param2) {
easeType = mx.transitions.easing.Regular.easeOut;
var mc = trackdot;
if (mc.inTrans == false) {
//mc.inMovement = true;
var begin = mc._y;
var beginX = mc._x;
var end = param;
//var end = mc._y+(random(10)-5);
var time = 0.6;
ballTween = new mx.transitions.Tween(mc, "_y", easeType, begin, end, time, true);
ballTween = new mx.transitions.Tween(mc, "_x", easeType, beginX, param2, time, true);
ballTween.onMotionFinished = function() {
mc.inTrans = false;
};
}
}
Right that should deal with any hit tests on the thumbnails in the two functions...
Now here is where the function are called.. in a sep frame on the inspire marker..
Code:
stop();
//INIT
_root.populateInspireThumbs();
//CALL FUNCTIONS IN INSPIRE FRAME
//THUMB1
onEnterFrame=hitAndHover(thumb1_mc,"hover1");
onEnterFrame=Thumbs_hitAndPlay(thumb1_mc,"Inspire",0);
//THUMB2
onEnterFrame=hitAndHover(thumb2_mc,"hover2");
onEnterFrame=Thumbs_hitAndPlay(thumb2_mc,"Inspire",1);
//THUMB3
onEnterFrame=hitAndHover(thumb3_mc,"hover3");
onEnterFrame=Thumbs_hitAndPlay(thumb3_mc,"Inspire",2);
//THUMB4
onEnterFrame=hitAndHover(thumb4_mc,"hover4");
onEnterFrame=Thumbs_hitAndPlay(thumb4_mc,"Inspire",3);
//THUMB5
onEnterFrame=hitAndHover(thumb5_mc,"hover5");
onEnterFrame=Thumbs_hitAndPlay(thumb5_mc,"Inspire",4);
//THUMB6
onEnterFrame=hitAndHover(thumb6_mc,"hover6");
onEnterFrame=Thumbs_hitAndPlay(thumb6_mc,"Inspire",5);
Can anyone tell me why this isn't working... because it's drivin me nuts...
Andy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|