Preloader does not work online - actionscript-3

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.

Related

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!

Never Have Access to Embedded SWF Content Through Loader

I am working on embedding a SWF that is just a converted PDF created with InDesign. The SWF is 15 pages, 1 page per frame. It does include TLF text and there is no way around that unless the document is completely recreated in Flash. The problem is that when I load the SWF into my application, I never have access to the root MovieClip.
this.loader = new Loader();
this.loader.contentLoaderInfo.addEventListener( Event.INIT, this.loaderInitHandler );
this.loader.contentLoaderInfo.addEventListener( Event.COMPLETE, this.loaderInitHandler );
this.loader.load( new URLRequest( "assets/doc.swf" ) );
When I look at the loader after both the INIT and COMPLETE events as well as later on by stopping the app in debug mode, I do not see a MovieClip. Instead, the loader.content is of type doc_fla.MainTimeline__Preloader__ which contains two children, an empty Shape and another Loader. That loader, when checking INIT and COMPLETE events results in the exact same situation and it appears to be a never ending line of Loaders whose contents are "Preloaders".
Could anyone shed some light as to what is causing this or how I might fix it? I've poured a good 2 hours into solving this and I am no closer to a solution than when I started.
ActionScript Mobile project
Compiling using AIR 3.6
Testing in emulator as well as on iPad and on Nexus 7
I recompiled the SWF and embedded the TLF libraries (under ActionScript settings, just set the TLF swc which was already there to be embedded) in it and this seems to have fixed the issue. I swear I had tried that before to no success, but it worked this time.

eventListener flash

I am working with AS3.
I simply can't remember what eventListener to use if I want it to start my function up by it self (as in not a mouseevent.CLICK)
It is intended for a quick flash banner, that should just start up when ever a user enters the site where it is located.
You don't need to hook into an event for this.
When the site is loaded, the swf will load and play.
If the site is refreshed, then the swf will be reloaded (from cache) and be replayed
So any code that instanciates your app will be executed.
You can do loaderInfo.addEventListener(Event.COMPLETE, _YourFunctionToBeExecuted) if you want to do something when your swf file has been loaded completely
Or
You can do addEventListener(Event.ADDED_TO_STAGE, _YourFunctionToBeExecuted) if you want to run your code when the display object has been added to the stage

as3 save swf stage to desktop - only works in IDE

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)

Adding an intro to a swf without access to the fla OR: differences between top-level and loaded swfs

I've got to (quickly!) add an intro to an existing flash masthead on a site that I've inherited. I don't have access to the source .fla's, so I approached the problem by putting the intro in a wrapper swf and loading the current masthead and adding it to the display list on Event.INIT. So far, so good. (Incidentally, the swfs are built for flash player 9 and use AS3.)
The problem I'm having is that although the intro plays fine and loads / displays the beginning of the masthead swf, which is a loading animation, the masthead itself never actually plays. Essentially, my question is: what would cause an actionscript 3-based swf to behave differently when it's the child of another swf as opposed to at the top level of the embedded swf?
Potentially important details: Embedding is being handled with swfobject, and no flashvars are being passed in. There are two params, which are base: "/flash/" and wmode: "opaque". All the swfs and flash data live in /flash/. The flash elements (minus the intro I built) were constructed using the Inky flash framework, with which I'm not familiar.
UPDATE: I've reconsidered my approach to the problem and gotten it working by using ExternalInterface; I'm having the intro swf call a js function when it finishes playing, which swaps out the intro swf and replaces it with the current masthead (the approach is outlined here). I'd still like to know why I was witnessing the behavior I was seeing earlier, though, so any ideas and suggestions would be welcome.
There could be a couple of potential problems with your flash files.
If your swf was compiled in AS2, it could be referencing _root which would be messed up when it is loaded into another swf. In AS2, you can get around it by using _lockroot. In AS3, this is not longer a problem because _lockroot is inheritted.
If your movie was a timeline based movie, you can try to invoke the play() function.
If your intro loads external assets, you will want to make sure your paths are set correctly for all your external assets. Try to put the swf file of your container and the intro in to the same directory. Or troubleshoot by using the Safari Activity window to see if you have any "404 not found".
Another thing is inconsistent flash version. You could run into problem if you load a Flash version 9 with a Flash version 10.
Hope these pointers help.