as3 save swf stage to desktop - only works in IDE - actionscript-3

I followed a tip here on saving the stage as a png (is there a way for flash AS3 to take a snapshot of a frame then save it as jpeg but using PNGEncoder instead). It works when run in Flash - I get a dialog box asking for where to save the file. But in a browser it just stalls out without showing the dialog box - and not running the code after that command. Are there security issues with using such code in a browser? Or is there something else going on here.

There are security issues with saving images - it has to be in response to a user action (ie mouse or keyboard event)

Related

Save picture of current screen to disk AS3

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."

Flash Video Loading Issue

Please click on the below link
http://hpecp.vmokshagroup.com/videobook/html/homepage.html
When we click on "What is VideoBook" link we got some blank screen before starting the swf file due to video fetching from the server. We have to avoid blank screen.
We are facing a problem of fetching the video clips from the hosting server. I added two video clips in Flash (.swf)... one is from the beginning, another one is at the ending and in between some text animations.
While we are playing/calling .swf file in browser from hosting server, initially getting blank screen. It takes some time to fetching the video clip from server due to size. Starting of first video clip duration is about 3-6 seconds. While video is being loaded.. text animation is starting without playing first video clip. Same problem we are facing in second video at the ending.
Is there any option to incorporate video clips internally in Flash (.swf file) rather than calling from external server or external file path?
Any help would be appreciated.
This happens because of the JavaScript that you use - it actually makes the swf files (in)visible depending on the situation. What this does is that it actually loads the .swf files each time. You can check that in the Network tab of your debugger (I'm using Chrome).
So it first loads Video-01d.swf, or Video-02.swf. They take time to load, and just when the main file is loaded, it starts to load the video file (video1.flv).
All that causes delay, and it's pretty normal as you have all that things in separate files. If you want to, you can merge them into one - just import the flv inside your .swf file and it will work out well..
Of course, you will need to change all your logic for the flash files that you are playing. You will also need to change the JavaScript to call Flash functions in order to tell it to go to another "scene".
I will advise you to add a simple gif loader image (like this), put it as a background-image of the div, and put some color into that div. What the user will see is that the movie disappears, there is a black background with a loading symbol inside, and then the new video begins. It's a normal thing to see online - preloaders :) Good luck!

Preloader does not work online

I've made a project that uses a preloader in the scene 1 and the content continues in the scene 2. The preloader have the follow code:
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
this.loaderInfo.addEventListener(Event.COMPLETE, loaded);
function loading(e:ProgressEvent):void {
text_txt.text = "Loading... "+int((this.stage.loaderInfo.bytesLoaded/this.stage.loaderInfo.bytesTotal)*100)+"%";
}
function loaded(e:Event):void {
play();
}
When i tested in the local machine it worked, but when i upload to the server online the preloader shots to 100% and don't show the progress percent.
I've tried export classes to the frame 2 and error still continues. I'm using just only one TextField on the stage.
It's most likely one of the following two issues:
The .swf is delivered by the server gzipped. This prevents the swf from starting until the whole file has been downloaded. You can see if it's being gzipped by opening the Dev tools (F12) in Chrome, go to the "network" tab and select the .swf and check for "Content-Encoding:gzip" under the "Response headers" headline. Note that you need to clear the browser cache first to make the browser download the .swf from the server, otherwise the Response headers won't be visible. Here's a relevant thread talking about gzip and swf: Preloader flash AS3 it's no longer working [GZIP issue].
You embed the .swf on the html page with wmode parameter set to "transparent". It's a known bug several years old, so I would be surprised if that is still relevant today. But if you do embed with wmode it's a quick test to remove that parameter and see if the problem is resolved.

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.

ActionScript not showing up in Actions - Frame window in Flash CS5

In an existing fla file, I'm not able to find strings within actionscript that is contained within certain frames (regardless of which frame it's in). So for example in frame 1 there is the following code:
stop();
But searching for 'stop' (without quotes) doesn't turn up any results.
If I create a new fla file, I'm able to find actionscript in all keyframes. Furthermore, I've noticed that the "Actions - Frame" window shows me a tree of all the ActionScript in the scene, organized by frame. This isn't happening in the first .fla file - I can open up and edit actionscript for a frame, but the tree/index never gets built.
Has anyone run into a situation like this? Is the first .fla corrupt in some way, or is there a setting to allow me to easily find actionscript within all frames? Thanks!
Have you checked the settings in the search box? Maybe the search is document based and the specific file you are having trouble with has different settings from the default one. Try to compare the working file with your "corrupt" file. Actionsctipt should be enabled.