Skip to main content
Participant
December 7, 2008
Question

creating new buttons on different frame labels

  • December 7, 2008
  • 2 replies
  • 328 views
can someone tell me if im doing something wrong or assigning the as to the wrong frame?

first off i have all my buttons on frame 2. im creating a real estate site and i have to have a couple links like HOME ABOUT BUYING SELLING CONTACT, the thing though is that in the BUYING and SELLING frames i want to add more sections and links but only on these 2 other parts of my site. when i code it and add new buttons to these sections though my movie plays over and over and over non stop. heres my coding...

FRAME 1 preloader

Frame 2 has a frame label of home and all the buttons on a diff layer, and AS3 on a different layer

Frame 3 has a frame label for about section

Frame 4 is my contact for example



so if i create a new button in the about frame label and just add the code to the working as3 code on frame 2 my movie just plays over and over and over again, and all i want it do do is act like the other buttons and go to a different frame label down in the time line. the only way i get it to work is if i have ALL my buttons on frame 2.






frame 1
my preloader

frame2

home_btn.addEventListener(MouseEvent.CLICK, onHome)
function onHome(event.MouseEvent):void
{
gotoAndStop("home");
}


about_btn.addEventListener(MouseEvent.CLICK, onAbout)
function onAbout(event.MouseEvent):void
{
gotoAndStop("about");
}

etc....

etc...

i enter my btn code just like this and the buttons on frame 2 work but any new buttons i try and creat and put into different frames othere then frame label "home" aka frame 2 wont work
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
December 7, 2008
correct.

there are lots of ways around it. but they all require the object to exist when the code executes.

with as3 it's particularly easy to create objects, code for them and then add them to the display list later when needed.
kglad
Community Expert
Community Expert
December 7, 2008
if an object doesn't exist at the time when code executes that tries to reference that object, the code will fail.
Participant
December 7, 2008
ok so your saying if i have my AS on frame 2 with preset buttons and then have a new button on fram 5 for eg , it will fail,


is there any way around it? im trying to creat like a subsection