This is probably an easy question. Ok say you have a text file that contains simply this:
comment1=0
Now in Flash, at the click of a button, you want to store inside a variable, the number contained inside the text file but added by one. So in this case, it would store instead of a zero, a one.
So when you click the button, it would be something like:
Hi Osteel. I'm not sure if I am having a hard time understanding what you're saying or if you really do have it reversed. But here is what I would do.I normally make Movie clips into buttons but I will do it both ways since I see a button handler.
With a Movie clip doubling as a button
//GIVE THE BUTTON AN INSTANCE NAME OF myText
//GIVE THE DYNAMIC TEXT FIELD THE VARIABLE comment1
var comment1:Number = 0;
_root.myText.onPress = function(){
_root.comment1++;
}
With a Button Instance
//GIVE THE DYNAMIC TEXT FIELD THE VARIABLE comment1
//ON THE MAIN TIMELINE
var comment1:Number = 0;
//ON THE BUTTON ITSELF
on (Release){
_root.comment1++;
}
With that you should be set. I am not really familiar with your coding though. have you been in actionscript since the beggining??
I know how to increment values in Flash, Ive been using Flash for about two years just learning things as I go.
No, the problem Im facing is grabbing a variable from the text file, and then incrementing that value by one inside a variable contained in flash. I thought I knew how, but it seems its not working
Oh well, its more of a curiousity then a problem I suppose.
Strange. I made a file with a movieclip as button and used that script, which is shown. The trace was 01 without using the datatyping and 1 with datatyping. What is your script and what is your text file? Are you publishing as Flash 8?
- The right of the People to create Flash movies shall not be infringed. -
how do i make the following code work when I press a button, right now it is set start on load. another thing is for some reason I can't get it to scroll like I have my other text boxes.
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
myStyle.load("sample.css");
my_txt.styleSheet = myStyle;
I tested in a browser with settings access network only and I get NaN. Go to publish - settings and change to access local files only, then it should work (I giuess).
Last edited by cancerinform; 04-05-2006 at 11:07 AM.
- The right of the People to create Flash movies shall not be infringed. -
This is strange. When I publish using Flash 8 it actually always works, no matter what is the setting. Only in browsers I found out you need to change settings. Can you post your fla.
- The right of the People to create Flash movies shall not be infringed. -