Posted by johnallen84 in SWF Studio V3 on Feb 25 2008, 03:36 pm

I have built a teaching application that uses 7 video clips. Each clip is about 10MB. I have included the video clips in the exe produced by swf studio (version 3.4). All works fine, but when the application is put onto CD it takes an age to load - presumably because it is so 'big' because of the video files. I assume that I should be keeping the flv files external to the exe so that the exe is 'lighter' and loads faster. The code I am using on each clip is:

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("EnergyVideo.flv");

I assume it is all in the addressing of the flv, but having looked through the forum and knowledge base I'm still struggling.

I'd be very grateful for any advice! Thanks


Posted by mbd in SWF Studio V3 on Feb 25 2008, 04:58 pm

Are you saying that the EXE takes a long time to load? Or that each video takes a long time to load?

Are the files set to auto-extract at startup (the default)?

Are you enabling the option to use the secure loader for the main movie? If you aren't then that's fine - just trying to determine what your project is doing.


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 05:44 am

Thanks for the help, Derek

The .exe takes a long time to load. Once the exe is loaded the flv's are instant.

Under the Movie tab:
I did have 'use auto-extract....' checked, but I have now unchecked that and checked 'use folder where projector is started from..'

'Use secure loader...' is unchecked
''Upgrade main movie to SWF8..' is checked

There are 7 flv's, all about 10-15 MB, so the total size of the exe is 90MB. From the hard drive all works fine - I press a button and the movie loads and plays. Press another button and the new movie loads and plays. I'm assuming that when this is installed onto a school network it will work in a similar way.

However, I would also like the exe to be run from a CD and it's this that seems to be slow. I wondered if the flvs should be kept outside the exe, hence making it very small. The external flvs then loaded when needed. As you will realise, I'm new to using flvs. All my applications before have just used animations etc.

I'll now see if the new settings make much difference.

Thanks for the help - I'd be grateful for any more advice!


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 06:23 am

I've now re-tested a CD with the exe on it - it still takes about 1 minute from double clicking until it opens


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 09:56 am

OK - what an idiot I am. To date I've only made simple applications and have not set autoextract or noautoextract in the files tab - I've just shoved everything in there.

So now I'm trying putting the flvs as noautoextract and using code like:

ns.play("startdir://EnergyVideo.flv");

to find the files.

Am I on the right lines?

Presumably the code won't work when just testing the swf files?

I'll try it and see.


Posted by mbd in SWF Studio V3 on Feb 26 2008, 10:47 am

The startdir:// will work (however, not in 3.5 ActionScript 3), but it shouldn't be necessary. As long as you leave the default base path as "use folder where projector is started from" Flash should be able to find your FLVs.

QUOTE:
have not set autoextract or noautoextract in the files tab - I've just shoved everything in there.The default is to autoextract. If you right-click on a file you can set it to not autoextract. Or you can right-click on the root node and make everything not autoextract.

That should make your EXE launch faster.

Do you have an Anti-Virus program? If so, it's possible that part of the slowdown is the av program scanning the file when it's about to launch. 90MB is pretty big and may take a while to scan, especially from CD.

Having the files external should resolve your speed issues.


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 11:21 am

Thanks for your help, Derek - I think I am starting to get somewhere.

However, now when I build the exe, all works well when I test it on my hard drive, but not when i put it onto CD or pen drive. When I open it from CD/pen drive the initial screen opens, but when I try to switch to another page it goes blank - as if the new swf being loaded doesn't exist. Any ideas?

Thanks!


Posted by mbd in SWF Studio V3 on Feb 26 2008, 11:42 am

When you say "switch to another page" what does that mean? Are you just loading another SWF as a movieclip? Is the SWF in the same relative position it is when testing from your harddrive? If you move your project to another folder on your harddrive do you see the same issue?

Can you try your original project with 3.5? See if that is any speedier from the CD.

What OS are you testing this on?


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 11:53 am

When my application opens there is a main menu page. There are buttons which open other pages e.g. 'Simulations' opens a swf where various simulations can be played. There are other pages for video, interactivity, test etc. - all done by loading and unloading swfs

I'm using windows xp, but also testing on vista

As I say - all worked well before - just slow loading

