?
Solved

preloading swf  alternatives

Posted on 2011-10-25
8
Medium Priority
?
621 Views
Last Modified: 2013-11-11
I need an alternative solution to preloading several swf files whos content come from database.
Ive tried several, built into flash preloaders with no success. The problem that i'm having is that the content sometimes loads and sometimes it hangs. this site is an AS2 flash site which loads 7 swfs as sections, originally it was xml driven but it was converted to run with a content editor. at this point i just need  perhaps a javascript solution to keep these swf files in the browsers until i need them. One solution that was sort of working for me was using a header script to quickly reload the page just enough to capture the swf files but unfortunately the script just kept reloading over and over, and the one page loader that I found that reloded one time only worked great in FF but not in stupid IE(god I hate IE) Anyways any help would  be greatly appreciate and returned in great karma :)
0
Comment
Question by:ukraze
  • 4
  • 4
8 Comments
 
LVL 6

Expert Comment

by:GregArnott
ID: 37029019
Have you considered loading in the swfs as iFrame contents?

Thus the JavaScript controlling them can stay on the current page, and you simply refresh, update or replace each of these content regions as required.

0
 

Author Comment

by:ukraze
ID: 37029072
Thank you for posting, but I'm not too clear about this solution, could you please elaborate more? - Where would the Iframe go? and what javascript code would I use?
0
 
LVL 6

Accepted Solution

by:
GregArnott earned 2000 total points
ID: 37029295
Some parts aren't completely clear in your question, as it's a little scattered. So this is a basic concept that you can tweak and apply.

Is this what you had in mind?
* Page loads.
* Multiple flash files on the page, but only 1 or none to be visible to begin with.
* A trigger (onclick event, for example) then shows the flash all ready loaded and ready to go.

Think of an iframe as a hole in the current web page showing another web page. This other web page will load the swf ready to use, as long as you have the preloader or starting frames set correctly - doesn't matter which of the many techniques used for loading the swf without it starting to play automatically - all should work.

The swf is loaded into another token page (ie: swf1.html, but can be any dynamic page as per your server, such as .php .asp .cf etc) which has heights and widths set to 100%. Thus the size of the output that is visible is based off the size of the iframe window that pulls in this other page.
   <section id="swf1">
      <iframe src="swf1.html" name="iframe1" width="400" height="300" frameborder="0" > 
   </section>
   <section id="swf2">
      <iframe src="swf2.html" name="iframe2" width="400" height="300" frameborder="0" > 
   </section>

Open in new window


From there, the javascript for showing is either:
* changing a CSS display state of the appropriate section wrapping the iframe, with the iframe set at the final height width desired
(section will require an initial state of: display:none;)
// vanilla javascript:
document.getElementById("swf1").style.display = "block";
// jQuery:
$("#swf1").show();

Open in new window


OR

* changing the dimensions of the iframe within the appropriate section to width="400" height="300".
(iframe will require an initial state of: width="0" height="0")
// vanilla javascript:
document.getElementById("iframe1").style.height = "300";
document.getElementById("iframe1").style.width = "400";
// jQuery:
$("#iframe1").css({width: '400', height: '300'});

Open in new window


I've tried to use old school and longer simpler code to make it easier for understanding.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ukraze
ID: 37030619
Thank you Greg I will give this a try today after work and let you know if it worked out. :)
0
 

Author Comment

by:ukraze
ID: 37050557
Sorry about the delay on reply. I followed and applied a slightly different version what you suggested
and its is working out good. Thank you

One more question if you don't mind? i have an swf file coming through that iframe which is playing audio. I cant lower the audio on that file cause that same swf file will be called to open in another window with its audio playing. so how can silence the audio on the iframe without affecting its sound playback in the window that it will open in.
0
 
LVL 6

Expert Comment

by:GregArnott
ID: 37051004
I'd try starting with the loading option:
autostart = "false"
Then toggle playback when its window is selected.

This would mean you're not changing default audio, nor have to add control frames to your swf, and still have your swf preloading.
0
 

Author Comment

by:ukraze
ID: 37051101
Are you talking about doing this in actionscript? and if so, can you show me a sample code for toggling the playback?
0
 
LVL 6

Expert Comment

by:GregArnott
ID: 37051329
This is in the html code or javascript depending which method you are using to call and play your swf files.

I've avoided all AS methods.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
Suggested Courses
Course of the Month16 days, 18 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question