Danz0r
18 posts
|
Okay, so this week I went out and bought myself Beginning Flash Game Programming for Dummies, and have been enjoying it so far.
Anyways, I got to the first ‘practical’ part of the book where you make a simple adventure game.
I’ve made the buttons, and have two keyframes.
The frame labels are ‘here’ and ‘there’.
I have a button (is definatly a button symbol) on the first keyframe, and the code is as follows:
stop();
btnGoThere.onPress = function(){
_root.gotoAndPlay(“there”);
}
On testing, this button DOES work.. and correctly goes to the next ‘state’.
But when I get to the next one, I cannot go back to the previous..
The button is called btnGoHere, and the frame I want to goto is called here.
The code =
btnGoHere.onRelease = function(){
_root.GotoAndPlay(“here”);
}
On testing, I cannot get back to the other frame.. The first button links fine, but then will not let me go back.
I know this is really really basic, but its stressing me out.
I’m in FlashCS3 Professional, using AS2.
Thanks for any help, P.S i’ll send you the FLA if you leave me your email address, if you don’t understand whats wrong either (:
-Dan |
|
|
Danz0r
18 posts
|
(The code is on different lines… just didn’t show properly in the post.) |
|
|
Danz0r
18 posts
|
Actually, I think I found the problem.
The _root. isn’t actually needed.
Maybe it was needed in the version of flash that the book was written using (MX 2004 I think.)
Will the _root. affect anything else?
(Sorry for treble post). |
|
|
DPbrad
520 posts
|
try this, its much easier
1- Make a button called ‘Button’
2- should have 4 available frames, Up Over Down and Pressed (Or In)
3- make an image on frame UP
4- make an image on frame DOWN (F6 it first)
5- goto actions for frame 3
6- type
on(Press){
gotoAndStop("Buttonstate1")
}
then on the first frame, label it as Buttonstate1
then on the 3rd frame, label it as Buttonstate2
Then make a new layer, and put a stop();
code on frames 1 and 3.....
but back to the point. Your code for the second state doesnt stop.....
EG.
You Have <pre>btnGoHere.onRelease = function(){_root.gotoAndPlay("here");}
Should be <pre>stop(); btn GoHere.onRelease = function(){_root.gotoAndPlay("here");} |
|
|
DPbrad
520 posts
|
Actually, I think I found the problem. The _root. isn’t actually needed. Maybe it was needed in the version of flash that the book was written using (MX 2004 I think.)
Will the _root. affect anything else? (Sorry for treble post).
The _root. is only needed if you have gotoAndPlay or gotoAndStop codes in seperate movieclips, which you dont have. But when you get more in-depth of Flash, you will need to start making sure you use _root. on the main timeline or movieclipnamegoeshere. for inside animation or effect inside. |
|
|
Danz0r
18 posts
|
Its odd that removing the _root. made it work though, don’t you think?
I’ll try what you suggested aswell. Thanks :) |
|
|
DPbrad
520 posts
|
hmm…..thats is quite weird. Oh wait, I think I know why that worked. Its because a button automatically has stop functions in it. It still would have worked though. |
|
|
DPbrad
520 posts
|
just for sakes, what flash version you using?
MX 2004
CS3…..? |
|
|
BigCheese
367 posts
|
Hmm…. I noticed that the second gotoAndPlay is capitalized. That might be a typo.
In AS2, the _root. shouldn’t matter. I don’t know about AS3. AS3 might be more strict. |
|
|
Danz0r
18 posts
|
I’m using AS2.. like the book uses.
And I’m using Adobe Flash CS3 Professional.
I’ll have another play later.. I was just interested into why the _root. didn’t let it work.
Though, having said that, i’ve just seen the capital typo, and that may of also stopped it from working.
Thanks for the replies anyway :) |
|
|
DPbrad
520 posts
|
No problem. Just installing Flash CS3 Pro myself, just need to figure out why my serial number isnt working o.O |
|
|
Danz0r
18 posts
|
Just been playing about again in a complete new project..
The _root. seems to be the root of all evil (excuse the pun..).
It stops my buttons from working..
stop();
begingame.onRelease = function(){
}
gotoAndStop("1");
seems to work, whereas with the 3rd line as:
_root.gotoAndStop(“1”);
it doesn’t.
WEIRD. |
|
|
Danz0r
18 posts
|
Btw, whats the forum code for posting code on here? It doesn’t show properly.. |
|
|
BigCheese
367 posts
|
The <...pre> <.../pre> tags, without the dots. |
|
|
Danz0r
18 posts
|
Still havn’t worked out the problem with the roots..
No matter what I use it in, it breaks stuff :P |
|
|
LOL15000
6 posts
|
HELL IS WHERE PEOPLE DIE WHEN THEY DIE IDOIT |
|
|
LOL15000
6 posts
|
Oh sorry i thought the question was what is hell dont look at these two ones
sorry |
|
|
skyboy
185 posts
|
erm… okay then… the problem with your second button was
btnGoHere.onRelease = function(){ _root.GotoAndPlay(“here”); }
the G should be a g in GotoAndPlay, and you should use _root.gotoAndStop("here") instead
(late, yeah yeah… it might help someone else later and since that other guy made those two posts >.>) |
|
|
7o0Ninjas
19 posts
|
Cant you just type this in the actions of a button?
on(release){ //When you release the left mouse button
gotoAndPlay(FRAME); //Play some frame
} //end |