The main menu opens fine, but cannot 'find' any other pages. It works ok when I'm in the same folder as the swfs etc., but not when I move it to another folder or onto a pen drive CD.


Posted by mbd in SWF Studio V3 on Feb 26 2008, 12:03 pm


QUOTE:
It works ok when I'm in the same folder as the swfs etc., but not when I move it to another folder or onto a pen drive CD.
If it doesn't work when you move the project to another folder, then you aren't moving all of the necessary files.

You should be able to simply move the main SWF and have the same effect.

If you don't include your SWFs in the EXE, and you have the default base path set to the start directory, and the paths you're specifying to load the SWFs are relative then you shouldn't have any problems - it should behave the same as double-clicking your main SWF.

If you've moved all of the SWFs over and you're still unable to get them to display, then can you post your SPF file for me to look at?

I'm thinking this is a path issue, or files aren't being placed where they need to be, or a setting in SWF Studio that affects paths is set and is causing the grief.


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 12:28 pm

Thanks Derek. I have to be away for about an hour, but I'll send the spf file as soon as I get back. I've probably missed something obvious.

Thanks again


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 01:46 pm

Please find attached the spf - I'd be grateful if you could have a look.
Thanks

attachments: Energy2.spf  


Posted by mbd in SWF Studio V3 on Feb 26 2008, 02:17 pm

What code are you using to load the SWF?

I'm guessing that it's loadMovie, rather than MovieClip.loadMovie. The global loadMovie command, where you specify the movieclip as an argument to the function, is different from MovieClip.loadMovie, where the loadMovie call is a function on the movieclip you are loading a SWF into.

The SWF Studio API overwrites some of the native Flash load commands to make projects like yours an easy transition. If you were to use, for example myClip.loadMovie("Test.swf"), the API would look for the file in the default base path, and if it wasn't found, load from the autoextract folder. That way you can just drop your project into SWF Studio and everything is in 1 EXE with no code changes.

However, the global loadMovie command cannot be overwritten. We can't make corrections for you in that case. You either have to specify the full path to the SWFs to load, change the default base path to look to the autoextract folder, or change your code to use MovieClip.loadMovie.

1. If you change the default base path to the autoextract folder it means all relative paths for native Flash commands will look to the temp folder to load files. If you are trying to load files next to the EXE, you'll have to change the paths. For example if you wanted to load your FLV with a Flash 8 FLVPlayback component:
myPlayer.contentPath = ssGlobals.ssStartDir+"\\EnergyVideo.flv";
or:
myPlayer.contentPath = "startdir://EnergyVideo.flv";

The file moniker (startdir://) works because setting that contentPath property, or any of the other component load commands, eventually get down to NetStream.play, which the SWF Studio API overwrites to handle paths.

2. If you want to manually set the path to the autoextract folder, so you don't have to change the default base path, you could use:
loadMovie(ssGlobals.ssTempDir+"\\Test.swf", myClip);

With this option, you wouldn't have to change any of the code for the FLVs.

3. Change your loadMovie calls to MovieClip.loadMovie calls. No other changes are necessary.

I would go with option 3 since it means your project would work outside of SWF Studio as well, without any other changes.


Posted by johnallen84 in SWF Studio V3 on Feb 26 2008, 02:24 pm

Thanks Derek. Yes I am using loadMovie throughout. I'll work on option 3 tomorrow and hopefully that should sort it.

Thanks again for your help!


Posted by johnallen84 in SWF Studio V3 on Feb 27 2008, 02:36 pm

OK, for a while I thought I had this sorted. I created a new 'empty' swf to hold the various swfs, the relevant code on this new swf being:

this.createEmptyMovieClip("key_mc",0);
key_mc._x =0;
key_mc._y =0;
key_mc.loadMovie("Splash.swf");

This therefore starts by opening the 'empty' swf and immediately loads the splash swf screen that I use. I've now got a movieclip that I can load into and unload from.

Further down the line, typical navigation script may look something like:

next.onRelease = function(){
_parent.key_mc.unloadMovie("Ac1.swf");
_parent.key_mc.loadMovie("Ac2.swf",0);
}

All works well as swf's, but when I create the exe all that happens is that the 'empty' swf opens - Splash.swf doesn't load into it

I'd be grateful for any further advice! Thanks


Posted by mbd in SWF Studio V3 on Feb 27 2008, 02:51 pm

What is the version of SWFs you are publishing for? Are any of your SWFs published for version 6?

If not, skip this explanation...

I ask because in your SPF you have upgrade to 8 checked, which people usually do to get synchronous command support and some other Flash Player 8 features when they have SWFs published for version Flash Player 6.

The problem is that with your main SWF as version 8, any SWFs you load that are published for fp6 will not share the same _global, or share any of the versions of native Flash commands that the SWF Studio API modifies.

What's worse is that if you load a version 6 SWF into _level0, the original _global and modified commands are completely removed, since the new SWF has a completely new _global. Loading SWFs of the same version keeps the _global intact (version 6 and 6, or version 7/8/9 and 7/8/9 - there was a break in functionality from 6 to 7, which is where this problem comes from).

A couple of notes:
unloadMovie doesn't take any parameters, so you don't specify the URL, you just unload whatever movie is in the movieclip you are calling the unloadMovie on.

The MovieClip.loadMovie method's second parameter is the method, as in GET or POST. You have specified 0, I'm assuming to load the SWF into _level0. It doesn't work that way. You have to use loadMovieNum or _level0.loadMovie.


Posted by johnallen84 in SWF Studio V3 on Feb 27 2008, 03:01 pm

I'm using Flash 8 Professional and publishing for Flash Player 8. (I'd not consciously checked the upgrade to Flash 8 box).

