Solved

Adobe Flash CS5 Preloader not working

Posted on 2012-03-25
23
625 Views
Last Modified: 2012-04-02
Using Adobe Flash CS5.
Created a 1mb (.swf) presentation (images, transitions, voice-over, etc).
Used the Preloader for SWF template from Flash CS5 library.
Copied the code into its own layer called "AS3" into frame 1.
Copied the little text box with instance name percent_txt into frame 1.
Everything else starts in frame 2.

The profiler still reads about 300kb in the first frame and it takes until about 50% (about 20 seconds at 56kb dl) until the simple image I put on frame 1 appears.


I read on a forum something about "exporting about 1mb of assets in your first frame", but I don't understand what that means...
profile.jpg
0
Comment
Question by:tlengnick
  • 13
  • 9
23 Comments
 

Author Comment

by:tlengnick
ID: 37764160
OK, I found it...

In Publish Settings, Flash Tab... next to the Script: ActionScript 3.0, I clicked the "settings" button and changed the "Export classes in frame:" option to "2"

However, my preloader doesn't show until about 450-500kb of the 900kb file is downloaded...

How can I get my preloaded to show almost immediately? There is nothing else but the preloader AS3 and the text box in frame 1!
0
 
LVL 8

Expert Comment

by:Jen0910
ID: 37766155
Can you share your file? Or code? I'm attaching a preloader that has always worked for me. Feel free to try it/manipulate it to look as yours does, otherwise I think getting a look at your code will help us lend you a hand. It's hard to fix what we can't see ;^)
preloader3.0.fla
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37770005
the way a preloader works is that everything that has the export in frame 1 option checked will have to be loaded into memory before it starts calculating.

Here's a quick explanation from senocular - although this post is for AS2 the concepts are the same.
http://www.senocular.com/flash/tutorials/faq/

I don't know how you did your preloader but I'd recommend using the seperate file - that works wonders - i use it on my massive game files.
Here's a tutorial from Lee Brimlow.
http://www.leebrimelow.com/?p=438
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 

Author Comment

by:tlengnick
ID: 37772467
Ok, I used Lee Brimlow link above and preloader works, but...

My audio file is starting when the preloader reaches 50%, then the rest loads when it reaches 100%... this leaves my content.swf file on frame 1, because it missed the first cuepoint associated with the audio file...

How can I either
1) Make the content.swf file load 100% before playing, or

2) Let the entire content.swf file play (images linked to cuepoints and all) at 50%?

Here is my AS3 code for the project. This begins in Frame 1 and spans the 60 frames of the file.

Experts-Exchange does not allow me to upload my .fla file.

--BEGIN AS3--------------------
import fl.video.MetadataEvent;
aud01.addEventListener(MetadataEvent.CUE_POINT, fl_CuePointHandler);

function fl_CuePointHandler(event:MetadataEvent):void
{
      if (event.info.name=="Cue Point 1")
      {gotoAndStop(5);}
      {trace(event.info.name + ", Time = " + aud01.playheadTime + ", Frame " + (this.currentFrame +1));}
      
      if (event.info.name=="Cue Point 2")
      {gotoAndStop(10);}
      
      if (event.info.name=="Cue Point 3")
      {gotoAndStop(15);}      
      
      if (event.info.name=="Cue Point 4")
      {gotoAndStop(20);}      

      if (event.info.name=="Cue Point 5")
      {gotoAndStop(25);}      
      
      if (event.info.name=="Cue Point 6")
      {gotoAndStop(30);}      
      
      if (event.info.name=="Cue Point 7")
      {gotoAndStop(40);}      
      
      if (event.info.name=="Cue Point 8")
      {gotoAndStop(45);}      
      
      if (event.info.name=="Cue Point 9")
      {gotoAndStop(50);}      
      
      if (event.info.name=="Cue Point 10")
      {gotoAndStop(55);}      
      
      if (event.info.name=="Cue Point 11")
      {gotoAndStop(56);}      
      
      //link to APA convention @ 2:00
      if (event.info.name=="Cue Point 12")
      {gotoAndStop(57);}      

      //link to
      if (event.info.name=="Cue Point 13")
      {gotoAndStop(58);}      

}

stop();

--End AS3------------
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37775283
how is aud01 added to your project?
shouldn't it be stopped and only called to play when the loading of the main file is completed.
0
 

Author Comment

by:tlengnick
ID: 37776135
it's an imported f4v... I treat it like an external video in order to assign q points. the play automatically box is checked. maybe if I  uncheck that and write as3 code to start playing on frame 2?
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37776868
yeah that would make a difference but you're importing it via code right? not putting it on the stage directly. It would make sense to preload that as well.
0
 

Author Comment

by:tlengnick
ID: 37778399
I put it on the stage... Do you recommend not to?
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37778694
i'm not familiar with using f4v formats, from what I understand, it makes use of a progressive download - so it starts buffering then plays a little bit etc. .. so how much control you have of it - it's hard to say.

my thinking - and this is thinking out loud - not from actual experience of it- it would make more sense to preload the movie - then when that's ready, add my audio (video)

