1
votes

I only have one frame in my flash activity. In the actions layer, it creates a variable called

var placedOnCard1 = '';

There are 2 blue circles, 1 red card and a submit button. When you drag the circle and place it on card 1, placedOnCard1 = 'circleOne'. If you drag the second circle and place it on card 1, placedOnCard1 = 'circleTwo'. This works.

Now, the code for the submit button is

on (release) {
    trace('when clicking submit, card on cardOnAns1 is ' + placedOnCard1);
}

Whenever I drag either of the circles on the card, the variable placedOnCard1 changes correctly but when I click submit, placedOnCard1 goes back to being just '' (an empty string). Why is this and how do I stop this from happening?

Note that in my actions layer, I also tried doing this

trace('placedOnCard1 gets reset');
placedOnCard1 = '';

and it only traced 'placedOnCard1 gets reset' once, it didn't reset the variable after I clicked submit so why does placedOnCard1 become an empty string after I click submit even though I'm not even switching frames? The whole flash activity is just on one frame.

1

1 Answers

1
votes

Seems like it looks for placedOnCard1 in button' inner scope. Try :

on (release) {
    trace('when clicking submit, card on cardOnAns1 is ' + _root.placedOnCard1);
}