Hi there.
I'm very new to Flash, but I have been learning loads and getting some good results so far. Browsing these forums has been a massive help. However today I have hit a problem in what should be almost the simplest line of code I know how to write (variable = x), and could do with some advice.
I have a simple program containing a button which will change a variable when pressed. There is also a text-box that will output that variable. However when I press the button, the variable will change, but then immediately revert to it's previous value.
Code:
class Hero extends MovieClip
{
var mmoloaded = "A"
function onLoad()
{
_root.loadButton.onPress = function()
{
mmoloaded = "B"
_root.mmoloadedText.text = mmoloaded
}
}
function onEnterFrame()
{
_root.mmoloadedText.text = mmoloaded
}
}
The effect is that when I press the button, it will change to "B" for a single frame, then back to "A".
I am writing all my code from within my 'Hero', and if I make the hero itself a button with the instance name 'heroButton' and put the code in there, then the code seems to work as intended. So is it something with the button just not being able to access the variables defined in the Hero class, despite being written inside the Hero class? I'm very confused!
Any and all advice is appreciated.
PS. I am using FLash CS3 and ActionScript 2.0