PDA

View Full Version : Importing a .swf file



benslayton
08-01-2006, 09:30 PM
Can I import an .swf into the library and it workk correctly. If so how.

BLiZZaRD
08-02-2006, 05:08 AM
Not into the Library. What you would do is just call it from the main timeline of the first movie.

For instance, if you have first.swf and second.swf you would upload both to the same folder.

In the main timeline of first.fla you would put



background.loadMovie("second.swf");


If you have the load on a button it would be:



on(release){
_root.gotoAndPlay(whatever number/frame);
}


and on the last frame of your animations to load:



onEnterFrame = function(){
loadMovie("second.swf", _root.getNextHighestDepth());
}


loadMovie is used either as...
loadMovie(url , target , method);
or
mc.loadMovie(url , method);
In both cases, method is optional.

:)

timothyj67
03-31-2007, 12:40 AM
I made a animated swf and tried importing it to the flash library to be in a main piece of work...The animated piece need to fly around and fade out..
But when I import it the animated piece is all broken up and doesnt animate....
ARGH!!
Didnt the older versions of flash import more smoothly?

Thanks!

BLiZZaRD
04-13-2007, 04:33 PM
Why would you want Flash to double in size and work twice as hard?

If you have your main swf you want to put inside another movie, instead of making it an swf copy ALL frames and make it a new MC. Then import this MC into the other movie.

buddycreative
10-01-2008, 11:50 AM
I also have this problem too. May I ask one question? please follow to what I have done.

1. When I made 2.fla which is going to be the final one. It must be contained 1.swf which I had already made like sky have many clouds go infinitely from right to left.(At 1.swf, each clould is symbol that has their own timeline with code gotoAndPlay(01); at the right end frame, over timeline.)

2. I imported 1.swf to Library and put it at frame1 and extended frame to be background for 2.fla

I found that the 1.swf is not work properly. Clouds were not imported, it was just clear blue sky with nothing goes by.

Could you please suggest to make 1.swf work perfectly in 2.fla?

1.jpg is 1.swf which it works properly. http://www.mice.co.th/1.jpg
2.jpg is 1.swf in symbol of 2.fla which cloulds not work properly.
http://www.mice.co.th/2.jpg



Thanx
Bryan
^^

Medyman
10-01-2008, 01:22 PM
What's your code in 1.fla? It's almost impossible to guess what's going on without some code.

What I suspect is that your're using relative paths that are incorrect. If you're using _root in your 1.fla, then that's 100% the problem.

buddycreative
10-02-2008, 04:19 AM
Hi Medyman..

May I send you the link for downloading this file? So you could see what's wrong.

First is 1.fla which has clouds works properly.

http://www.mice.co.th/1.fla

Second is 2.fla which 1.swf has been already imported to layer 1 but no clouds.

http://www.mice.co.th/2.fla


Thank you so much
Bryan
^^

Medyman
10-02-2008, 02:36 PM
Bryan,

I see what's happening here. You have two options (this is all done within 2.fla):

1) Reimport the swf. First, double click on 1.swf in your library. Then, delete Layer 1. Create a new layer. Select the first frame in that new layer. Next, go to File > Import > Import to Stage. Choose 1.swf from your HDD. Click Open. It'll take a few seconds to import..and all should be well.

2) Import the swf programatically. Click on 1.swf on your stage, go to the properties panel and assign it an instance name (i'll use animation for this example). Then, create a new layer on the main timeline, rename it to actions and click on the first frame in that layer. Then, add the following ActionScript 2.0:

animation.loadMovie("1.swf")
The code assumes that you have 1.swf and 2.fla in the same directory. If you don't, either move them so they are or change the path.

Test and if done right, you'll have imported the SWF.

The second method is by far the most efficient way to do it. It keeps your file size down. Ideally, you should add a preloader. Lee Brimelow has some great video tutorials on how to do this at gotoAndLearn() (http://www.gotoandlearn.com).

buddycreative
10-03-2008, 08:02 AM
Thanx Mr. Medyman,

I'm trying..and will let you know if succeed.

Bryan
^^

buddycreative
10-03-2008, 08:34 AM
Medyman,

I've already did follow your instruction then it's work!!...I'm really feel thanks to you deeply from my hearth ^^...

But I still do not understand the point.

1. Why do I reimport 1.swf ? even though I have 1.swf into library and it's already on the stage.
2. Why use import to stage from directory instead drag 1.swf from library to stage?
3. The code animation.loadMovie("1.swf") seems like it runs file 1.swf from directory, not from Library, so why do we need to have 1.swf in the library ?
4. If I put just .jpg with static background at the layer1, then rename it to animation, and put that code at the first frame, layer2..Can I? because I knew I have 1.swf in the same directory.

Sorry for a lot of questions, because I just start using Flash for 1 month.

Thanx Medyman
Bryan

Medyman
10-03-2008, 02:34 PM
Why do I reimport 1.swf ? even though I have 1.swf into library and it's already on the stage.
You can't add .swf files into the library. When you import a .swf file into the library, Flash creates a movieclip equal in length (based on the current framerate) but only showing the first frame of the imported.


Why use import to stage from directory instead drag 1.swf from library to stage?
Same reason as explained above.


The code animation.loadMovie("1.swf") seems like it runs file 1.swf from directory, not from Library, so why do we need to have 1.swf in the library ?
You don't. That's why I said that technique was more efficient.


If I put just .jpg with static background at the layer1, then rename it to animation, and put that code at the first frame, layer2..Can I? because I knew I have 1.swf in the same directory.
Yup. Thats exactly how you should do it. Any other way is a waste of resources.


Also, like I said, you should probably add a preloader if you're adding this to a website. I linked to a tutorial above. You'll want to watch "External SWF Preloading".