Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: As Q: Problem With Button Inside Mc

(99 views • 7 replies)

This topic is 1 page long.

<< < > >>
Questioning

Greensinge

Reply To Post Reply & Quote

Posted at: 5/12/08 03:51 PM

Greensinge LIGHT LEVEL 11

Sign-Up: 04/27/03

Posts: 481

Hey,

I'm having a problem which should be fairly easy to explain if you have some time to help a newbie! (again, for some of you)... :P

Here is the beta of the sim game I'm currently working on (my first ever game, I might add!)

http://spamtheweb.com/ul/upload/120508/7 4957_simgame.php

I have a Movie Clip with an instance name of "bg". Inside it are 3 keyframes (each with a stop action), and each keyframe has a different background for each of the different rooms (living room, bedoom, kitchen). On each keyframe there are buttons which either move the player to another room, or modify a variable's value (such as 'Eat', or 'Watch T.V').

When I run the .swf, I can click the buttons that are within the Movie Clip, and they affect the stats, just as I had planned. When I click the button to leave the living room and enter the kitchen (which is also within the MC) it works fine, and the MC current frame changes from 1 to 2. Perfect!

But this is where my problem begins :(

Everything in this room is exactly the same, except for the appearance and buttons being different, but I'm talking about how the AS should function. The buttons in this room, however, do not work!

Here is the code for the button on frame(1) inside the background MC which moves the player into the kitchen:

_root.bg.buttonKitchen.onPress = function() {
	_root.bg.gotoAndStop(2);
}

And here is the code for the button on frame(2) of the bg MC, which SHOULD move the player back into the living room. But this does not work! :(

_root.bg.buttonLiving.onPress = function() {
	_root.bg.gotoAndStop(1);
}

This problem is the same for the other buttons on frame(2).

I know this is probably something really simple that I'm just not noticing o haven't learnt yet, but I've looked through AS: Main unsuccessfuly, and I'm not sure if there is something you have to do or not (code to write) that specifies which frame within the MC the buttons are actually located on.

Is this the case? Could somebody please explain to me what I am supposed to be writing to do this?

Thanks a lot guys, most of you have been a real help so far with my other problems, and it feels like my game is really coming along great :)

I look forward to reading somebody's response! :)

GS


Winking

Greensinge

Reply To Post Reply & Quote

Posted at: 5/12/08 06:22 PM

Greensinge LIGHT LEVEL 11

Sign-Up: 04/27/03

Posts: 481

*BUMP*

I hate bumping my own threads, so I'm sorry, but I have to for this one, because it's irritating me how something which seems so easy is kicking my arse.

I've looked up _currentframe and onEnterFrame and onLoad and stuff, and maybe I'm missing or not getting something, but I've been trying for a couple of hours now and I just can't seem to figure out the problem.

Anyone able to help? Thanks a lot if you can! :)


Crying

Greensinge

Reply To Post Reply & Quote

Posted at: 5/13/08 11:15 AM

Greensinge LIGHT LEVEL 11

Sign-Up: 04/27/03

Posts: 481

Ok I'm very sorry having to post here again, but this is insane. Why can't I figure this out?? :(

I've simplified the problem even more in a further attempt to work this out myself, and tried to do the exact same thing from scratch with a blank .fla file. (I would really appreciate it if somebody could please take a look at it and see what they think I'm doing wrong!)

http://spamtheweb.com/ul/upload/130508/5 7834_fromscratch.fla (it's flash 8)

It's even more annoying that the problem still occurs when Movie Clips are not even involved anymore!

It's almost as if the main AS code I've written doesn't apply anymore as soon as the frame changes. So what on Earth is going on? This is really started to bother me now, because all of the other problems I've had were resolved really easily up till now! Though I don't resent the learning process, I wish I could find something to help me get this specific problem! :(

I know some of you will think I'm stupid or lazy or whatever, but I've looked in so many places for answer and found none, so it's driving me nuts that I can't just figure this out.

Please help! :( I know that as soon as this problem is solved I can move on and *possibly* finish the rest of the game without any more help!


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 5/13/08 11:34 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,588

Since AS doesn't report errors like a normal language you'll encounter a lot of that shit as you do more complicated things.

Use the 'trace' function to check if the movieclip you're assigned to exists and whether the functions are getting called at all etc.

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


Questioning

Greensinge

Reply To Post Reply & Quote

Posted at: 5/13/08 02:45 PM

Greensinge LIGHT LEVEL 11

Sign-Up: 04/27/03

Posts: 481

Ok thanks for the advice Gust. I didn't think of using trace to see if the buttons were doing anything at all, but I tried with this:

buttonNext.onPress = function(){
	gotoAndStop(2);
	trace ("Next Button Works");
};
buttonLast.onPress = function(){
	gotoAndStop(1);
	trace ("Last Button Works");
};

The first button shows the trace text in the output window, but the second button doesn't show anything. Not sure if that's what you meant I should do or not. With what I've done above, I tried it without using a Movie Clip and instead just using two keyframes on the main timeline. But it still doesn't work. Is there a way to specify which frame the button is on, or should it not matter?


None

PBM

Reply To Post Reply & Quote

Posted at: 5/13/08 03:48 PM

PBM NEUTRAL LEVEL 20

Sign-Up: 03/24/00

Posts: 611

Greensinge,
Do you have messenger? If so, hit me up at pbm_mc@hotmail.com and I may be able to help.
Im intermediate at AS right now, but im always looking for things to challenge me. Sim games are new to me as well, but I have been wanting to do one so maybe we can help each other.


None

PBM

Reply To Post Reply & Quote

Posted at: 5/14/08 03:58 PM

PBM NEUTRAL LEVEL 20

Sign-Up: 03/24/00

Posts: 611

Greensinge,
Never heard back from you. Were you able to fix the problem?


Happy

Greensinge

Reply To Post Reply & Quote

Posted at: 5/14/08 04:10 PM

Greensinge LIGHT LEVEL 11

Sign-Up: 04/27/03

Posts: 481

Hey, sorry I didn't post back until now. I didn't solve the problem yet as such, no, but I did find a way around it so I've kind of done it another way until I figure it out properly.

I'll add you anyway if I can, it would be good to have someone with a mutual interest in improving AS skills.


All times are Eastern Daylight Time (GMT -4) | Current Time: 12:48 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!