As you've probably gathered, I'm not a whizz on ActionScript and it takes me a while to get the technical stuff! However, I am learning loads and I'm grateful for your advice. Am I a million miles away?


Posted by johnallen84 in SWF Studio V3 on Feb 27 2008, 03:03 pm

So should this:

next.onRelease = function(){
_parent.key_mc.unloadMovie("Ac1.swf");
_parent.key_mc.loadMovie("Ac2.swf",0);
}

read as:

next.onRelease = function(){
_parent.key_mc.unloadMovie();
_parent.key_mc.loadMovie("Ac2.swf");
}


Posted by johnallen84 in SWF Studio V3 on Feb 27 2008, 03:19 pm

OK, I think I'm getting somehwere. I unchecked the upgrade to 8 box and re-built and it now seems to be working. Thanks for all the help, Derek - any further advice would be welcome.;


Posted by mbd in SWF Studio V3 on Feb 27 2008, 03:37 pm

For your previous post, yes the bottom code is technically correct.

If you are publishing ALL of your SWFs for Flash Player 8 then checking or unchecking the checkbox in SWF Studio shouldn't make a difference. Remember, even if you're using Flash 8 it doesn't mean you're publishing for Flash Player 8. This catches a lot of people that were using a project they started in Flash MX and then save in Flash 8. Flash doesn't change the publish settings, it only changes the format of the FLA.

I'm glad it's working for you. If you run into something like this again, the best thing to do is tackle a big problem one step at a time. Create a simple version of the functionality you are having problems with. In this case, build a simple FLA that just loads another SWF. Then build a new SWF Studio project with just the main SWF and the other SWF in the Files tab. Get that to work and then apply the changes.

Oh, and get your code out of the buttons! :) The code for your buttons looks as though it's in a timeline as opposed to directly on a button, which is good. However, if you have the same functionality spread across many buttons have the buttons call the same function to do the job. In this case:
next.onRelease = function(){
MyUtilities.loadMovie("Ac2.swf", _parent.key_mc);
}

Create a _global object that will contain any special functionality like this:
_global.MyUtilities = new Object();

Then create a function:
_global.MyUtilities.loadMovie = function (url, mc)
{
mc.unloadMovie();
mc.loadMovie(url);
}

Why would I suggest that? If you would ever want to change functionality in that call you would otherwise end up looking all around your FLA for code snippets to replace. This way you make changes in one place.

The organization of objects/classes like this is not a small subject, but the idea is to think of what your project is intended to do and centralize as much of the functionality as possible. You end up with a project that is both easy to maintain and easy to modify.

... way out of the scope of SWF Studio so I'll stop there.


Posted by johnallen84 in SWF Studio V3 on Feb 27 2008, 03:47 pm

Thanks for that, Derek.

It all seems to be working now, other than when the flvs are set to NoAutoExtract -I'll work on that one tomorrow!

Thanks again