Groups | Blog | Home
all groups > flash actionscript > september 2005 >

flash actionscript : Combining Two .fla Files - How?


David Stiller
9/7/2005 2:29:47 PM
Matt,

[quoted text, click to view]

Remember, it isn't the FLA that gets published to the web. If you have
a Start button that is supposed to go to the first frame of another movie,
the "going to" will be to the first frame of another SWF. External SWFs can
be loaded into the current SWF via MovieClip.loadMovie() or the
MovieClipLoader class. Once the external SWF is loaded into the "parent" or
"container" SWF, the formerly external SWF can be referenced by instance
name of the movie clip that contains it. Using that instance name, you can
invoke any MovieClip class method, such as myLoadedClip.gotoAndPlay(1).

If you want to combine two FLAs, you would accomplish the somewhat
arduous task by copy/pasting frames from one FLA to another, or by dragging
movie clips (or other Library content) from one FLA to another.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

David Stiller
9/7/2005 3:39:11 PM
Matthew,

[quoted text, click to view]

Ha! No problem. :) I wouldn't call it dumbing down -- I'm sure you're
not dumb -- just a different or more thorough explanation.

[quoted text, click to view]

There are two ways to think of "a button called" something. There is
the name you give the button symbol in your Library. Separate from that is
the instance name you give the button instance on your Stage. Instance
names give you a means of addressing invidual buttons on the Stage, even if
they're dragged there from the same symbol in your library.

Give your button an instance name (see the Properties inspector when you
click once to select your button on the Stage). Now that it has this kind
of name, you can address it via ActionScript.

Create a new layer and name it scripts (this keeps your code all in one
place and easier to find). In a keyframe of your scripts layer that
vertically coincides with your button -- that is, the same frame number as
the frame that contains your button, even though they're on different
layers -- type the following:

yourButtonInstanceName.onRelease = function() {
//
}

So far, you've simply called your button instance by name (by its
instance name) and are assigning a function to its onRelease event handler.
Event handlers ... well, they handle events, such as an onRelease (when the
user clicks, then releases the mouse). How do you know what events your
button can handle? Check out the "Button class" entry in your ActionScript
Language Reference. Classes define objects, and everything in ActionScript
is an object, including MovieClips, TextFields, etc. In your code, you'll
substitute the word yourButtonInstanceName with whatever instance name you
give your button.

Now, the actual code you'll want to invoke is the getURL() function.
Give that a shot in the ActionScript Language Reference, too. You'll see
that it takes at least one parameter, which is usually an http: request.
You might have it open another HTML document that contains your other SWF,
for example.

If you're hoping to actually load another SWF *into* the existing SWF,
you would use something like MovieClip.loadMovie().

yourButtonInstanceName.onRelease = function() {
_root.loadMovie("otherMovie.swf");
}

.... where _root is your main timeline. Doing the above would load the named
external SWF into the _root of the current SWF, which would wipe out
everything but the new SWF. The new SWF will start playing from frame 1
when it loads.

You could, alternatively, load an external SWF into a movie clip. After
all, MovieClip.loadMovie() is a method of the MovieClip class, so it can be
used on any movie clip instance (and, as it happens, on timelines, such as
_root). You would have to have a movie clip -- it could be empty -- on the
Stage with an instance name, such as ... oh ... mcLoader. Whatever you want
to call it.

yourButtonInstanceName.onRelease = function() {
_root.mcLoader.loadMovie("otherMovie.swf");
}

.... in which case the external SWF would *not* wipe out everything, because
it's harnessed into a particluar movie clip instance. You could position
that clip anywhere you like. Experiment with it! :)


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

David Stiller
9/7/2005 4:27:47 PM
[quoted text, click to view]

Glad to help, bro.

[quoted text, click to view]

Heh. It's your spelling of "function".


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Matt Ostil
9/7/2005 6:17:27 PM
Hey everyone.

I just have a quick question.

How exactly do I go about combining two seperate .fla files?

For example , if the user clicks the button "start", how would i then go to
the first frame of another .fla?

Thanks :)

-Matthew Ostil-
Matt Ostil
9/7/2005 7:00:45 PM
Oh ok, that does make sense actaully.

But like I said to the other person yesterday, im not really good at flash and
doing this as a side project hoping to learn more.

So, if your dont' mind dumbing down what you said up there? If you don't have
time, its alright as well.

Heres what i have:

A button called "bt_ForestMap" and what I want to happen is once I click that
it will go to the swf called "Forest.swf"

If you understand and have time, your help will be appreciated :)

Thanks

-Matthew Ostil-
Matt Ostil
9/7/2005 8:24:31 PM
Wow thanks alot :)

*Copies Suggestion into Word Document*

Alright, I did as you suggested ( i think ill attempt to use your first one
though, more appealing)

But as I typed this code in :

bt_forestmap.onRelease = funtion() {
_root.loadMovie("forest.swf");
}


I get this error :

Scene=Scene 1, Layer=Scripts, Frame=10: Line 1: ';' expected
bt_forestmap.onRelease = funtion() {

I know its probably something small and your going to kill me, but I dont'
know whats wrong :(

-Matthew Ostil-

ps, thanks for your time, this REALLY helps :D




Matt Ostil
9/7/2005 8:40:43 PM
Hahaha oh dear.

Its times like these that I regret never looking over my writing *shifty eyes*

On either note it works :)

Thanks for all the help sir, you made a mere 18 year old quite happy :D

Now I know where to turn if and most likely when I need more flash help :P

Many thanks again!

-Matthew Ostil-
David Stiller
9/8/2005 9:14:07 AM
[quoted text, click to view]

Glad to help, Matthew. Flash makes me happy every day. Just keep an
eye out for those small details. The devil is in the details. ;)


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

AddThis Social Bookmark Button