Log in

View Full Version : alternative to navigate URL



evan
09-08-2008, 06:12 PM
In another post I mentioned save jpg and targeting the save -the problem then was to get control over the snapshot, well the long and short of it there isn't.

but with bitmapdata and copyPixels you can control the coordinates of what is being copied.

Bitmapdata class seems to only copy from existing flat files or objects like jpgs unless I'm wrong. It would save alot of work if the bitmapdata could just export the file rather than just display the selected pixels.

so, what I will do is save the whole stage as a jpg, import it and select the pixels and move it to 0,0 coord and do another save.

so in order to get that to work, I will need to save the jpg to a folder on the server.

can I use navigateToURL () ? -It only seems to target _self, _blank, _parent, etc.

can I specify a file with it? if so how do I assign the path to save it?:confused:

BLiZZaRD
09-08-2008, 06:48 PM
I saw your other post, and I will admit I stayed out of it cause I was confused, as I am now.

Is what you want to do:

Have a picture, image, MC on the stage in Flash, have the user use the mouse to select any portion of said [inserted previously] then save that selection to their computer?

Am I even close? LOL If I can understand what you want I [i]may just be able to build a working example for you.

evan
09-08-2008, 07:42 PM
Ok and again appologies to anyone who WOULD offer their help but are put off if I'm not clarifying it well enough.

Initially I had Two projects in mind.

one where the user could select and save part of what's on the screen and use a moving sprite as a camera. -that was for fun

what I will need is to implement a save feature into a drawing pad.
--get the legnth and width of the pad , the coordinates to copy it.
(-copyPixel) -and then save it, and store it.

-so I'm learning about Bitmapdata and copy pixel and jpeg encoder, the display list - loaders at once (in AS3) and trying to apply it from tutorials.
take this example:




var penguinsBmd:BitmapData = new Penguin(0,0);
var penguinsBm:Bitmap = new Bitmap(penguinsBmd);

function onClick(evt:MouseEvent):void {



//OK --this part determines the L/W size of the area to be copied

var penguinCopyBmd:BitmapData = new BitmapData(300, 300);

//w/h/x/y
//the loaction of where the copying takes place:

var rect:Rectangle = new Rectangle(200, 200, 300, 300);

//this carries out the copying:

penguinCopyBmd.copyPixels(penguinsBmd, rect, new Point());

//this is the instance of the copied pixels:

var penguinCopy:Bitmap = new Bitmap(penguinCopyBmd);

//the placement of the copied pixels:

penguinCopy.x = 10;
penguinCopy.y = 10;

but I realize this code is only good for applying it to a bmp or jpg that is imported


var penguinsBmd:BitmapData = new Penguin(0,0);
var penguinsBm:Bitmap = new Bitmap(penguinsBmd);

so what to do ...if I want to copy something that is dynamicly drawn or dragged onto the stage?
-then there is saving it to a directory. I haven't given up yet.


I stay up alot with this now so I appologise if my brain is turning to mush.

evan
09-08-2008, 08:29 PM
I got this far..

http://www.asmakta.com/clients/encode/index2.html

Medyman
09-09-2008, 02:21 AM
Hey Evan...

I didn't read your second and third posts. This is just to answer your question about sending variables to PHP w/o using navigateToURL.

First of all, navigateToURL is not what you're looking for. I suppose you're using the AS 2.0 mindset where getURL() might have worked.

But in this case, navigateToURL() does what it says...navigates to it. To send PHP variables back and forth, you should be sendToURL().

For example...
Say you're creating a email form and you need to send the email to a PHP script from a textarea. Your AS3 might look like this:


var request:URLRequest = new URLRequest( "http://mysite.com/submit.php" );

var variables:URLVariables = new URLVariables();
variables.email = emailSubmitText;

request.data = variables;

request.method = URLRequestMethod.POST;

sendToURL(request);


As to your question about BitmapData...I'm just as confused as Blizzard. From what I understand, you're trying to output a .jpg from a selection of the stage. Is that correct?

evan
09-09-2008, 02:49 PM
Mendyman,
-I also disected the code from the link you sent -
I got alot out of it.

-great advice :
you should be sendToURL().



that's it.:D

the drawing pad is in the middle of the page. copy pixel is great for doing just that -and then setting up ways to manipulate pixels. -But it only works with "flattend" images.

the save jpg ability -at least the way I see it used only allows me to save the whole screen, the upper left hand side of the screen -or an object by itself -such as a sprite (not what lies on top of it).

I want to be wrong here -otherwise I am planning a workaround.

Medyman
09-09-2008, 04:55 PM
Hey Evan...

Unfortunately, you're right. You need to use the workaround. BitmapData only works with a byteArray. So, you need an actual bitmap image to use any of those methods.

You *might* be able to just capture the whole screen and save the data into a byteArray and manipulate it internally. Therefore, it removes the need to save it and then import it. But, I've never done this so I can't say for sure.

If you want to post all the relevant code, I might be able to play around with it and offer a suggestion.

evan
09-10-2008, 10:34 PM
can I save a jpg straight to disk?

with send to url, would that imply that I can specify a path on a server

re:send url:

sendToURL(http://www.mysite.com/images).

would that work?

Medyman
09-11-2008, 02:36 AM
can I save a jpg straight to disk?

Nope...security implications. You have to have a server as an intermediate.