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

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.

Related

Creating Preloader for SWF in AS3 Flash Builder

I'm a relatively new developer in AS3 using Flash Builder. My objective is to create a quick/fast loading small SWF preloader for a larger (30mg) SWF application. I can't include the larger SWF inside the preloader, but I can use external interface calls to get jquery to tell me what the speed of internet the users are using and figure out how long it should take to load based on the size of the larger SWF.
Right now, we have a large web application that takes around 5 mins to load if the client has a slow internet connection. So, we wanted to use a small SWF preloader that will display a loading circle or loading bar, and display options if the SWF takes longer than 5 mins to load. Kind of like error handling. For instance, for Safari, sometimes the player actually has to click the SWF in order for it to load. Is it possible to have a button on the SWF that will make it start loading?... Is it easier to create the preloader in jQuery? I'm just wondering if it's just going to create more issues using a SWF to load a SWF. Any ideas?...
Any ideas on how to tackle this beast? I've read almost every article about preloaders but there is nothing that references preloaders created in Flash Builder.
I can't use Flash Professional or timeline. It has to be in Flash Builder.
So I tried to use the below tutorial and I wasn't able to actually get anything to appear when I test it. I'm getting an error at the "run()" function:
Error: Error #2136: The SWF file http://local.myproj.com/MyProject.swf contains invalid data.
at Preloader/run()[/Development/MyProject/src/Preloader.as:109]
at Preloader/onEnterFrame()[/Development/MyProject/src/Preloader.as:46]
References:
http://fortheloss.org/how-to-preloader-in-flash-builder-4-7/
I worked until two years ago with a lot of these things and I know I have a few good scripts in my databases, but you are talking about Preloaded & activated loading were as in a preloader it is out of the hands of say a visitor what he or she can or cannot do, and in using a button (possible of course) the visitor has a choice to download or not! From memory there was never really a lot published yet over years of using Flex Builder I have collected some good AS3 scripts and modified them (including a progress-bar - but without time Indicator) to download in web Apps. or FLEX AIR etc. with AS3.
The small problem would only be to adapt any of it from mx to fx depending on what FLEX Builder you use!
I used my scripts mainly to download high resolution Images, Calendars, SWFs etc. with up to compressed 22 mB! Anyway, if Interested I have to look up my FLEX databases & Application to get it to you! rgs Aktell

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.

Single-swf preloader wrapper in Flash

I have a .swf that I'd like to create a preloader for. In the end, I want a single file which combines both the preloader and the content .swf.
Every tutorial I can find on Flash preloaders offers one of two options:
Using a URLRequest in the preloader wrapper to load an external content .swf. This will not work because I do not want two .swfs.
A "single-swf" solution like this one which works for assets which you have created in the Flash IDE. I assumed I would easily be able to go this route, but I'm having trouble. I cannot use the Flash IDE to import my content .swf. I can use an embed tag like so:
[Embed(source="content.swf")]
private var MyContent:Class;
But it seems like this embedded content is exported on the first frame, so my preloader only appears after the content .swf is loaded. I'm guessing it's something along these lines. Any thoughts?
But it seems like this embedded content is exported on the first frame
You are absolutely correct, all Ebmed do embedding in the first frame by default but mxmlc provides solution by creating two frames swf with preloader in the first frame via the metatag:
[Frame(factoryClass="Preloader")]
You can find step by step guide here http://www.bit-101.com/blog/?p=946.

3D transforms on loaded SWFs aren't working

Here's the scenario:
Our creative team produces SWF animations in the Flash CS5 authoring tool that we (the engineers) load at runtime into a project built using the Flex SDK. Animations that don't use the "3D rotation tool" work just fine.
Animations that use the 3D rotation tool give the following behavior:
MovieClips that have 3D tweens applied using the 3D rotation tool show up in the top-left corner of the stage as if they had no transform at all (i.e. as if their Matrix3D was being ignored, and their Matrix was identity)
MovieClips that have normal 2D tweens animate properly
Alpha and other non-affine properties tween properly
Both 3D and non-3D animations play fine when loaded by themselves in a browser tab or the standalone flash player. 3D is only broken when loaded into our code generated SWF.
So it seems that for MovieClips with 3D transformations applied in the CS5 authoring environment, those transformations aren't being applied / respected when the SWF is loaded by our code SWF.
This is my first foray into 3D, so I'm not sure what could be causing this, but here's what I've tested / checked / tried, all to no avail:
I've ensured that actionscript 3 and Flash Player 10 / 10.1 is selected in the authoring environment.
I've tried loading animations into code SWFs built using Flex 4.1, 4.5, and 4.6 at Flash player versions 10.0, 10.1, 10.2, and 11
I've applied Matrix3D to the containers that load the SWF animations, both identity and rotated. I can see the rotated containers do work with 3D in perspective, so I know that my code SWF is 3D capable.
I'm hoping there's some simple trick, some setup I'm missing. Thanks for your help!
This may be something that is going on in your Flex code, such as stopping the animations, or not starting them. Can you post the code that you use to load the SWFs?
This may be a race condition, too. You may have to wait until the SWFs are loaded (e.g., addedToStage events or the like) before using them.
I came across your problem because I had exactly the same issue... And after a lot of poking around, the solution (for me) boiled down to this:
If, at any point, you are strong-typing your CHILD swf to a class, or referring to any of its variables using dot syntax from the PARENT, it breaks. Even if it's just a trace message.
I had to replace this:
var stoneVideo:StoneVideo = loader.content as StoneVideo;
stoneVideo.stoneText = model.stoneText;
With this:
loader.content["stoneText"] = model.stoneText;
And it started working properly. Hope this helps!
I can't post code, but it turns out it was an overly cautious subtlety in our loader code that had never caught us before:
We have a custom class that loads all images for us (including a few utilities and common functionality built in). On load complete, this code took the loader.content, added it as a child to itself, and -- here's the kicker -- cleaned up the no-longer-necessary loader using close() and unloadAndStop().
I suppose it seemed rational to cleanup the loader in this way, and it has always worked until now (with static images, static SWFs, and SWF animations), but it caused the above issue upon loading 3D swfs (and it turns out this also caused odd URL not found errors on loading video SWFs).
Disabling the overly cautious Loader cleanup fixed my problem.