/* Open a new FLash file (ActionScript 3.0). Select TimeLine --> Top Layer --> Frame 1 Select Window --> Actions (F9) Copy and paste this snippet Observe the stage */ // A very common concern for students is how do I set up my page // countes? Another is how do I do percent? This is a shell that // demonstrates both. // Here we have the counters we'll use to describe progress var pageCount:int = 0; var pageTotal:int = 14; var questionsRight:int = 0; var questionsTotal:int = 4; // Here we set up our page counter var ourProgress_txt:TextField = new TextField(); ourProgress_txt.text = pageCount + " of " + pageTotal; ourProgress_txt.x = 200; ourProgress_txt.y = 300; ourProgress_txt.width = 50; addChild (ourProgress_txt); // Here we set up our percentage correct var ourScore_txt:TextField = new TextField(); ourScore_txt.text = (questionsRight / questionsTotal) + " % correct" ; ourScore_txt.x = 250; ourScore_txt.y = 300; ourScore_txt.width = 70; addChild (ourScore_txt); // Now in the fla, create 14 keyframes. // Insert --> Timeline --> Keyframe // In the frames 2, 3, 5, 6, 8, 9, 11, 12 // Copy and paste the snippet below into the frame (removing comments) // pageCount++; // ourProgress_txt.text = pageCount + " of " + pageTotal; // In the frames 4, 7, 10, 13 // Copy and paste the snippet below into the frame (removing comments) // pageCount++; // questionsRight++; // ourProgress_txt.text = pageCount + " of " + pageTotal; // ourScore_txt.text = (questionsRight / questionsTotal) + " % correct" ; // Do your CNTL ENTER. You should see the progress counter update very quickly. // To stop it so it only runs once go to the last keyframe (should be 15) and add: // stop(); to the very last line of the keyframe (without the comment of course). // Better but we didn't see much updating did we? Why? // // The answer we are looking for is default frame rate. It's set to 24 frames per second // At that rate we burn through all of our frames too quickly to "see" it. // To fix this we have several ways but we'll just slow our frame rate. Select // Modify --> Document. Frame rate is in the lower portion of the panel and probably // reads 24. Click the 24 and set the rate to 1. Now run it. // Better but notice the percent is a bit off. Can can modify // ourScore_txt.text = (questionsRight / questionsTotal) + " % correct" ; // to read instead // ourScore_txt.text = (questionsRight / questionsTotal) *100 + " % correct" ; // Now do a CNTL ENTER. The movie should "walk" through the frames, incrementing // the page counter every frame and the "questions" right every third frame. This // is similar to the way most of you CAN do your movie. You will have to consider //placement of your code to increment on "right" answers for example, but this // is a start.