evan
09-02-2008, 05:00 AM
if I create a rect object and use startDrag and stopDrag
with the function that controls MouseUp I can
trace the size and position with:
trace("rect bounds ", rect.getBounds(this));
I would like to do something like assign a variable like
var Capture:Number;
and then place the values from rect.getBounds in it
Capture=rect.getBounds(this);
and then
trace(Capture);
but that won't work because I think it's got 4 values at once to store
I have some code from learnactionscript.com and seen lee brimlow's demo on gotoand learn about taking a snapshot of a video.
I am trying to reverse engineer something I have seen here (http://disney.go.com/pooh/html/advntr/hunt.html)
so far I have code for the basic jpeg capture,
import com.adobe.images.JPGEncoder;
var Capture:Number;
var rect:Sprite=new Sprite();
rect.graphics.beginFill(0x0000FF,1);
rect.graphics.drawRect(250,250,50,50);
rect.graphics.endFill();
rect.alpha=.25;
addChild(rect);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed, false, 0, true);
function onKeyPressed(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case Keyboard.SPACE:
trace("space");
var paintGrab:BitmapData = new BitmapData (50,50);
paintGrab.draw(canvas);
var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(paintGrab);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var saveJPG:URLRequest = new URLRequest ("savejpg.php?img=mydrawing.jpg");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
navigateToURL(saveJPG, "_blank");
break;
case Keyboard.ENTER:
trace("enter");
break;
}
}
//in this sample, canvas is a movie clip on the stage
rect.addEventListener(MouseEvent.MOUSE_UP,dragnot);
function dragnot(evt:MouseEvent):void{
rect.stopDrag();
trace("rect bounds ", rect.getBounds(this));
// rect.getBounds(this);
//Capture=rect.getbounds(this)
//trace(Capture);
}
rect.addEventListener(MouseEvent.MOUSE_DOWN,dragcam);
function dragcam(evt:MouseEvent):void{
rect.startDrag();
}
there is also some php that runs with it that I didn't post -I got it to work but I can't control an image capture inside bouunds coords -as in I don't want a complete screenshot of the whole stage.
with the function that controls MouseUp I can
trace the size and position with:
trace("rect bounds ", rect.getBounds(this));
I would like to do something like assign a variable like
var Capture:Number;
and then place the values from rect.getBounds in it
Capture=rect.getBounds(this);
and then
trace(Capture);
but that won't work because I think it's got 4 values at once to store
I have some code from learnactionscript.com and seen lee brimlow's demo on gotoand learn about taking a snapshot of a video.
I am trying to reverse engineer something I have seen here (http://disney.go.com/pooh/html/advntr/hunt.html)
so far I have code for the basic jpeg capture,
import com.adobe.images.JPGEncoder;
var Capture:Number;
var rect:Sprite=new Sprite();
rect.graphics.beginFill(0x0000FF,1);
rect.graphics.drawRect(250,250,50,50);
rect.graphics.endFill();
rect.alpha=.25;
addChild(rect);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed, false, 0, true);
function onKeyPressed(evt:KeyboardEvent):void
{
switch(evt.keyCode)
{
case Keyboard.SPACE:
trace("space");
var paintGrab:BitmapData = new BitmapData (50,50);
paintGrab.draw(canvas);
var myEncoder:JPGEncoder = new JPGEncoder(100);
var byteArray:ByteArray = myEncoder.encode(paintGrab);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var saveJPG:URLRequest = new URLRequest ("savejpg.php?img=mydrawing.jpg");
saveJPG.requestHeaders.push(header);
saveJPG.method = URLRequestMethod.POST;
saveJPG.data = byteArray;
navigateToURL(saveJPG, "_blank");
break;
case Keyboard.ENTER:
trace("enter");
break;
}
}
//in this sample, canvas is a movie clip on the stage
rect.addEventListener(MouseEvent.MOUSE_UP,dragnot);
function dragnot(evt:MouseEvent):void{
rect.stopDrag();
trace("rect bounds ", rect.getBounds(this));
// rect.getBounds(this);
//Capture=rect.getbounds(this)
//trace(Capture);
}
rect.addEventListener(MouseEvent.MOUSE_DOWN,dragcam);
function dragcam(evt:MouseEvent):void{
rect.startDrag();
}
there is also some php that runs with it that I didn't post -I got it to work but I can't control an image capture inside bouunds coords -as in I don't want a complete screenshot of the whole stage.