-
global code problem
I'm doing a key pad to teach text messageing. I was given this code and it works fine until I add more then 4 buttons. Then the count stops working right and I'm not able to add any of the letters after the first one.
I'm assuming it has to do something with the _global code, but I don't know which one to move or replace.
10 buttons on their own layer all on frame 7, main time line.
//On main time line, frame 7
//_root.button1.onEnterFrame = function(){
_root.button1.onRelease = function(){
_global.count = 0;
this.gotoAndStop(this._currentframe +1);
}
//}
In side of button, on Layer 1, frame 1 (I have this on each of the 10 MCbuttons):
_global.count = 0;
this.onEnterFrame = function(){
_global.count++;
trace(_global.count);
}
//layer 2, for letters D (plus three more for the letters E, F, 2):
this.pressIt1.onEnterFrame = function(){
if(_global.count >= 10){
//change your text field - something like
_root.yourTextField = _root.yourTextField + "D";
//frame one - b for frame 2 and c for frame 3
_global.count = 0;
this._parent.gotoAndStop(1);
}
}
-
FK's Geezer Mod
What version of flash are you using?
MX likes _global, F8 likes _root instead.
-
-
FK's Geezer Mod
Try changing your _global to _root. I've had this problem before. Variables are stored in the controller in the flashplayer, and for some reason MX likes _global. Newer versions don't for some reason. Using _root instead usually fixes it.
-
Wow that is weird, with the change its working. So does that mean if I upgrade to 8 I'll have to change it back to _global?
Thank you for the help!
-
FK's Geezer Mod
No, flash 8 likes _root. It's only MX that prefers _global.
And it is weird. It took me weeks to figure out the connection there, cause it's not documented. In fact, you can find very little about using _global at all.
-
I have a book on "flash mx actionscripting advanced training from the source" He has a whole section on global use but he said global needs to be stated on the main time line then it can be called any where in the project....that's why I was wondering if stating a _global call on every button was causing the problem. I just don't know enough about scripting to make changes like that.
-
FK's Geezer Mod
Yes, and he's right. Up to about 4 different globals. After that, it seems to stop reading them, where using _root always seems to work.
-
thanks for the heads up. I'll write that in my book.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|