[Tools][Expand/Collapse All]Note that automatic extraction of ActionScript 3 is still pretty much unsupported by swfchan. AS1/AS2 works okay most of the time.Instance of Symbol 29 MovieClip in Frame 1 (273 B)
onClipEvent (load) {
xin_motion_val = "Toward";
xin_alphatype_val = "No";
xout_motion_val = "None";
xout_alphatype_val = "No";
perc_req_val = 100;
show_perc_val = "Yes";
slow_factor_val = 0.2;
init_action_val = "_root.stop();";
play_action_val = "_root.play();";
}
Frame 2 (8 B)
stop();
Frame 3 (8 B)
stop();
Instance of Symbol 81 MovieClip in Frame 3 (1.47 KiB) ●
onClipEvent (load) {
show_unfound_val = "True";
special_sound_probability_val = 0.25;
incorrect_points_val = -5;
correct_points_val = 20;
game_over_circle_color_rgb = 16711680 /* 0xFF0000 */;
game_over_circle_color_r = 255;
game_over_circle_color_g = 0;
game_over_circle_color_b = 0;
game_over_circle_color_a = 100;
drag_circle_color_rgb = 0;
drag_circle_color_r = 0;
drag_circle_color_g = 0;
drag_circle_color_b = 0;
drag_circle_color_a = 100;
word_selection_type_val = "Circled";
words_per_puzzle_val = 15;
grid_columns_val = 20;
grid_rows_val = 20;
database_file_val = "funnies_wordsearch1.txt";
time_limit_val = 300000 /* 0x0493E0 */;
possible_word_directions_label = "Top Left to Bottom Right|Top Right to Bottom Left|Bottom Left to Top Right|Bottom Right to Top Left|Top to Bottom|Bottom to Top|Left to Right|Right to Left";
possible_word_directions_load_type = "Load URL|Load URL|Load URL|Load URL|Load URL|Load URL|Load URL|Load URL";
possible_word_directions_load_url = "http://|http://|http://|http://|http://|http://|http://|http://";
possible_word_directions_load_target = "_blank|_blank|_blank|_blank|_blank|_blank|_blank|_blank";
possible_word_directions_swf_type = "Level|Level|Level|Level|Level|Level|Level|Level";
possible_word_directions_swf_level = "1|1|1|1|1|1|1|1";
possible_word_directions_swf_mc = "_root.content|_root.content|_root.content|_root.content|_root.content|_root.content|_root.content|_root.content";
possible_word_directions_simple = "|||||||";
}
Frame 4 (8 B)
stop();
Frame 5 (8 B)
stop();
Symbol 5 MovieClip [circle_selection] Frame 1 (393 B)
var x1 = from_mc._x;
var y1 = from_mc._y;
var x2 = to_mc._x;
var y2 = to_mc._y;
this._x = x1;
this._y = y1;
end._x = x2 - x1;
end._y = y2 - y1;
middle._rotation = 0;
middle._width = Math.sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
angle = (Math.atan2(y2 - y1, x2 - x1) * 180) / Math.PI;
start._rotation = angle;
middle._rotation = angle;
end._rotation = angle + 180;
Symbol 10 MovieClip [letter_textfield] Frame 1 (8 B)
stop();
Symbol 14 MovieClip [word_bank_textfield] Frame 1 (8 B)
stop();
Symbol 29 MovieClip Frame 1 (8 B)
stop();
Instance of Symbol 28 MovieClip "swfloader" in Symbol 29 MovieClip Frame 1 (6.97 KiB) ● ●
onClipEvent (load) {
function strip_spaces(str) {
var _str = new String("");
var j = 0;
while (j < str.length) {
if ((str.charAt(j) != " ") && (str.charAt(j) != ";")) {
_str = _str + str.charAt(j);
}
j++;
}
return(_str);
}
function simple_script(action, timeline) {
action = strip_spaces(action);
if ((0 < action.length) && ((action.indexOf(")") != -1) && (action.indexOf("(") != -1))) {
var sections = action.split(".");
var timeline_action = sections.pop();
var first_paren = timeline_action.indexOf("(");
var second_paren = timeline_action.indexOf(")");
var timeline_function = timeline_action.substr(0, first_paren);
var function_parameter = timeline_action.substr(first_paren + 1, second_paren - (first_paren + 1));
var timeline_reference = timeline;
var j = 0;
while (j < sections.length) {
timeline_reference = timeline_reference[sections[j]];
j++;
}
if (function_parameter.indexOf("\"") != -1) {
function_parameter = function_parameter.substr(1, function_parameter.length - 2);
}
timeline_reference[timeline_function](function_parameter);
}
}
function execute_action() {
unloaded = true;
_parent._visible = false;
simple_script(_parent.play_action_val, _parent);
}
_parent.anim.gotoAndStop(1);
simple_script(_parent.init_action_val, _parent);
var done = false;
var unloaded = false;
var orig_x = _parent._x;
var orig_y = _parent._y;
var dist_x = (_parent._x + ((_parent._width * 2) / 3));
var dist_y = (_parent._y + ((_parent._height * 2) / 3));
var orig_a = _parent._alpha;
var accel_jump = 0.75;
var slow_factor = _parent.slow_factor_val;
var speed_factor = (1 + (slow_factor / (1 - slow_factor)));
var ready = false;
var perc_fadeout = 0;
_parent.perc._x = _parent.anim._x - (_parent.perc._width / 2);
_parent.perc._y = _parent.anim._y - (_parent.perc._height / 2);
if (slow_factor < 1) {
var _local1 = "Up";
switch (_parent.xin_motion_val) {
case _local1 :
_parent._y = orig_y + (dist_y * 2);
break;
case "Down" :
_parent._y = orig_y - (dist_y * 2);
break;
case "Left" :
_parent._x = orig_x + (dist_x * 2);
break;
case "Right" :
_parent._x = orig_x - (dist_x * 2);
break;
case "Toward" :
_parent._xscale = (_parent._yscale = 1);
break;
case "None" :
_parent._alpha = 0;
}
} else {
ready = true;
}
}
onClipEvent (enterFrame) {
if (unloaded) {
return(undefined);
}
if (!ready) {
var _local1 = "Toward";
switch (_parent.xin_motion_val) {
case _local1 :
_parent._xscale = _parent._xscale + ((100 - _parent._xscale) * slow_factor);
_parent._yscale = _parent._xscale;
if (_parent.xin_alphatype_val == "Yes") {
_parent._alpha = Math.round((orig_a / 100) * Math.max(0, Math.min(_parent._xscale, 100)));
}
if (Math.abs(100 - _parent._xscale) < 0.5) {
_parent._xscale = (_parent._yscale = 100);
_parent._alpha = orig_a;
ready = true;
}
break;
default :
_parent._x = _parent._x + ((orig_x - _parent._x) * slow_factor);
_parent._y = _parent._y + ((orig_y - _parent._y) * slow_factor);
if (_parent.xin_alphatype_val == "Yes") {
if (_parent.xin_motion_val == "None") {
_parent._alpha = _parent._alpha + ((orig_a - _parent._alpha) * slow_factor);
} else if (Math.abs(orig_y - _parent._y) < Math.abs(orig_x - _parent._x)) {
_parent._alpha = 100 - Math.round(((orig_a / 100) * (Math.min(dist_x, Math.abs(_parent._x - orig_x)) / dist_x)) * 100);
} else {
_parent._alpha = 100 - Math.round(((orig_a / 100) * (Math.min(dist_y, Math.abs(_parent._y - orig_y)) / dist_y)) * 100);
}
}
if (!(((_parent.xin_motion_val == "None") && (1 >= Math.abs(_parent._alpha - orig_a))) || (((_parent.xin_motion_val != "None") && (Math.abs(_parent._y - orig_y) < 0.5)) && (Math.abs(_parent._x - orig_x) < 0.5)))) {
break;
}
_parent._x = orig_x;
_parent._y = orig_y;
_parent._alpha = orig_a;
ready = true;
}
} else if (!done) {
var rl = _root.getBytesLoaded();
var rt = (_root.getBytesTotal() * (_parent.perc_req_val / 100));
if ((10 < rl) && (10 < rt)) {
rl = Math.min(rl, rt);
var new_frame = (_parent.anim._currentframe + Math.ceil(((_parent.anim._totalframes * (rl / rt)) - _parent.anim._currentframe) / 4));
new_frame = Math.max(1, new_frame);
if (_parent.show_perc_val == "Yes") {
_parent.perc.text = Math.round(((new_frame - 1) / (_parent.anim._totalframes - 1)) * 100) + " %";
}
if (new_frame != _parent.anim._currentframe) {
_parent.anim.gotoAndStop(new_frame);
}
if ((_parent.anim._totalframes == _parent.anim._currentframe) && (rl >= rt)) {
done = true;
}
}
} else if (slow_factor < 1) {
var _local1 = "Down";
switch (_parent.xout_motion_val) {
case _local1 :
if (orig_y >= _parent._y) {
_parent._y = orig_y + accel_jump;
}
_parent._y = orig_y + (Math.abs(_parent._y - orig_y) * speed_factor);
perc_fadeout = Math.round((Math.min(dist_y, Math.abs(_parent._y - orig_y)) / dist_y) * 100);
if ((orig_y + (dist_y * 2)) < _parent._y) {
execute_action();
}
break;
case "Up" :
if (_parent._y >= orig_y) {
_parent._y = orig_y - accel_jump;
}
_parent._y = orig_y - (Math.abs(_parent._y - orig_y) * speed_factor);
perc_fadeout = Math.round((Math.min(dist_y, Math.abs(_parent._y - orig_y)) / dist_y) * 100);
if (_parent._y < (orig_y - (dist_y * 2))) {
execute_action();
}
break;
case "Right" :
if (orig_x >= _parent._x) {
_parent._x = orig_x + accel_jump;
}
_parent._x = orig_x + (Math.abs(_parent._x - orig_x) * speed_factor);
perc_fadeout = Math.round((Math.min(dist_x, Math.abs(_parent._x - orig_x)) / dist_x) * 100);
if ((orig_x + (dist_x * 2)) < _parent._x) {
execute_action();
}
break;
case "Left" :
if (_parent._x >= orig_x) {
_parent._x = orig_x - accel_jump;
}
_parent._x = orig_x - (Math.abs(_parent._x - orig_x) * speed_factor);
perc_fadeout = Math.round((Math.min(dist_x, Math.abs(_parent._x - orig_x)) / dist_x) * 100);
if (_parent._x < (orig_x - (dist_x * 2))) {
execute_action();
}
break;
case "Away" :
if ((_parent._xscale >= 100) || (_parent._yscale >= 100)) {
_parent._xscale = (_parent._yscale = 100 - accel_jump);
}
_parent._xscale = (_parent._yscale = Math.max(0.5, 100 - ((100 - _parent._yscale) * speed_factor)));
perc_fadeout = 100 - Math.round(Math.max(0, Math.min(_parent._xscale, 100)));
if (_parent._xscale < 1) {
execute_action();
}
break;
default :
perc_fadeout = perc_fadeout + ((100 - perc_fadeout) * slow_factor);
if (1 < Math.abs(perc_fadeout - 100)) {
break;
}
execute_action();
}
_local1 = "Yes";
if (!((_parent.xout_alphatype_val) === (_local1))) {
} else {
_parent._alpha = (orig_a / 100) * (100 - perc_fadeout);
}
} else {
execute_action();
}
}
Symbol 43 Button (30 B)
on (release) {
this.play();
}
Symbol 56 MovieClip Frame 1 (8 B)
stop();
Symbol 58 MovieClip Frame 1 (8 B)
stop();
Symbol 60 MovieClip Frame 1 (8 B)
stop();
Symbol 62 MovieClip Frame 1 (8 B)
stop();
Symbol 69 Button (53 B)
on (press) {
_root.gotoAndStop("Starting Screen");
}
Symbol 70 MovieClip Frame 1 (8 B)
stop();
Symbol 79 Button (53 B)
on (press) {
_root.gotoAndStop("Starting Screen");
}
Symbol 81 MovieClip Frame 1 (19.03 KiB) ● ● ●
Math.randi = function (a, b) {
return(Math.floor(Math.random() * (b - a)) + Math.floor(a));
};
Math.sign = function (val) {
return(((val == 0) ? 0 : (val / Math.abs(val))));
};
Array.prototype.swap = function (a, b) {
var temp = this[a];
this[a] = this[b];
this[b] = temp;
};
Array.prototype.shuffle = function () {
var j = 0;
while (j < this.length) {
this.swap(j, Math.randi(0, this.length));
j++;
}
};
Array.prototype.random_subset = function (n) {
var subset = new Array();
var indices = Array.getIndices(0, this.length - 1);
indices.shuffle();
var j = 0;
while (j < n) {
subset[j] = this[indices[j]];
j++;
}
return(subset);
};
Array.getIndices = function (a, b) {
var _array = new Array();
var j = a;
while (b >= j) {
_array[j - a] = j;
j++;
}
return(_array);
};
Array.get_letter_grid = function (m, n) {
var _array = new Array();
var j = 0;
while (j < m) {
_array[j] = new Array();
var k = 0;
while (k < n) {
_array[j][k] = String.fromCharCode(Math.randi(65, 91));
k++;
}
j++;
}
return(_array);
};
Array.prototype.sortOn = function (p) {
Array.$sortprop = p;
var sortfunc = function (a, b) {
var p = Array.$sortprop;
return(a[p] < b[p]);
};
this.sort(sortfunc);
delete Array.$sortprop;
};
Array.prototype.return_copy = function () {
var _array = new Array();
var j = 0;
while (j < this.length) {
_array[j] = this[j];
j++;
}
return(_array);
};
String.prototype.return_reverse = function () {
var _str = "";
var j = (this.length - 1);
while (j >= 0) {
_str = _str + this.charAt(j);
j--;
}
return(_str);
};
Array.prototype.hasElement = function (e) {
var j = 0;
while (j < this.length) {
if (this[j] == e) {
}
j++;
}
return(false);
};
Array.prototype.intersection = function (A) {
var _array = new Array();
var j = 0;
while (j < this.length) {
if (a.hasElement(this[a])) {
_array.push(this[j]);
}
j++;
}
return(_array);
};
String.prototype.searchReplace = function (s, r) {
return(this.split(s).join(r));
};
WordSearch = function () {
this.load_game_data();
};
WordSearch.prototype.time_limit = ((Number(time_limit_val) == 0) ? Number.MAX_VALUE : (Number(time_limit_val)));
WordSearch.prototype.database_file = database_file_val;
WordSearch.prototype.grid_rows = Number(grid_rows_val);
WordSearch.prototype.grid_columns = Number(grid_columns_val);
WordSearch.prototype.words_per_puzzle = Number(words_per_puzzle_val);
WordSearch.prototype.word_selection_type = word_selection_type_val;
WordSearch.prototype.drag_circle_color = drag_circle_color_rgb;
WordSearch.prototype.game_over_circle_color = game_over_circle_color_rgb;
WordSearch.prototype.correct_points = Number(correct_points_val);
WordSearch.prototype.incorrect_points = Number(incorrect_points_val);
WordSearch.prototype.special_sound_probability = Number(special_sound_probability_val);
WordSearch.prototype.show_unfound = show_unfound_val;
WordSearch.prototype.timeline = this;
WordSearch.prototype.load_game_data = function () {
this.timeline.controller.loadVariables(this.database_file);
};
WordSearch.prototype.initialize = function () {
this.initialize_variables();
this.initialize_graphics();
};
WordSearch.prototype.initialize_variables = function () {
this.mouse_down = false;
this.depth = 0;
this.score = 0;
this.start_time = getTimer();
this.answer_key = new Array();
this.letter_grid_width = this.timeline.grid_area._width;
this.letter_grid_height = this.timeline.grid_area._height;
this.word_bank = this.words.random_subset(this.words_per_puzzle);
this.word_bank.sortOn("length");
this.create_letter_grid();
this.embed_word_bank();
};
WordSearch.prototype.create_letter_grid = function () {
var initial_grid = Array.get_letter_grid(this.grid_rows, this.grid_columns);
this.letter_grid = new Array();
var j = 0;
while (j < this.grid_rows) {
this.letter_grid[j] = new Array();
var k = 0;
while (k < this.grid_columns) {
this.letter_grid[j][k] = new Object();
this.letter_grid[j][k].letter = initial_grid[j][k];
this.letter_grid[j][k].word_bank_letter = false;
this.letter_grid[j][k].letter_found = false;
this.letter_grid[j][k].drag_selected = false;
k++;
}
j++;
}
};
WordSearch.prototype.embed_word_bank = function () {
var temp_bank = this.word_bank.return_copy();
var j = 0;
while (j < temp_bank.length) {
temp_bank[j] = temp_bank[j].searchReplace(" ", "");
j++;
}
var j = 0;
while (j < temp_bank.length) {
var index_j = Math.randi(0, this.grid_rows);
var index_k = Math.randi(0, this.grid_columns);
var possible_directions = this.get_possible_word_directions(temp_bank[j].length, index_j, index_k);
var bool = this.embed_word(temp_bank[j], index_j, index_k, possible_directions);
if (!bool) {
temp_bank.push(temp_bank[j]);
}
j++;
}
};
WordSearch.prototype.get_possible_word_directions = function (word_length, index_j, index_k) {
var directions = new Array();
if (((index_j + word_length) < this.grid_rows) && ((index_k + word_length) < this.grid_columns)) {
directions.push("Top Left to Bottom Right");
}
if (((index_j + word_length) < this.grid_rows) && ((index_k - word_length) >= 0)) {
directions.push("Top Right to Bottom Left");
}
if (((index_j - word_length) >= 0) && ((index_k + word_length) < this.grid_columns)) {
directions.push("Bottom Left to Top Right");
}
if (((index_j - word_length) >= 0) && ((index_k - word_length) >= 0)) {
directions.push("Bottom Right to Top Left");
}
if ((index_j + word_length) < this.grid_rows) {
directions.push("Top to Bottom");
}
if ((index_j - word_length) >= 0) {
directions.push("Bottom to Top");
}
if ((index_k + word_length) < this.grid_columns) {
directions.push("Left to Right");
}
if ((index_k - word_length) >= 0) {
directions.push("Right to Left");
}
return(directions);
};
WordSearch.prototype.embed_word = function (word, index_j, index_k, possible_directions) {
possible_directions.shuffle();
if (this.answer_key.length < (0.2 * this.word_bank.length)) {
possible_directions.sortOn("length");
}
var j = 0;
while (j < possible_directions.length) {
var increments = this.calculate_slope_increments(possible_directions[j]);
if (!this.word_overlaps(word, index_j, index_k, increments)) {
this.put_letters_in(word, index_j, index_k, increments, possible_directions[j]);
return(true);
}
j++;
}
return(false);
};
WordSearch.prototype.put_letters_in = function (word, index_j, index_k, increments, direction) {
var n = 0;
while (n < word.length) {
var j = (index_j + (n * increments.j));
var k = (index_k + (n * increments.k));
var letter = this.letter_grid[j][k];
letter.word_bank_letter = true;
letter.letter = word.charAt(n);
n++;
}
var answer = new Object();
answer.start = {j:index_j, k:index_k};
answer.length = word.length;
answer.increments = increments;
answer.direction = direction;
answer.word = word;
this.answer_key.push(answer);
};
WordSearch.prototype.word_overlaps = function (word, index_j, index_k, increments) {
var n = 0;
while (n < word.length) {
var j = (index_j + (n * increments.j));
var k = (index_k + (n * increments.k));
var letter = this.letter_grid[j][k];
if (letter.word_bank_letter && (letter.letter != word.charAt(n))) {
return(true);
}
n++;
}
return(false);
};
WordSearch.prototype.calculate_slope_increments = function (direction) {
if (direction == "Top Left to Bottom Right") {
return({j:1, k:1});
}
if (direction == "Bottom Left to Top Right") {
return({j:-1, k:1});
}
if (direction == "Top Right to Bottom Left") {
return({j:1, k:-1});
}
if (direction == "Bottom Right to Top Left") {
return({j:-1, k:-1});
}
if (direction == "Left to Right") {
return({j:0, k:1});
}
if (direction == "Right to Left") {
return({j:0, k:-1});
}
if (direction == "Top to Bottom") {
return({j:1, k:0});
}
if (direction == "Bottom to Top") {
return({j:-1, k:0});
}
};
WordSearch.prototype.initialize_graphics = function () {
this.create_letter_grid_graphics();
this.render_letter_grid();
this.render_word_bank();
};
WordSearch.prototype.create_letter_grid_graphics = function () {
this.letter_spacing_x = this.timeline.grid_area._width / (this.grid_columns + 1);
this.letter_spacing_y = this.timeline.grid_area._height / (this.grid_rows + 1);
var j = 0;
while (j < this.grid_rows) {
var k = 0;
while (k < this.grid_columns) {
this.timeline.attachMovie("letter_textfield", (("letter_" + j) + "_") + k, this.depth++);
var _mc = this.timeline[(("letter_" + j) + "_") + k];
_mc._x = this.timeline.grid_area._x + (this.letter_spacing_x * (k + 1));
_mc._y = this.timeline.grid_area._y + (this.letter_spacing_y * (j + 1));
_mc.field = this.letter_grid[j][k].letter;
_mc.index_j = j;
_mc.index_k = k;
k++;
}
j++;
}
};
WordSearch.prototype.render_letter_grid = function () {
var j = 0;
while (j < this.grid_rows) {
var k = 0;
while (k < this.grid_columns) {
var _mc = this.timeline[(("letter_" + j) + "_") + k];
_mc.field = this.letter_grid[j][k].letter;
if (this.letter_grid[j][k].drag_selected) {
_mc.gotoAndStop("Drag Selected");
} else if (this.letter_grid[j][k].letter_found) {
_mc.gotoAndStop("Found Selected");
} else {
_mc.gotoAndStop("Default");
}
k++;
}
j++;
}
};
WordSearch.prototype.render_word_bank = function () {
this.word_bank.sort();
var word_spacing_y = (this.timeline.word_bank_area._height / (this.word_bank.length + 1));
var j = 0;
while (j < this.word_bank.length) {
this.timeline.attachMovie("word_bank_textfield", "word" + j, this.depth++);
var _mc = this.timeline["word" + j];
_mc._x = this.timeline.word_bank_area._x;
_mc._y = this.timeline.word_bank_area._y + ((j + 1) * word_spacing_y);
_mc.field = this.word_bank[j];
j++;
}
};
WordSearch.prototype.mouse_press = function () {
this.correct_mouse_press = true;
if (!this.timeline.grid_area.hitTest(_root._xmouse, _root._ymouse, true)) {
this.correct_mouse_press = false;
return(undefined);
}
this.mouse_down = true;
this.press_mc = this.get_closest_letter();
if (this.word_selection_type == "Circled") {
this.depth++;
this.timeline.attachMovie("circle_selection", "circle" + this.depth, this.depth);
this.current_circle_selection = this.timeline["circle" + this.depth];
this.current_circle_selection.from_mc = this.press_mc;
this.current_circle_selection.to_mc = this.press_mc;
var _color = new Color(this.current_circle_selection);
_color.setRGB(this.drag_circle_color);
}
};
WordSearch.prototype.get_closest_letter = function () {
var delta_x = Math.max(0, this.timeline._xmouse - (this.timeline.grid_area._x + (this.letter_spacing_x / 2)));
var delta_y = Math.max(0, this.timeline._ymouse - (this.timeline.grid_area._y + (this.letter_spacing_y / 2)));
var index_j = Math.min(this.grid_rows - 1, Math.floor(delta_y / this.letter_spacing_y));
var index_k = Math.min(this.grid_columns - 1, Math.floor(delta_x / this.letter_spacing_x));
return(this.timeline[(("letter_" + index_j) + "_") + index_k]);
};
WordSearch.prototype.mouse_release = function () {
if (!this.correct_mouse_press) {
return(undefined);
}
this.mouse_down = false;
this.release_mc = this.get_closest_proper_letter();
this.evaluate_guess();
this.set_word_path_property(this.press_mc, this.release_mc, "drag_selected", false);
this.render_letter_grid();
this.press_mc = undefined;
this.release_mc = undefined;
};
WordSearch.prototype.action = function () {
if (this.mouse_down) {
this.render_dragged_word();
}
this.update_game_properties();
};
WordSearch.prototype.render_dragged_word = function () {
if (this.word_selection_type == "Circled") {
this.render_circled_dragged_word();
} else {
this.render_dots_dragged_word();
}
};
WordSearch.prototype.render_circled_dragged_word = function () {
this.current_circle_selection.to_mc = this.get_closest_proper_letter();
};
WordSearch.prototype.render_dots_dragged_word = function () {
var closest_mc = this.get_closest_proper_letter();
this.set_word_path_property(this.press_mc, closest_mc, "drag_selected", true);
this.render_letter_grid();
this.set_word_path_property(this.press_mc, closest_mc, "drag_selected", false);
};
WordSearch.prototype.get_closest_proper_letter = function () {
var closest_mc = this.get_closest_letter();
var j1 = this.press_mc.index_j;
var k1 = this.press_mc.index_k;
var j2 = closest_mc.index_j;
var k2 = closest_mc.index_k;
var to_j = undefined;
var to_k = undefined;
if (((Math.abs((j1 - j2) / (k1 - k2)) == 1) || (Math.abs(j1 - j2) == 0)) || (Math.abs(k1 - k2) == 0)) {
to_j = j2;
to_k = k2;
} else {
var angle = Math.abs((Math.atan2(j2 - j1, k2 - k1) * 180) / Math.PI);
if ((angle < 22.5) || (157.5 < angle)) {
to_j = j1;
to_k = k2;
} else if ((67.5 < angle) && (angle < 112.5)) {
to_j = j2;
to_k = k1;
} else {
to_j = (Math.max(Math.abs(j2 - j1), Math.abs(k2 - k1)) * Math.sign(j2 - j1)) + j1;
to_k = (Math.max(Math.abs(j2 - j1), Math.abs(k2 - k1)) * Math.sign(k2 - k1)) + k1;
}
}
to_j = Math.max(0, to_j);
to_k = Math.max(0, to_k);
to_j = Math.min(this.grid_rows - 1, to_j);
to_k = Math.min(this.grid_columns - 1, to_k);
return(this.timeline[(("letter_" + to_j) + "_") + to_k]);
};
WordSearch.prototype.set_word_path_property = function (from_mc, to_mc, prop, val) {
var inc_x = Math.sign(to_mc.index_k - from_mc.index_k);
var inc_y = Math.sign(to_mc.index_j - from_mc.index_j);
var dist_x = Math.abs(to_mc.index_k - from_mc.index_k);
var dist_y = Math.abs(to_mc.index_j - from_mc.index_j);
var dist = Math.max(dist_x, dist_y);
var j = 0;
while (dist >= j) {
var index_j = (from_mc.index_j + (j * inc_y));
var index_k = (from_mc.index_k + (j * inc_x));
this.letter_grid[index_j][index_k][prop] = val;
j++;
}
};
WordSearch.prototype.evaluate_guess = function () {
var selected_word = this.calculate_word_path(this.press_mc, this.release_mc);
var bank_index = this.check_word_bank(selected_word);
if (bank_index != -1) {
this.word_found(bank_index);
} else {
this.wrong_word_found();
}
this.check_for_win();
};
WordSearch.prototype.word_found = function (bank_index) {
this.timeline["word" + bank_index].gotoAndStop(2);
if (this.word_selection_type == "Dots") {
this.set_word_path_property(this.press_mc, this.release_mc, "letter_found", true);
this.set_word_path_property(this.press_mc, this.release_mc, "drag_selected", false);
}
this.score = this.score + this.correct_points;
if (Math.random() < this.special_sound_probability) {
this.timeline.special_correct_sounds.gotoAndStop(1 + Math.randi(1, this.timeline.special_correct_sounds._totalframes));
this.timeline.special_correct_sounds.gotoAndStop(1);
} else {
this.timeline.correct_sounds.gotoAndStop(1 + Math.randi(1, this.timeline.correct_sounds._totalframes));
this.timeline.correct_sounds.gotoAndStop(1);
}
};
WordSearch.prototype.wrong_word_found = function () {
if (this.word_selection_type == "Dots") {
this.set_word_path_property(this.press_mc, this.release_mc, "drag_selected", false);
} else {
this.current_circle_selection.removeMovieClip();
}
this.score = this.score + this.incorrect_points;
if (Math.random() < this.special_sound_probability) {
this.timeline.special_incorrect_sounds.gotoAndStop(1 + Math.randi(1, this.timeline.special_incorrect_sounds._totalframes));
this.timeline.special_incorrect_sounds.gotoAndStop(1);
} else {
this.timeline.incorrect_sounds.gotoAndStop(1 + Math.randi(1, this.timeline.incorrect_sounds._totalframes));
this.timeline.incorrect_sounds.gotoAndStop(1);
}
};
WordSearch.prototype.calculate_word_path = function (from_mc, to_mc) {
var inc_x = Math.sign(to_mc.index_k - from_mc.index_k);
var inc_y = Math.sign(to_mc.index_j - from_mc.index_j);
var dist_x = Math.abs(to_mc.index_k - from_mc.index_k);
var dist_y = Math.abs(to_mc.index_j - from_mc.index_j);
var dist = Math.max(dist_x, dist_y);
var word_str = "";
var j = 0;
while (dist >= j) {
var index_j = (from_mc.index_j + (j * inc_y));
var index_k = (from_mc.index_k + (j * inc_x));
word_str = word_str + this.letter_grid[index_j][index_k].letter;
j++;
}
return(word_str);
};
WordSearch.prototype.check_word_bank = function (word) {
var j = 0;
while (j < this.word_bank.length) {
var word_mc = this.timeline["word" + j];
if (((word_mc.field == word) || (word_mc.field == word.return_reverse())) && (word_mc._currentframe == 1)) {
return(j);
}
if (((word_mc.field.searchReplace(" ", "") == word) || (word_mc.field.searchReplace(" ", "") == word.return_reverse())) && (word_mc._currentframe == 1)) {
return(j);
}
j++;
}
return(-1);
};
WordSearch.prototype.check_for_win = function () {
var j = 0;
while (j < this.word_bank.length) {
var word_mc = this.timeline["word" + j];
if (word_mc._currentframe == 1) {
return(undefined);
}
j++;
}
_root.gotoAndStop("Win");
};
WordSearch.prototype.check_for_lose = function () {
};
WordSearch.prototype.update_game_properties = function () {
this.timeline.score = this.score;
_root.score = this.score;
var time = Math.floor((this.time_limit - (getTimer() - this.start_time)) / 1000);
if (time < 0) {
time = 0;
}
var min = Math.floor(time / 60);
var sec = (time % 60);
if (9 >= sec) {
sec = "0" + sec;
}
this.timeline.timer = (min + ":") + sec;
if (this.timeline.timer == "0:00") {
if (this.show_unfound == "False") {
_root.gotoAndStop("Lose");
} else {
this.show_missed_words();
}
}
};
WordSearch.prototype.show_missed_words = function () {
var j = 0;
while (j < this.answer_key.length) {
var answer = this.answer_key[j];
var found = false;
var k = 0;
while (k < this.word_bank.length) {
var word_mc = this.timeline["word" + k];
if ((word_mc._currentframe != 1) && (word_mc.field == answer.word)) {
found = true;
}
k++;
}
if (!found) {
this.depth++;
this.timeline.attachMovie("circle_selection", "end_selection" + j, this.depth++);
var _mc = this.timeline["end_selection" + j];
var to_j = (answer.start.j + ((answer.length - 1) * answer.increments.j));
var to_k = (answer.start.k + ((answer.length - 1) * answer.increments.k));
_mc.from_mc = this.timeline[(("letter_" + answer.start.j) + "_") + answer.start.k];
_mc.to_mc = this.timeline[(("letter_" + to_j) + "_") + to_k];
var _color = new Color(_mc);
_color.setRGB(this.game_over_circle_color);
}
j++;
}
var j = 0;
while (j < this.word_bank.length) {
this.timeline["word" + j].removeMovieClip();
j++;
}
this.timeline.word_bank_area.gotoAndStop(2);
for (var n in this) {
this[n] = undefined;
}
};
this._x = 0;
this._y = 0;
game = new WordSearch();
Instance of Symbol 54 MovieClip "controller" in Symbol 81 MovieClip Frame 1 (438 B)
onClipEvent (load) {
this._visible = false;
}
onClipEvent (data) {
_parent.game.words = this.words.split("|");
var j = 0;
while (j < _parent.game.words.length) {
_parent.game.words[j] = _parent.game.words[j].toUpperCase();
j++;
}
_parent.game.initialize();
}
onClipEvent (mouseDown) {
_parent.game.mouse_press();
}
onClipEvent (mouseUp) {
_parent.game.mouse_release();
}
onClipEvent (enterFrame) {
_parent.game.action();
}
Symbol 85 Button (53 B)
on (press) {
_root.gotoAndStop("Starting Screen");
}
Symbol 99 MovieClip Frame 35 (8 B)
stop();