Groups | Blog | Home
all groups > macromedia flash sitedesign > july 2007 >

macromedia flash sitedesign : A question I have not been able to find online


David Stiller
7/3/2007 3:11:23 PM
sr817,

[quoted text, click to view]

You bet. The "trick" is to give each of your movie clips an instance
name, then use that instance name in your ActionScript to tell each clip
what to do. Not all, but many objects can be given instance names via the
Property inspector. In your case, you'll select each movie clip on the
Stage by clicking on it once, then looking at the Property inspector while
each is selected.

Under the hood, movie clip symbols are instances of the MovieClip class
(button symbols, in ActionScript 2.0, are instance of the Button class, and
in ActionScript 3.0 are intances of the SimpleButton class). Non-static
text fields are instances of the TextField class, and so on. Classes define
objects, so you can find the functionality that each supports by looking up
the relevant class entry in the ActionScript 2.0 or 3.0 Language Reference
in the Help docs (AS3 is only available since Flash CS3). You'll generally
find three categories: properties (characteristics the object has), methods
(things the object can do), and events (things the object can react to).
For example, you'll find the MovieClip.gotoAndPlay() method under the
Methods heading of the MovieClip class. In actual pratice, you'll invoke
that method against the instance name desired:

myClip.gotoAndPlay(15);

[quoted text, click to view]

That's right -- an that's perfectly fine. ActionScript in keyframes of
the main timeline, where each of these movie clips resides, needn't worry
about the timeline it's in. (When it does, it's invoking MovieClip methods
on the main timeline itself ... it's not immediately obvious, but the main
timeline effectively *is* one big movie clip symbol.)

[quoted text, click to view]

Buttons will need their own instance names. If you have three
buttons -- myBtnA, myBtnB, and myBtnC -- inside a movie clip with the
instance name myClip2, then you would reach the "B" button like so from the
main timeline:

myClip2.myBtnB

.... and you could then invoke Button (or SimpleButton) class members on it.
If you're using ActionScript 2.0 (I'm just guessing), then you might handle
a Button.onRelease event like this:

myClip2.myBtn2.onRelease = function():Void {
// do something here
}

If this "B" button is supposed to send the timeline of myClip1
somewhere, it might look like this (again, all this code is in a keyframe of
the timeline that contains these clips and their nested buttons) ...

myClip2.myBtn2.onRelease = function():Void {
myClip1.gotoAndPlay(33);
}

In the above example, a function is assigned to the Button.onRelease
handler of the myBtn2 instance, which resides inside the myClip2 instance.
The function asks myBtn2 to look for yet another instance named myClip1.
The function will look for this reference inside itself first, won't find
it -- because no variable has been named myClip1 inside itself -- will then
look "up the chain," so to speak, in myClip2 and won't find it, and will
finally look up the chain again to the timeline that contains both myClip2
and myClip1, at which point it will make the connection and tell myClip1
what to do.


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

sr817
7/3/2007 5:55:05 PM
I've been working for a few days on the beginning of a fully-"flashed" website.
This is one of my first real attempts at such a task, but so far, the
animation-side of flash programming has been doable. Easily programming
buttons has not been as easy for me. To simplify my site design, I seperated
the site into 3 "frames" (not actually frames, but objects), three movie clips,
one for the top bar, one for the main content, and a bottom bar for navigation.
My question should be rather easy to answer for any experienced flash user: is
there a way to have a button from one movie clip (say a button from the bottom
navigation bar) perform an action on one of the other movieclips I have
organized in my flash document. I have individually edited each of the frames,
then organized each of them in my actual document window. In very simple
computer terms, once I move them onto the actual document window rather than
editing the actual movie clips in my library, the frame number no longer
corresponds to the actual length of each of the clips (a 200 frame movie clip
appears as a single frame) and button instances do not seem to work together
unless located in the same library clip. All I need to do is have a button
from one library clip (now located in Scene 1 of the actual file) perform an
action on another library clip (also located in Scene 1 of the actual file)
when I click on it. I've been experimenting with actioncript and seem to have
some sense of what to do, but this particular problem has left me stumped. If
anyone understands my issues and has an answer, I would be very grateful.

Thanks
sr817
7/5/2007 3:04:55 PM
AddThis Social Bookmark Button