Changing the code

 
     
 

Back

 

 
     
 

Tidy up the stage so the objects are arranged appropriately and check that the boxes are the right size for the labels.

If you need to change the size of a box, right-click on it and choose scale from the menu. The box will then have handles to drag it bigger or smaller.

You have now done all the hard work. All that remains is to add some extra code to get the activity running.

Test the movie to see how it looks. You should notice that two of the labels behave as expected as they already have the code referring to them.

check box sizes
 

Click on frame 1 of the scripts layer and press F9 to open the actions pane. Check that you have selected Expert View so that you can scroll through the existing code and add things to it.

The code is more or less prepared but needs to be modified to take into account the number of objects in the activity. The code below shows existing instructions in black and additions in blue. Text in green is intended as a helpful instruction, it must not be added to the code.

 

// ** you will edit the code below this point **

// sets up an array for the word destinations (the boxes)
var boxes = new array();
// adds the name of each box symbol to its variable
boxes[1] = box1;
boxes[2] = box2;
boxes[3] = box3; (add a line for each box you have)
// tells flash how many boxes there are
var boxNo = 6; (or however many you have)

//sets up array for the words
var words = new array();
words[1] = word1;
words[2] = word2;
words[3] = word3; (add a line for each text label)
// tells flash how many words there are
var wordNo = 6; (or however many you have)

// sets the reset position of all words to their starting position
word1.starty = word1._y;
word1.startx = word1._x;
word2.starty = word2._y;
word2.startx = word2._x;
word3.starty = word3._y;
word3.startx = word3._x;
(a pair of lines for each text label)

// sets up an array for the correct answers
var answer = new array();
// sets the correct answer for each word
// answer[1] = word1 destination box etc.
answer[1] = 1;
answer[2] = 2;
answer[3] = 3; (a line for each pair - you may have to go back to the stage to work out which box matches with which text label)

// ** you should not change any code below this point **

 

All you have to do now is make all the words draggable. Click on either word1 or word2 and open the actions pane. Copy the code (shown below) and then paste it into the actions pane for each of the other words.

on (press) {
this.startDrag(false);
}

on (release) {
stopDrag();
_root.overBox(this);
}

Test the movie and check if all the objects do what you expect.

 
 
     
 

Back