Save picture of current screen to disk AS3 - actionscript-3

I want to add a button to my flash game (AS3) and on click it saves a picture of the current users whole screen and saves it to pictures/disk automatically, but I don't know how to do that, I know how to add the button to the UI and add a click event and all that, just need to know how to make it save a picture of the current screen to disk (doesn't have to be just the flash screen, can be the WHOLE screen of the users pc, either way works!)

I was on my way writing you the answer but I found this post have a better explaination: Is it possible to capture the screen and save the image in actionscript 3?
"Yes, it's possible.
Draw some display object to a BitmapData (the stage, for example) and crop it if neccesary (the second param of BitmapData::draw will help you out here).
Then, convert the raw pixel data to JPEG or PNG using some encoder. I'm sure up to this point, this is what those tutorials will explain you how to do.
Now, the third step is different but simple enough. Instead of sending the image data to a server side script, use a FileReference object. Since Flash Player 10, it has a method called save, that prompts the user to save a file locally.
Since this is a desktop app, you could also make it an AIR app. This will give more direct access to the file system and other features, in case you need them."

Related

changing button functions of sq23 camera

I recently got small action camera called sq23. I used it few times outdoors, found that I never take picture instead of video. But from stand-by state to video-ready state is tough, so I want to change the function of buttons in this camera.
I know how to program, but I don't know to access the code that original functionality is implemented. Can you provide some procedure or tools for accessing the original code?

Programmatically surface CameraRoll image created with CameraCaptureTask

As described in this thread's first answer, for WP8 the Camera Capture Task automatically saves a copy of any images it creates to the Camera Roll. If an image is saved in this way, is it possible to programmatically surface the image in an application directly from the copy in the Camera Roll without creating a second copy in a location such as Isolated Storage or Application Data? If so, how would you get a pointer to the Camera Roll location of this newly-saved image?
I'd like to avoid having multiple redundant copies of each image floating around, if at all possible. And if using the copy in the Camera Roll will allow me to leverage the CameraCaptureTask functionality instead of working with the Camera API directly, then this would be ideal for my purposes. Thanks.
If you just need the location of the image it is provided in the OriginalFileName property of the PhotoResult that you get from the Completed event.
For example, take a picture with the emulator gives "C:\Data\Users\Public\Pictures\Camera Roll\WP_20140106_002.jpg"
Now that you have it you can display to the user with a BitMapImage and set that as the Source for an image.
MyImage.Source = new BitmapImage(new Uri("C:\\Data\\Users\\Public\\Pictures\\Camera Roll\\WP_20140106_002.jpg", UriKind.Absolute));
If you need the image right away, you get that from the ChosenPhoto property of the PhotoResult.

Externally loaded images in AS3 un-clickable?

I'm loading in an external image (a book cover from goodreads.com) into a library viewer AIR app (used on ipad and in-browser) running on Starling (in case you need to know). After it loads, the cover should be clickable to take further action.
This all works fine on ipad and when directly built from FlashDevelop, but when it's viewed in-browser, click events don't do anything on the loaded images. It'll work on my embedded placeholder bitmaps no problem (sitting in a "Book" class extending Sprite).
It seems to be a security problem, but if it was, I'd expect the image to not load at all. But instead it loads but isn't interactive anymore. I've tried various things like:
Add loader and click listener to the Book object
Add loader.content as Bitmap and click listener to the Book
Create a BitmapData and draw the Loader.content, then add the resulting Bitmap (it's blank in-browser, but works perfectly when built from FD)
Add loader and place a transparent sprite on top of it, add listener to the sprite
Has anyone had this problem? Would anyone know a work-around?
Thanks!
This was a sand-box problem.
I think it's intentional; you shouldn't be able to hot-link other site's assets unless given express permission.
I fixed this by only pulling images hosted locally and using crossdomain.xml to make sure there was no lookup issues when www.domain.com and domain.com were different.

Flash CS3 (AS3) is giving my graphics (buttons and movieclips) outlines

So, I'm pretty much a beginner in Flash and Actionscript (using AS3, as I said in the title), and I'm trying to make a basic escape the room game. I haven't gotten far, and right now that's because every time I test my game (or publish preview it) the graphics get this annoying outline. Here it is when tested: http://i305.photobucket.com/albums/nn228/chokingondrama/flash.png
Every outline corresponds to some object present in the game, most of which have an alpha component of 0 since they're on different sides of the room. This didn't happen before, but once I added the code that allowed the player to change their view with the arrow (each viewpoint/wall is a different frame) these appeared.
It's a little different when published to HTML, basically it just gives each image a white background: http://i305.photobucket.com/albums/nn228/chokingondrama/html.png
Also, it would be nice if somebody could give me advice on how to make sure importing to flash won't result in lower quality.
Thanks in advance. If needed, I'll post any part of the code.
Some tips:
Don't set alpha to 0, instead use the visible property, setting movieclip.visible = false will make it a lot more efficient.
As for the importing and quality, after you import to stage or library, bring up the library (ctrl + l), and right click on the file you imported, go to properties. If it's an image, set compression to lossless, and allow smoothing.
For audio, go to file-> publish settings, and change audio stream and audio event (whichever you might use) to 128kbps.
As for your main question, I need more info, if you want you can post your source. It might be because of how you are placing your graphics on the stage.
For each of your MovieClips in question:
Try disabling button mode and see if the rectangles go away.
movieClipName.buttonMode = false;
If that doesn't help, or you really want button mode, try setting
movieClipName.tabEnabled = false;
There's a chance that since you added keyboard interaction each of your MovieClips are now expecting to be selected by the user when they press the tab key, much like any normal web form.
tabEnabled in the docs
You could also try
movieClipName.focusRect = false;
focusRect in the docs

Live Video Keying with Flash (AS3)? How to do that?

For a new project, I want to take a video feed, filmed in a greenscreen room, and as you see it, do a color keying, to kill the green and show an alternative picture on the background.
Is there a way to do this with Flash, AS3?
optional question: If a button is clicked, the now new constructed Picture should be saved as a Jpg. Any Idea?
Thanks a lot for you help!
For this sort of thing you're going to need to use Pixel Blender: http://www.adobe.com/devnet/pixelbender.html and possibly Alchemy as well http://labs.adobe.com/technologies/alchemy/
Sorry I can't give you more info than that as I've never worked with them before.
To capture a screen grab, it's easier. Create a new BitmapData object the size that you want your final image. Use the draw() method on it to capture the stage (or holding clip etc). Grab the as3corelib from here: https://github.com/mikechambers/as3corelib and use the JPGEncoder or PNGEncoder class to create a jpg or png (personally I prefer png, as even though the filesize is bigger, it's much quicker to generate as you don't need to worry about compression).
Then, use the FileReference class ( http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html) to save it out (JPGEncoder and PNGEncoder both return your image as a ByteArray so just pass that as the data to the FileReference.save() function).