Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-04-2012, 05:33 PM   #1
THP
Registered User
 
Join Date: Mar 2012
Posts: 19
Default Problem with Buttons

Hello,

I've got another problem that I can't solve on my own and I'd be really glad for some help: In my game project one can enter a map, a seperate scene. Depending on the story progression, there are five different variants of the map, each a single frame.

Now, if I enter the map on the first frame, there is no problem with the single button here. But if I enter the second frame none of the two buttons work (even the one that used to work before). I use the same actionscript for all frames:

ActionScript Code:
outpost_btn.onPress = function(){ gotoAndPlay("outpost",1); } shipwreck_btn.onPress = function(){ gotoAndPlay("shipwreck",1); }

I double-checked the instance names of the buttons and the spelling of the scenes referred to in the code is also correct. Does anybody have an idea what the source of the problem could be? I'm really confused since the code works in the first frame (with the "outpost" scene).

Thanks a lot in advance,
THP
THP is offline  
Old 03-04-2012, 07:18 PM   #2
woestyn
Beginner programmer
 
Join Date: Jan 2012
Location: South Africa
Posts: 31
Default

I've had the same problem with a file which I created with CS3. When I opened the file in CS5 the buttons worked perfectly. I am not sure but I think there is some bug in CS3 concerning using buttons to navigate between scenes.
woestyn is offline  
Old 03-04-2012, 08:53 PM   #3
Prid
Prid - Outing
 
Prid's Avatar
 
Join Date: Oct 2009
Location: Halden, Norway
Posts: 1,191
Send a message via MSN to Prid Send a message via Skype™ to Prid
Default

DO NOT USE SCENES WHEN MAKING GAMES

right now, you are experiencing just another issue of the consequences of using scenes. Resort to Frames instead!
__________________
I have returned, and am now 18
Prid is offline  
Old 03-04-2012, 10:26 PM   #4
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

Don't ever target a scene name in your Flash life again... Only target a labeled frame.
Thus, label the first frame of each different scene , with a unique label such as target_1, target_2... (no number only labels, or at least not starting off with a number, no spaces, no caps and no special character other than the underscore...), and in your actionscript first target the main timeline with _root or _level0, and second that labeled frame...
Something like...

Code:
outpost_btn.onPress = function(){
    gotoAndPlay("target_1"); // or outpost if it's the label you used...
}

shipwreck_btn.onPress = function(){
    gotoAndPlay("target_2"); // or shipwreck if it's the label you used...
}
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline  
Old 03-05-2012, 05:40 PM   #5
THP
Registered User
 
Join Date: Mar 2012
Posts: 19
Default

Thanks for the replies. I tried using labels instead of the scene names but unfortunately it doesn't seem to work with my project.

I must admit that I heard of problems with scenes before. So far, I ignored all the hints telling me to resort to frames instead because I find scenes much more efficient to navigate in. I'll redesign my game into a single scene using frames for different aspects. I hope that will solve this problem.

So again, thanks. I'll surely ask for your help again if I encounter another problem ;-)
THP is offline  
Old 03-05-2012, 09:58 PM   #6
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

Sorry, my bad! I just now noticed that I didn't provide you with the proper code.
When transposing your own code, I forgot to target the main timeline first...

So not this...

Code:
outpost_btn.onPress = function(){
    gotoAndPlay("target_1"); // or outpost if it's the label you used...
}

shipwreck_btn.onPress = function(){
    gotoAndPlay("target_2"); // or shipwreck if it's the label you used...
}
But this should work fine...

Code:
outpost_btn.onPress = function(){
    _level0.gotoAndPlay("target_1"); // or outpost if it's the label you used...
}

shipwreck_btn.onPress = function(){
    _level0.gotoAndPlay("target_2"); // or shipwreck if it's the label you used...
}
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline  
Old 03-08-2012, 06:48 PM   #7
THP
Registered User
 
Join Date: Mar 2012
Posts: 19
Default

Hi tacos,

Thanks for your advice. Unfortunately, it still won't work. Funny thing is that even frames in the timeline can't be reached by using buttons anymore.
THP is offline  
Old 03-09-2012, 05:32 AM   #8
tacos
Grrrrrrrrreat!
 
tacos's Avatar
 
Join Date: Apr 2007
Location: Montréal, Québec
Posts: 5,473
Default

Provide your .fla... Upload it to www.tinyupload.com and provide the link to download it here... Since you don't have enough posts to post links, omit the http://www part when posting it...
__________________
WHO I WAS...
BANDS OF THE 80's
tacos is offline  
Old 03-11-2012, 07:13 PM   #9
THP
Registered User
 
Join Date: Mar 2012
Posts: 19
Default

Hi tacos,

I tried to cut the part from my projects where I have the problem. But it keeps getting messed up. And uploading the whole thing would be a bit too much. Anyway, thanks for your help. I'll try to find a workaround for my button-problem.
THP is offline  
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:11 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.