var _vid:Video = new Video()
var nc:NetConnection = new NetConnection();
nc.connect(null);
             
var ns:NetStream = new NetStream(nc);
ns.client = this;
             
addChild(_vid);
_vid.width = 200;
_vid.height = 140;    
_vid.attachNetStream(ns);
             
ns.play("uourfile.f4v");
0
 

Author Comment

by:tlengnick
ID: 37779211
Ok, I know I'm doing this wrong... I put your code in the preloader code like this:

import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
var _vid:Video = new Video()
var nc:NetConnection = new NetConnection();
nc.connect(null);
             
var ns:NetStream = new NetStream(nc);
ns.client = this;

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));

function loop(e:ProgressEvent):void
{
      var perc:Number = e.bytesLoaded / e.bytesTotal;
      percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
         removeChildAt(0);
         percent = null;
         addChild(l);        
      addChild(_vid);
      _vid.width = 200;
      _vid.height = 140;    
      _vid.attachNetStream(ns);
      ns.play("audio.f4v");
}

----------END AS3 -----------

...and I'm getting this error.


ReferenceError: Error #1065: Variable Icon is not defined.

and the audio is playing but not triggering any cue points now... the audio is on the stage and starts in frame 1, if that helps.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37779327
can i look at it in the morning (my morning) - it's almost midnight and it's a school night.
If you could upload your files that would help.
0
 

Author Comment

by:tlengnick
ID: 37779503
no problem... Experts-Exchange does not allow me to upload .fla files... even when I zip them, it finds some file in there that it doesn't like and doesn't accept.

Here is a link to the file online... maybe seeing it might help a little...
http://www.psychtrain.com/R-PAS.html

this is killing me.
0
 

Author Comment

by:tlengnick
ID: 37780213
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37790881
how big if the audio.f4v file - will you upload that as well?
let me test properly.
0
 

Author Comment

by:tlengnick
ID: 37791246
sorry. that was an oversight... here it is: http://www.psychtrain.com/RPAS/Flash/audio.f4v
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37793299
ok what am i missing. when i run your  file it runs as expected - the animations are synched with your audio?
0
 

Author Comment

by:tlengnick
ID: 37793324
When I test the file (preloader.fla) in Flash CS5 and use the Bandwith Profiler and select "Simulate Download", the audio starts playing at 50% or so... then, the video flashes an image just before the hummingbird that shouldn't occur, then the video kind of "catches up" to the cue points and plays normally.

I'm trying to stop that audio from starting until the whole file is loaded and plays normally from the get-go.

When I load the preloader on my site, it's not working... we can open another ticket for that one if needed... see http://www.psychtrain.com/RPAS/withpreloader.html

I need to figure out how to stop audio from playing (I am treating it like a video file so I can use dynamic cue points) before the entire file is downloaded when I use an external preloader.
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 37795394
ok it might be as simple as unchecking the autoplay checkbox in your flvplayback component and calling a play on it once the file is loaded.

why do you do the checklastframe on the preloader?

have a look at the files i've uploaded.
1. i changed your preloader to not do that checklastframe - dont' think that's necessary.
2. i unchecked the autoplay for your flvplayer.
3. i removed the gotoAndPlay(1) when the file is loaded.
4. i've called the start on your audio in the introduction file.

ok having bandwidth issues, instead of uploading  the acutal files see if you can work with the snippets.



function loadProdComplete(e:Event):void {
      trace("swf file loaded");      
      vBox.removeChild(preLoader);
      vBox.addChild(swfLoader);      
      currentSWF = MovieClip(swfLoader.content);
      currentSWF.aud01.play();
}
0
 

Author Comment

by:tlengnick
ID: 37796661
The instance name of the audio is "aud01."

When I put following line in the AS3 on frame one, it does the same thing as having autoplay checked:

aud01.play();

1) Is there a different code for making it play that might work differently?
2) Is there a way of having a statement like:

if (framesLoaded = totalFrames){
aud01.play();
}

would it go in the main .fla or in the preloader?

3) As far as the checkLastFrame function, I don't really know... I downloaded that preloader and just changed the names to match my files...

do you see a problem with that function?

Thanks for sticking with this... no one on here seems to know Flash but you! :)
0
 

Author Comment

by:tlengnick
ID: 37796979
Dear, sweet heavens, it works!

http://www.psychtrain.com/RPAS/Flash/R-PAS2.html

Thanks so much for your help and tenacity!!!
0
 

Author Comment

by:tlengnick
ID: 37797002
I did what you suggest and put the aud01.play(); code in the "completed" function of the preloader.

So, in the actual .fla file, there is no AS3 telling the aud01 file to play (and I unchecked autoplay as you suggested).

I also put the .html files in the same folder as the preloader.swf and introduction.swf file, but that shouldn't matter.
0
 

Author Closing Comment

by:tlengnick
ID: 37797005
Thanks!
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 37797198
:-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Embedding Flash App/Movie on Website 3 503
Accessing Live Dynamic Stream 6 200
Flash Slides/Presnetation 4 77
good online free meeting tool with record audio video feature 2 154
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

820 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