Skip to main content
Participant
September 30, 2008
Question

Links - basic question

  • September 30, 2008
  • 1 reply
  • 418 views
Flash newbie quesiton - please bear with.

A simple Flash intro, with 3 text buttons appearing toward the end of the movie that should allow navigation to other pages in the site.

I'm not sure where to place the actionscript for the buttons... do I select the layer that contains each button, then click the keyframe where the button first appears (buttons do not appear until frame 250). I've also read that a separate layer for actionscript should be created, and all scripts placed there.

Here is the basic script I'm using:

enter_btn.addEventListener(MouseEvent.CLICK, enterbuttonClickHandler);
function enterbuttonClickHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(" http://www.danceartscentreatl.com/main.htm"));
}
This topic has been closed for replies.

1 reply

Inspiring
September 30, 2008
JillTW,

> Flash newbie quesiton - please bear with.

This is the place for it. :)

> A simple Flash intro, with 3 text buttons appearing toward
> the end of the movie that should allow navigation to other
> pages in the site.

I'm with ya.

> I'm not sure where to place the actionscript for the buttons...

Think of the timeline in terms of a grid. In this analogy, frames are
your vertical columns and layers are your horizontal rows. Your buttons
appear on frame 250, so imagine a column going up and down in frame 250.
Your ActionScript needs to appear along this column somewhere. It doesn't
matter what "row" (layer) its in, so long as the code the buttons appear in
the same "column".

If you put your code in frame 1, for example, Flash will look for a
button with the instance name enter_btn in that "column," but won't find it.
Conversely, if your buttons appeared in frame 1, and ended in frame 100,
then stopped ... and your code appeared in frame 250, it still wouldn't find
the button reference.

> I've also read that a separate layer for actionscript should be
> created, and all scripts placed there.

Technically speaking, it makes no difference which layers hold your code
... but from a practical standpoint, it makes a lot of sense to put all your
code in a dedicated layer named "scripts", or "actions", or some other name
that fits. That way you'll quickly be able to find it, instead of having to
hunt and peck.

> Here is the basic script I'm using:
>
> enter_btn.addEventListener(MouseEvent.CLICK, enterbuttonClickHandler);
> function enterbuttonClickHandler(event:MouseEvent):void {
> navigateToURL(new
> URLRequest(" http://www.danceartscentreatl.com/main.htm"));
> }

That covers a button symbol currently on the Stage or pasteboard whose
instance name is enter_btn. Note: instance names must be unique per
*intance* of a symbol. You can create a single button symbol, with whatever
Library name makes sense, and then drag numerous copies of it to the Stage.
To speak to each instance separately, each instance needs its own instance
name (assigned in the Property inspector).

> enter_btn.addEventListener(MouseEvent.CLICK, buttonClickHandler);
> function buttonClickHandler(event:MouseEvent):void {
> navigateToURL(new URLRequest(" http://www.danceartscentreatl.com"));
> }

This second event handler, assuming it also exists on frame 250 with
your other buttons, will fail because it's also being assigned to enter_btn.
That might have been a typo, I realize, but just to be clear, make sure each
button has its own instance name.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


JillTWAuthor
Participant
September 30, 2008
Thanks for replying, David.
I've gone through your reply, checked and re-checked my script and its positioning in the timeline, checked the button instance names, and the silly thing still doesn't work.

I've got all 3 links going to the same place for now... they will eventually go to separate URLs. There are 3 layers for the buttons, each begins in frame 152 with a keyframe; I have an actions layer with a keyframe in frame 152 that contains the script. The button instance names are details_btn, tour_btn and enter_btn.

Any advice of where to look?

Here is the code for all the buttons: