Friday, May 12, 2006

Adding Background Sound in Flash

1) Select {File - Import - Import to Stage} (see figure 1)


2) Select a sound file.

3) Use your mouse to select a Layer (Note: you can rename the layer "sound" ).

4) In Properties, choose the sound. (see figure 2)

Thursday, May 11, 2006

check for integer input in C++

The following source code could check whether your input is an integer:

#include <iostream>
#include <string>
#include <ctype.h>
#include <stdlib.h>
using namespace std;
int main () {
     int n, ans;
     string instr;
     cout << "Enter an integer: ";
     cin >> instr;
     cout << instr.c_str() << endl;
     const char *c_instr = instr.c_str();
     for( int i=0; i<instr.length(); i++) { // check input
          if( !isnumber( c_instr ) ) {
               cout << "Input error: MUST be a positive integer.\n";
               exit(1);
          }
     }
     n = atoi( c_instr ); // convert to number
     ans = n + 1;
     cout << ans;
     return 0;
}