views:

48

answers:

2

Hi, I'm building a very simple questionnaire in flash cs5. My timeline consists of an intro frame, three question frames and a results frame. Each of the question frames allows the users to select 1 of 5 answers choices (buttons) and then proceeds to the next question. I want to capture their button selection, store it in a variable and display it on the results page.

I placed the following actionscript below on each question frame (variable names change accordingly ie secondq, thirdq, a_second, a_third..) to capture the user's anwser. Then in the results frame, I created a text box for each anwser, made it dynamic, and set the variable name (firstq, secondq, thridq) as the value. The variables only appear in the results frame if I select the first button for each question, all other answers are not appearing in the results frame. Any help would be appreciated.

question frames:

var firstq:int = 0;

        a_first.onRelease = function () 

        { 

        firstq = 1;
        gotoAndPlay(30);

        };

        b_first.onRelease = function () 

        { 

        firstq = 2;
        gotoAndPlay(30);

        };



        c_first.onRelease = function () 
        { 
        firstq = 3;
        gotoAndPlay(30);

        } ;


        d_first.onRelease = function () 
        { 
        firstq = 4;
        gotoAndPlay(30);

        } ; 


        e_first.onRelease = function () 
        { 
        firstq = 5;
        gotoAndPlay(30);


        } ; 

results frame

stop();
trace(firstq);
trace(secondq);
trace(thirdq);


firstq = resA.text;
secondq = resB.text;
thirdq = resC.text;
A: 

I've never really added ActionScript to the frame but rather linked AS pages to the whole FLA but I thought I'd chime in and see if I could help. It looks like your initialization of firstq, secondq...lastq is on it's corresponding page. Because of this I think you may be losing its value when you leave the page. Something you can try doing is creating another layer and adding a slide that persists over all of the frames. Add your text fields to this so that they're on all of the frames. On the frames that you don't want them displayed you can just change their visibility. Now, when you need to change their value you can just say myTextField.text = "some text".

Aaron Hathaway
A: 

Following your description, I don't see any reason why it doesn't work. You could start by tracing the results of the different questions in your results frame:

     trace( firstq, secondq , etc... );

then you could also test your TextField instances, in the results frame:

    trace( tfInstance1 , tfInstance1.text , etc... );

if all of the above is working , check if you've correctly embed the fonts in your TextFields. Now if it's all working... maybe a stop(); statement on the last frame...

PatrickS
I placed the following trace code on my results frame, and i see the correct output in my compiler window. I just can't get res1 to show up on the stage/movie when i run it. `stop(); trace(firstq); trace(secondq); trace(thirdq); trace(res1.text);`
gates
I can only get the first answer to appear in the movie.
gates
at least you've narrowed down your problem to a display issue. verify that your TextFields are properly set up.
PatrickS