Help with the code of a game of complete sentences

  • dcg76_uamazc
  • Born
  • Born
  • dcg76_uamazc
  • Posts: 1

Post 3+ Months Ago

Hi, I `ma bit stuck, I` m making a game Where You Have to complete the sentences by dragging the words Which are dinamically generated over right place to STIs Some boxes, everything works fine But if you pull the words out of the pits Placed it all are one crashes.


Unfortunately this is someone elses code (another programmer WHO dance on us in the middle of the proyect) Although I Manage to make it work with new words, making the draggable items you undraggable one place all 4 of them in the boxes is totally right Unclear to me. I `ll appreciate any help I can get.


Here `s all the code That this part of the movie is using, I` m using cs4 with actionscript 2:

ACTIONSCRIPT Code: [ Select ]
function random (min, max)
(
var _loc2 = true;
if (usados. length <= max - min)
(
while (_loc2! = false)
(
var _loc1 = Math.floor (Math.random () * (max - min + 1));
_loc2 = repeat (_loc1)
) / / End while
used. push (_loc1)
return (_loc1)
)
else
(
return (0);
) / / End else if
) / / End of the function
function repeat (num)
(
_loc1 var = false;
for (i = 0; i <used. length; i + +)
(
if (num == Used [i])
(
_loc1 = true;
) / / End if
) / / End of for
return (_loc1)
) / / End of the function
stop ();
var used = new Array ();
_root. palabras_colocadas = 0;
palabras_correctas = 0;
listado_x = 700;
listado_y = 400;
origenx = 0;
origeny = 0;
estaba_en = -1;
off = false;
_root. sentence = 2;
var words = new Array ("huts", "made", "mud", "straw");
var correct = new Array (false, false, false, false);
var busy = new Array (-1, -1, -1, -1);
my_font var = new TextFormat ();
my_font.font = "Arial";
my_font.color = 0;
my_font. size = 30;
words [i]. embedFonts = true;
my_font.bold = true;
var i = 0;
while (i <4)
(
this ["box" + i]. gotoAndStop (1);
this. createEmptyMovieClip (myClip "+ i, this.getNextHighestDepth ());
length = words [i]. length * 22;
this ["myClip" + i]. createTextField ("label", 1, 0, 0, length, 40);
this ["myClip" + i]. label.text = words [i];
this ["myClip" + i]. label. setTextFormat (my_font)
this ["myClip" + i]. onPress = function ()
(
temp = this. _name;
temp = Number (temp charAt (6));
if (Occupied [0] == temp)
(
off = true;
estaba_en = 0;
) / / End if
if (Occupied [1] == temp)
(
off = true;
estaba_en = 1;
) / / End if
if (Occupied [2] == temp)
(
off = true;
estaba_en = 2;
) / / End if
if (Occupied [3] == temp)
(
off = true;
estaba_en = 3;
) / / End if
if (! off)
(
estaba_en = -1;
) / / End if
origenx = this._x;
origeny = this. _y;
trace ("was" + estaba_en)
this.startDrag ();
);
this ["myClip" + i]. onRelease = this ["myClip" + i]. onReleaseOutside = function ()
(
this.stopDrag ();
which = this._name;
which = Number (cual. charAt (6));
drop = eval (this._droptarget)
trace (drop);
WHERE = String (drop);
frame = donde.substr (8, 6);
WHERE = Number (donde. charAt (14));
trace (Which + "in" + WHERE + "" + table);
if (table == "table")
(
if (Occupied [WHERE]> = 0 & & Occupied [WHERE] <= 3 | | WHERE == estaba_en)
(
off = false;
this._x = origenx;
this._y = origeny;
)
else
(
if (! off)
(
+ + _root.palabras_colocadas;
) / / End if
section = eval ("tranche" + (where + 1) + "_mc");
tramo.gotoAndPlay (2);
if (_root. palabras_colocadas> = 4)
(
startbtn.start ();
start_mc. gotoAndPlay (2);
)
else
(
palabra_ok.start ();
) / / End else if
length = words [Which]. length * 8.500000E +000;
drop.gotoAndStop (2);
this._y = drop._y - 22;
this._x = drop. _x - long;
Occupied [WHERE] = is;
if (off)
(
off = eval ("Table" + estaba_en)
apaga.gotoAndStop (1);
= Eval section ("section" + (estaba_en +1) + "_mc");
tranche. gotoAndPlay (6);
Occupied [estaba_en] = -1;
correct [estaba_en] = false;
off = false;
trace ("is" + _root.palabras_colocadas + "words");
if (_root.palabras_colocadas == 3)
(
trace ("Without noise off");
start_mc. gotoAndStop (1);
) / / End if
) / / End if
trace (Occupied [0] + "" + Occupied [1] + "" + Occupied [2] + "" + Occupied [3]);
if (Which == where)
(
+ + Palabras_correctas;
correct [WHERE] = true;
) / / End if
) / / End if
) / / End else if
if (table == "myClip" | | Table == "start_)
(
palabra_error.start ();
this._x = origenx;
this. _y = origeny;
) / / End if
if (table == "bottom")
(
if (off)
(
off = eval ("Table" + estaba_en)
off. gotoAndStop (1);
= Eval section ("section" + (estaba_en +1) + "_mc");
tramo.gotoAndPlay (6);
Occupied [estaba_en] = -1;
correct [estaba_en] = false;
- _root. Palabras_colocadas;
off = false;
trace ("is" + _root.palabras_colocadas + "words");
if (_root. palabras_colocadas == 3)
(
startbtn.start ();
start_mc.gotoAndStop (1);
) / / End if
) / / End if
) / / End if
);
+ + I;
) / / End while
var ii = 0;
while (ii <4)
(
var numeroNuevo = random (1, 4);
trace (numeroNuevo)
this ["myClip" + numeroNuevo]. _x = listado_x;
this [myClip "+ numeroNuevo]. listado_y + y = 40 * i;
+ + Ii;
) / / End while
  1. function random (min, max)
  2. (
  3. var _loc2 = true;
  4. if (usados. length <= max - min)
  5. (
  6. while (_loc2! = false)
  7. (
  8. var _loc1 = Math.floor (Math.random () * (max - min + 1));
  9. _loc2 = repeat (_loc1)
  10. ) / / End while
  11. used. push (_loc1)
  12. return (_loc1)
  13. )
  14. else
  15. (
  16. return (0);
  17. ) / / End else if
  18. ) / / End of the function
  19. function repeat (num)
  20. (
  21. _loc1 var = false;
  22. for (i = 0; i <used. length; i + +)
  23. (
  24. if (num == Used [i])
  25. (
  26. _loc1 = true;
  27. ) / / End if
  28. ) / / End of for
  29. return (_loc1)
  30. ) / / End of the function
  31. stop ();
  32. var used = new Array ();
  33. _root. palabras_colocadas = 0;
  34. palabras_correctas = 0;
  35. listado_x = 700;
  36. listado_y = 400;
  37. origenx = 0;
  38. origeny = 0;
  39. estaba_en = -1;
  40. off = false;
  41. _root. sentence = 2;
  42. var words = new Array ("huts", "made", "mud", "straw");
  43. var correct = new Array (false, false, false, false);
  44. var busy = new Array (-1, -1, -1, -1);
  45. my_font var = new TextFormat ();
  46. my_font.font = "Arial";
  47. my_font.color = 0;
  48. my_font. size = 30;
  49. words [i]. embedFonts = true;
  50. my_font.bold = true;
  51. var i = 0;
  52. while (i <4)
  53. (
  54. this ["box" + i]. gotoAndStop (1);
  55. this. createEmptyMovieClip (myClip "+ i, this.getNextHighestDepth ());
  56. length = words [i]. length * 22;
  57. this ["myClip" + i]. createTextField ("label", 1, 0, 0, length, 40);
  58. this ["myClip" + i]. label.text = words [i];
  59. this ["myClip" + i]. label. setTextFormat (my_font)
  60. this ["myClip" + i]. onPress = function ()
  61. (
  62. temp = this. _name;
  63. temp = Number (temp charAt (6));
  64. if (Occupied [0] == temp)
  65. (
  66. off = true;
  67. estaba_en = 0;
  68. ) / / End if
  69. if (Occupied [1] == temp)
  70. (
  71. off = true;
  72. estaba_en = 1;
  73. ) / / End if
  74. if (Occupied [2] == temp)
  75. (
  76. off = true;
  77. estaba_en = 2;
  78. ) / / End if
  79. if (Occupied [3] == temp)
  80. (
  81. off = true;
  82. estaba_en = 3;
  83. ) / / End if
  84. if (! off)
  85. (
  86. estaba_en = -1;
  87. ) / / End if
  88. origenx = this._x;
  89. origeny = this. _y;
  90. trace ("was" + estaba_en)
  91. this.startDrag ();
  92. );
  93. this ["myClip" + i]. onRelease = this ["myClip" + i]. onReleaseOutside = function ()
  94. (
  95. this.stopDrag ();
  96. which = this._name;
  97. which = Number (cual. charAt (6));
  98. drop = eval (this._droptarget)
  99. trace (drop);
  100. WHERE = String (drop);
  101. frame = donde.substr (8, 6);
  102. WHERE = Number (donde. charAt (14));
  103. trace (Which + "in" + WHERE + "" + table);
  104. if (table == "table")
  105. (
  106. if (Occupied [WHERE]> = 0 & & Occupied [WHERE] <= 3 | | WHERE == estaba_en)
  107. (
  108. off = false;
  109. this._x = origenx;
  110. this._y = origeny;
  111. )
  112. else
  113. (
  114. if (! off)
  115. (
  116. + + _root.palabras_colocadas;
  117. ) / / End if
  118. section = eval ("tranche" + (where + 1) + "_mc");
  119. tramo.gotoAndPlay (2);
  120. if (_root. palabras_colocadas> = 4)
  121. (
  122. startbtn.start ();
  123. start_mc. gotoAndPlay (2);
  124. )
  125. else
  126. (
  127. palabra_ok.start ();
  128. ) / / End else if
  129. length = words [Which]. length * 8.500000E +000;
  130. drop.gotoAndStop (2);
  131. this._y = drop._y - 22;
  132. this._x = drop. _x - long;
  133. Occupied [WHERE] = is;
  134. if (off)
  135. (
  136. off = eval ("Table" + estaba_en)
  137. apaga.gotoAndStop (1);
  138. = Eval section ("section" + (estaba_en +1) + "_mc");
  139. tranche. gotoAndPlay (6);
  140. Occupied [estaba_en] = -1;
  141. correct [estaba_en] = false;
  142. off = false;
  143. trace ("is" + _root.palabras_colocadas + "words");
  144. if (_root.palabras_colocadas == 3)
  145. (
  146. trace ("Without noise off");
  147. start_mc. gotoAndStop (1);
  148. ) / / End if
  149. ) / / End if
  150. trace (Occupied [0] + "" + Occupied [1] + "" + Occupied [2] + "" + Occupied [3]);
  151. if (Which == where)
  152. (
  153. + + Palabras_correctas;
  154. correct [WHERE] = true;
  155. ) / / End if
  156. ) / / End if
  157. ) / / End else if
  158. if (table == "myClip" | | Table == "start_)
  159. (
  160. palabra_error.start ();
  161. this._x = origenx;
  162. this. _y = origeny;
  163. ) / / End if
  164. if (table == "bottom")
  165. (
  166. if (off)
  167. (
  168. off = eval ("Table" + estaba_en)
  169. off. gotoAndStop (1);
  170. = Eval section ("section" + (estaba_en +1) + "_mc");
  171. tramo.gotoAndPlay (6);
  172. Occupied [estaba_en] = -1;
  173. correct [estaba_en] = false;
  174. - _root. Palabras_colocadas;
  175. off = false;
  176. trace ("is" + _root.palabras_colocadas + "words");
  177. if (_root. palabras_colocadas == 3)
  178. (
  179. startbtn.start ();
  180. start_mc.gotoAndStop (1);
  181. ) / / End if
  182. ) / / End if
  183. ) / / End if
  184. );
  185. + + I;
  186. ) / / End while
  187. var ii = 0;
  188. while (ii <4)
  189. (
  190. var numeroNuevo = random (1, 4);
  191. trace (numeroNuevo)
  192. this ["myClip" + numeroNuevo]. _x = listado_x;
  193. this [myClip "+ numeroNuevo]. listado_y + y = 40 * i;
  194. + + Ii;
  195. ) / / End while
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 9 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.