stop(); //******SETTINGS****** // Tolerance in pixels in Competition mode DistTolerance = 1000; Cheat = false; hitS = 0; hit1 = 0; hit2 = 0; hit3 = 0; hit4 = 0; hit5 = 0; map1._visible = false; // Map edges in pixels for both yagi and posts map_top = 38; map_bot = 498; map_lef = 220; map_rig = 763; // Get shared object cookie with playerName and language game_so = SharedObject.getLocal("SVMRasor"); // Get language, swe=1, eng=2, fin=3, cze=4, ger=5, fre=6, jap=7, chi=8, rus=9 LanguageSelected = game_so.data.language; if (LanguageSelected>0) { LanguageSettings.LanguageGroup.setValue(LanguageSelected); this["FSetLang_"+LanguageSelected](); } else { // If no Shared Object Available, set language to English, store SO and display LanguageSettings _root.game_so.data.language = 2; FSetLang_2(); mcFirstLanguage._x = 0; mcFirstLanguage._y = 0; LanguageSettings._x = 10; LanguageSettings._y = 30; } //Inital settings varDrawFree = false; setScore = function () { score_txt.text = String(score).addCommas(); }; // Reset some main variables score = 0; gameOver = true; rnd = Math.random; // Adds commas to a string every third character (used on numbers, i.e. "12345" becomes "12,345") String.prototype.addCommas = function() { var len = this.length; var str = ""; for (var i = 0; i<=len; i++) { str = this.charAt(len-i)+str; if (i%3 == 0 && i>0 && i1) { time_fox.setEnabled(true); time_fox.removeAll(); time_fox.addItemAt(0, Txt10s, 10); time_fox.addItemAt(1, Txt20s, 20); time_fox.addItemAt(2, Txt30s, 30); time_fox.setRowCount(3); time_fox.setSelectedIndex(1); draw_2aX._visible = true; draw_2bX._visible = true; draw_3aX._visible = false; draw_3bX._visible = false; results_plate.Fox2txt._visible = true; results_plate.Fox3txt._visible = false; } if (value_no_foxes>1) { time_fox.removeItemAt(4); draw_2aX._visible = true; draw_2bX._visible = true; } else { draw_2aX._visible = false; draw_2bX._visible = false; } if (value_no_foxes>2) { draw_3aX._visible = true; draw_3bX._visible = true; } else { draw_3aX._visible = false; draw_3bX._visible = false; } if (value_no_foxes>3) { draw_4aX._visible = true; draw_4bX._visible = true; } else { draw_4aX._visible = false; draw_4bX._visible = false; } if (value_no_foxes>4) { draw_5aX._visible = true; draw_5bX._visible = true; } else { draw_5aX._visible = false; draw_5bX._visible = false; } }; // When combo-box "Time per post" is changed time_per_post = function () { // Get time per post value_time_fox = time_fox.getValue(); }; // When Competition radio-button is selected CompetitionButton.setChangeHandler("Comp"); Comp = function () { no_foxes.removeAll(); no_foxes.addItemAt(0, TxtFive); no_foxes.setSelectedIndex(0); time_fox.removeAll(); time_fox.addItemAt(0, Txt20s, 20); time_fox.setSelectedIndex(0); _root.BtnShowX._visible = false; _root.CompetitionButtons._visible = true; _root.mcDrawFree._visible = true; // no_foxes.setEnabled(false); // time_fox.setEnabled(false); extraLines._visible = false; ChBoxAttenuator._visible = false; help_fox._visible = false; help_signal._visible = false; help_distance._visible = false; FoxBoxShow._visible = false; SignalBoxShow._visible = false; DistanceBoxShow._visible = false; value_no_foxes = 5; value_time_fox = 20; _root.ModeCompete = true; // Show background buttons draw_2aX._visible = true; draw_2bX._visible = true; draw_3aX._visible = true; draw_3bX._visible = true; draw_4aX._visible = true; draw_4bX._visible = true; draw_5aX._visible = true; draw_5bX._visible = true; results_plate.Fox2txt._visible = true; results_plate.Fox3txt._visible = true; }; // When Training radio-button is selected TrainingButton.setChangeHandler("Train"); Train = function () { // no_foxes.setEnabled(true); // time_fox.setEnabled(true); no_foxes.removeAll(); no_foxes.addItemAt(0, TxtOne, 1); no_foxes.addItemAt(1, TxtTwo, 2); no_foxes.addItemAt(2, TxtThree, 3); no_foxes.addItemAt(3, TxtFour, 4); no_foxes.addItemAt(4, TxtFive, 5); no_foxes.setRowCount(5); no_foxes.setSelectedIndex(1); FUpdateInterval(); BtnShowX._visible = true; CompetitionButtons._visible = false; mcDrawFree._visible = false; extraLines._visible = true; ChBoxAttenuator._visible = true; help_fox._visible = true; help_signal._visible = true; help_distance._visible = true; FoxBoxShow._visible = true; SignalBoxShow._visible = true; DistanceBoxShow._visible = true; value_no_foxes = 2; value_time_fox = 20; _root.ModeCompete = false; // Show background buttons draw_2aX._visible = true; draw_2bX._visible = true; draw_3aX._visible = false; draw_3bX._visible = false; }; //FUNCTION: Set combobox 10, 20, 30 s FUpdateInterval = function () { time_fox.removeAll(); time_fox.addItemAt(0, Txt10s, 10); time_fox.addItemAt(1, Txt20s, 20); time_fox.addItemAt(2, Txt30s, 30); time_fox.setRowCount(3); time_fox.setSelectedIndex(1); }; //Set working area for yagi to map area with (yagi3) { top = map_top; bottom = map_bot; left = map_lef; right = map_rig; } // _root.onEnterFrame = function() { // move yagi forward if (forward) { yagi3._x += 1*(Math.sin((yagi3._rotation+90)*(Math.PI/180))); yagi3._y -= 1*(Math.cos((yagi3._rotation+90)*(Math.PI/180))); // stop yagi at map edges if (yagi3._ymap_bot) { yagi3._y = map_bot; ySpeed = 0; xSpeed = 0; } if (yagi3._xmap_rig) { yagi3._x = map_rig; xSpeed = 0; ySpeed = 0; } } // rotate yagi if (_root.right_dragging) { yagi3._rotation = yagi3._rotation+6; } if (_root.left_dragging) { yagi3._rotation = yagi3._rotation-6; } //Attenuator value (0-3) if (attUse == true) { attenuator._visible = true; fader_scale._visible = true; att_show = Math.round(_root.att_value/9); if (att_show == 0) { damping = 1; } if (att_show == 1) { damping = 0.4; } if (att_show == 2) { damping = 0.2; } if (att_show == 3) { damping = 0.05; } } else { attenuator._visible = false; fader_scale._visible = false; damping = 1; } // with (yagi3) { // // Calculate distance yagi to post delta_x = initx-_x; delta_y = inity-_y; distance = Math.sqrt((delta_x*delta_x)+(delta_y*delta_y)); // calculate the angle from the yagi to post in radians and convert to degrees radians = Math.atan2(delta_y, delta_x); degrees = radians*180/Math.PI + 180; // calculate volume based on angle diff = Math.abs(yagi3._rotation-degrees); if (diff>=180) { diff = Math.abs(diff-360); } // Set signal strength based on distance distance_variable = 1-Math.pow(distance/400, 2); ljudvolymPre = Math.abs(Math.round(distance_variable*(Math.pow((100-Math.min(diff, 100)), 2)/100))); //ljudvolym = Math.round(ljudvolymPre*((30-att_value)/30)); ljudvolym = Math.round(ljudvolymPre*damping); foxes_sounding.fox1_sound.setVolume(ljudvolym); foxes_sounding.fox2_sound.setVolume(ljudvolym); foxes_sounding.fox3_sound.setVolume(ljudvolym); foxes_sounding.fox4_sound.setVolume(ljudvolym); foxes_sounding.fox5_sound.setVolume(ljudvolym); foxes_sounding.fox_end.setVolume(ljudvolym); //Calculate distance to display distance_disp = String(4*Math.round(distance, 2))+" m"; // Round the attenuation value to be shown beside attenuation knob } // TIMER totalTime = getTimer()/1000-pauseLength; goTimeRaw = totalTime-buttonPressTime; if (timing) { goTime = goTimeRaw; minutes = Math.floor((goTime/3600)*60); seconds = Math.floor(((goTime/3600)*60-minutes)*60); if (seconds<10) { seconds = "0"+seconds; } } //Hide HELP values when no post transmits, or competition mode if ((_root.start_mode == 1) || (_root.ModeCompete == true)) { DispSignal._visible = false; DispPost._visible = false; DispDistance._visible = false; } //Check hit Start if (hitS == 0) { if (yagi3.hitTest(fox6_x_pos, fox6_y_pos, false)) { // Play fox left film if (radio_flag6._x<=(map_rig/2)) { mcCountdown._x = radio_flag6._x+50; mcCountdown._y = radio_flag6._y-5; mcCountdown.gotoAndPlay(2); // Play fox right film } else { mcCountdown._x = radio_flag6._x-50; mcCountdown._y = radio_flag6._y-5; mcCountdown.gotoAndPlay(2); } hitS = 1; } } //Check hit posts if (start_mode == 0) { for (i=1; i1) { FShowRadioFlag(2); FCalcDistance(2); } if (value_no_foxes>2) { FShowRadioFlag(3); FCalcDistance(3); } if (value_no_foxes>3) { FShowRadioFlag(4); FCalcDistance(4); } if (value_no_foxes>4) { FShowRadioFlag(5); FCalcDistance(5); } min_fox = Math.min(Math.min(distance1, distance2), distance3); // Determine best fox and show talking fox only if if valid value and not competition mode if ((min_fox != 9999) && (_root.ModeCompete == false)) { for (i=1; i=1000) || (this["distance"+Fox] == NaN)) { this["distance"+Fox] = 9999; this["distance"+Fox+"_disp"] = "---"; this["distance"+Fox+"a"] = 0; } else { this["distance"+Fox+"_disp"] = String(this["distance"+Fox]+" m"); this["distance"+Fox+"a"] = this["distance"+Fox]; distance_total_dis = Number(distance1a+distance2a+distance3a); distance_total_disp = String(distance_total_dis+" m"); // FTotalDist(); } }; // Calculate total distance and min fox //FTotalDist = function () { // distance_total_dis = Number(distance1a+distance2a+distance3a); // distance_total_disp = String(distance_total_dis+" m"); //}; // FUNCTION: Check distance from fox in Competition mode /* FInterceptClose = function (PostId) { // If close enough if (this["distance"+PostId](map_rig+10)) { length = length-5; slut_x = length*angle_x; slut_y = length*angle_y; } // Check if line is outside map, over while ((yagi3._y+slut_y)(map_bot+10)) { length = length-5; slut_x = length*angle_x; slut_y = length*angle_y; } // Fill line with colour with (line) { beginFill(0x0000FF, 50); lineStyle(2, 0xFF00FF, 100); moveTo(yagi3._x+start_x, yagi3._y+start_y); lineTo(yagi3._x+slut_x, yagi3._y+slut_y); endFill(); } // Read start and end of line and locate label this[LineId+"_start_x"] = yagi3._x+start_x; this[LineId+"_start_y"] = yagi3._y+start_y; this[LineId+"_end_x"] = yagi3._x+slut_x; this[LineId+"_end_y"] = yagi3._y+slut_y; this["symbol"+LineId]._x = yagi3._x+((length+8)*angle_x); this["symbol"+LineId]._y = yagi3._y+((length+8)*angle_y); }; /* // FUNCTION: Check if the 3:rd of the found posts, then stop timer FCheckLastPost = function () { if ((post1 == true) && (post2 == true) && (post3 == true)) { CancelButton._visible = false; if (Cheat == false) { EnterScore_btn._visible = true; } newtry._visible = true; stopAllSounds(); FPause(); mcTimerStopFlash._visible = true; mcTimerStopFlash.gotoAndPlay(2); } }; */ // FUNCTION: Hide a-button, show b-button FShowBBtn = function (no) { this["draw_"+no+"a"]._visible = false; this["draw_"+no+"b"]._visible = true; this["draw_"+no+"aX"]._visible = false; }; // FUNCTION: Hide b-button FHideBBtn = function (no) { this["draw_"+no+"b"]._visible = false; this["draw_"+no+"bX"]._visible = false; }; // FUNCTION: Clear all lines and intersection symbols FClearLines = function () { _root.map_shading.pen.clear(); line_extra.clear(); for (i=1; i1) { draw_2a._visible = true; } else { draw_2a._visible = false; } if (value_no_foxes>2) { draw_3a._visible = true; } else { draw_3a._visible = false; } if (value_no_foxes>3) { draw_4a._visible = true; } else { draw_4a._visible = false; } if (value_no_foxes>4) { draw_5a._visible = true; } else { draw_5a._visible = false; } FUnpause(); run_no = 0; foxes_sounding.gotoAndPlay(2); yagi3.stopDrag(); yagi3.onPress = function() { stopDrag(); }; // show help values if (helpSignal == true) { DispSignal._visible = true; } if (helpFox == true) { DispPost._visible = true; } if (helpDistance == true) { DispDistance._visible = true; } // // Show extra line button if ((exLine == true) && (_root.ModeCompete == false)) { BtnExtraLine._visible = true; } else { BtnExtraLine._visible = false; } }; // FUNCTiON: New Try, resetting all parameters FNewTry = function () { BtnMap._visible = true; BtnUp.enabled = true; BtnLeft.enabled = true; BtnRight.enabled = true; mcIndicate1._visible = true; mcIndicate2._visible = false; mcIndicate3._visible = false; fader_scale._x-100; attenuator_x-100; time_fox.setEnabled(true); no_foxes.setEnabled(true); time_fox._visible = true; no_foxes._visible = true; radioGroup.setEnabled(true); map1._visible = false; BtnExtraLine._visible = false; for (i=1; i<(8); i++) { this["delta"+i+"_x"] = NaN; this["delta"+i+"_y"] = NaN; this["distance"+i] = 9999; this["distance"+i+"a"] = null; this["post"+i] = false; } distance_total_disp = "---"; foxes_sounding.gotoAndStop(1); stopAllSounds(); // no_foxes.setEnabled(true); time_fox.setEnabled(true); EnterScore_btn._visible = false; results_plate._visible = false; FYagiStart(); // FRandomMap(); FRestartTimer(); _root.start_mode = 1; hit = 0; show._visible = false; newtry._visible = false; mcTimerStopFlash.gotoAndPlay(1); mcTimerStopFlash._visible = false; 1; // Show GREY draw buttons, hide ACTIVE draw buttons for (i=1; i<(value_no_foxes+1); i++) { this["draw_"+i+"aX"]._visible = true; this["draw_"+i+"bX"]._visible = true; this["draw_"+i+"a"]._visible = false; this["draw_"+i+"b"]._visible = false; } // Reset old results hitS = 0; hitF = o; for (i=1; i<(6); i++) { // Reset result fox and distance info this["distance"+i+"_disp"] = ""; this["fox"+i+"text"] = ""; // Reset the fox position variable this["fox"+i+"_x_pos"] = -100; this["fox"+i+"_y_pos"] = -100; // Reset hits this["hit"+i] = 0; // Hide radio flags and intersection symbols to the left,set intersection to no value this["radio_flag"+i]._x = -100; this["radio_flag"+i].gotoAndStop(1); radio_flag6._x = -100; radio_flag6._y = -100; radio_flag7._x = -100; radio_flag7._y = -100; // Reset line start and end. Reset intersection value this["A"+i+"_start_x"] = 0; this["A"+i+"_start_y"] = 0; this["A"+i+"_end_x"] = 0; this["A"+i+"_end_y"] = 0; this["B"+i+"_start_x"] = 0; this["B"+i+"_start_y"] = 0; this["B"+i+"_end_x"] = 0; this["B"+i+"_end_y"] = 0; this["intersection"+i+"_x"] = 9999; this["intersection"+i+"_y"] = 9999; } // jumping_fox._x = -100; jumping_fox._y = -100; // Delete all lines FClearLines(); // If Competition, show grey competition buttons if (_root.ModeCompete == true) { CompetitionButtons._visible = true; } // Declare and set initial variables and properties with (yagi3) { initx = x_pos; inity = y_pos; } // make yagi draggable yagi3.onPress = function() { startDrag(yagi3, true, left, top, right, bottom); }; yagi3.onRelease = function() { // new att _root.attenuator._x = _root.yagi3._x-35; _root.attenuator._y = _root.yagi3._y-15+_root.att_value; _root.fader_scale._x = _root.yagi3._x-35; _root.fader_scale._y = _root.yagi3._y; stopDrag(); }; attenuator.onPress = function() { startDrag(attenuator, true, _root.yagi3._x-35, _root.yagi3._y-15, _root.yagi3._x-35, _root.yagi3._y+15); // attenuator.text_attenuator._visible = false; // attenuator.attenuator_value_clip._visible = true; }; attenuator.onRelease = function() { stopDrag(); // attenuator.attenuator_value_clip._visible = false; _root.att_value = attenuator._y-_root.yagi3._y+15; stopDrag(); }; }; // CHECKBOX: Attenuator attenuator_change = function () { attUse = ChBoxAttenuator.getValue(); }; // CHECKBOX: ExtraLine extraLines_change = function () { exLine = extraLines.getValue(); if (exLine == true) { ExtraLineX._visible = true; if (start_mode == 0) { BtnExtraLine._visible = true; } } else { ExtraLineX._visible = false; BtnExtraLine._visible = false; } }; // CHECKBOX: Show post help_fox_change = function () { helpFox = help_fox.getValue(); if (helpFox == true) { DispPost._visible = true; } else { DispPost._visible = false; } }; // CHECKBOX: Show signal help_signal_change = function () { helpSignal = help_signal.getValue(); if ((helpSignal == true) && (_root.ModeCompete == false)) { DispSignal._visible = true; } else { DispSignal._visible = false; } }; // CHECKBOX: Show distance help_distance_change = function () { helpDistance = help_distance.getValue(); if ((helpDistance == true) && (_root.ModeCompete == false)) { DispDistance._visible = true; } else { DispDistance._visible = false; } }; // BUTTON: Map BtnMap.onPress = function() { mcLoadMap._x = 240; mcLoadMap._y = 140; }; BtnMap.onRelease = function() { BtnMap._visible = false; mcIndicate1._visible = false; mcIndicate2._visible = true; mcIndicate3._visible = false; time_fox.setEnabled(false); no_foxes.setEnabled(false); radioGroup.setEnabled(false); //time_fox._visible = false; //no_foxes._visible = false; //stopAllSounds(); attenuator.text_attenuator._visible = true; map1._visible = true; map_shading.gotoAndPlay(2); mcLoadMap._x = -100; mcLoadMap._y = -100; //If competition mode if (_root.ModeCompete == true) { CancelButton._visible = true; show._visible = false; DispPost._visible = false; DispSignal._visible = false; DispDistance._visible = false; } else { CancelButton._visible = false; show._visible = true; DispPost._visible = true; DispSignal._visible = true; DispDistance._visible = false; } FRandomLocation(); help_fox_change(); help_signal_change(); // yagi3._focusrect = true; }; // BUTTON: Show show.onRelease = function() { FShowPosts(); }; // BUTTON: New try newtry.onRelease = function() { FNewTry(); }; // BUTTON: Cancel Competition CancelButton.onRelease = function() { CancelButton._visible = false; EnterScore_btn._visible = false; newtry._visible = true; FShowPosts(); }; // BUTTON: Cancel High Score gameOver_mc.BtnScoreCancel.onRelease = function() { gameOver_mc._y = 600; }; // BUTTON: Enter Score EnterScore_btn.onRelease = function() { FClearLines(); score = 60*_root.minutes+Math.round(_root.seconds); gameOver_mc._x = 20; gameOver_mc._y = 15; EnterScore_btn._visible = false; }; // BUTTON: Quit Quit.onRelease = function() { getURL("javascript:window.close()"); }; // BUTTON: Draw_1a draw_1a.onRelease = function() { FShowBBtn(1); _root.createEmptyMovieClip("line_a1", 1); FCheckDrawline(line_a1, "A1"); }; // BUTTON: Draw_1b draw_1b.onRelease = function() { FHideBBtn(1); _root.createEmptyMovieClip("line_b1", 2); FCheckDrawline(line_b1, "B1"); FIntersect(A1_start_x, A1_start_y, A1_end_x, A1_end_y, B1_start_x, B1_start_y, B1_end_x, B1_end_y, 1); }; // BUTTON: Draw_2a draw_2a.onRelease = function() { FShowBBtn(2); _root.createEmptyMovieClip("line_a2", 3); FCheckDrawline(line_a2, "A2"); }; // BUTTON: Draw_2b draw_2b.onRelease = function() { FHideBBtn(2); _root.createEmptyMovieClip("line_b2", 4); FCheckDrawline(line_b2, "B2"); FIntersect(A2_start_x, A2_start_y, A2_end_x, A2_end_y, B2_start_x, B2_start_y, B2_end_x, B2_end_y, 2); }; // BUTTON: Draw_3a draw_3a.onRelease = function() { FShowBBtn(3); _root.createEmptyMovieClip("line_a3", 5); FCheckDrawline(line_a3, "A3"); }; // BUTTON: Draw_3b draw_3b.onRelease = function() { FHideBBtn(3); _root.createEmptyMovieClip("line_b3", 6); FCheckDrawline(line_b3, "B3"); FIntersect(A3_start_x, A3_start_y, A3_end_x, A3_end_y, B3_start_x, B3_start_y, B3_end_x, B3_end_y, 3); }; // BUTTON: Draw_4a draw_4a.onRelease = function() { FShowBBtn(4); _root.createEmptyMovieClip("line_a4", 7); FCheckDrawline(line_a4, "A4"); }; // BUTTON: Draw_4b draw_4b.onRelease = function() { FHideBBtn(4); _root.createEmptyMovieClip("line_b4", 8); FCheckDrawline(line_b4, "B4"); FIntersect(A4_start_x, A4_start_y, A4_end_x, A4_end_y, B4_start_x, B4_start_y, B4_end_x, B4_end_y, 4); }; // BUTTON: Draw_5a draw_5a.onRelease = function() { FShowBBtn(5); _root.createEmptyMovieClip("line_a5", 9); FCheckDrawline(line_a5, "A5"); }; // BUTTON: Draw_5b draw_5b.onRelease = function() { FHideBBtn(5); _root.createEmptyMovieClip("line_b5", 10); FCheckDrawline(line_b5, "B5"); FIntersect(A5_start_x, A5_start_y, A5_end_x, A5_end_y, B5_start_x, B5_start_y, B5_end_x, B5_end_y, 5); }; // Button: Extra line BtnExtraLine.onRelease = function() { nomb_line++; _root.createEmptyMovieClip("line_extra", nomb_line); FCheckDrawline(line_extra, nomb_line); with (_root.line_extra) { //Check where to draw line //_root.check_drawline(); //Check if line is outside map, left //_root.check_outside(); //Fill line with color //_root.fill_colour(); beginFill(0x0000FF, 50); lineStyle(2, 0x999999, 100); moveTo(yagi3._x+start_x, yagi3._y+start_y); lineTo(yagi3._x+slut_x, yagi3._y+slut_y); endFill(); } }; // HELP MENU, Instructions, Language, High Score, About, HelpSystem.SubHelpSet.HelpSubHelp.onRelease = function() { gotoAndStop("Instructions", "Task"); }; HelpSystem.SubHelpSet.HelpSubScore.onRelease = function() { gotoAndStop("ScoreList", 1); }; HelpSystem.SubHelpSet.HelpSubLanguage.onRelease = function() { LanguageSettings._x = 5; LanguageSettings._y = 40; HelpSystem.instructions.enabled = false; HelpSystem.SubHelpSet.HelpSubHelp.enabled = false; HelpSystem.SubHelpSet.HelpSubScore.enabled = false; HelpSystem.SubHelpSet.HelpSubAbout.enabled = false; }; HelpSystem.SubHelpSet.HelpSubAbout.onRelease = function() { mcAbout._x = 0; mcAbout._y = 0; HelpSystem.SubHelpSet._visible = false; _root.mcAbout.gotoAndStop("About"); }; // Options panel // CHECKBOX: Distance Tolerance in Options panel under About mcOptions.ChBoxDist500_change = function() { Dist500 = mcOptions.ChBoxDist500.getValue(); if (Dist500 == true) { DistTolerance = 500; Cheat = true; } else { DistTolerance = 100; Cheat = false; } }; // Function of intersection between 2 lines // (Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy) // r = ----------------------------- (eqn 1) // (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx) //Calculate intersection point and show intersection symbol FIntersect = function (Astart_x, Astart_y, Aend_x, Aend_y, Bstart_x, Bstart_y, Bend_x, Bend_y, PostId) { q = (Astart_y-Bstart_y)*(Bend_x-Bstart_x)-(Astart_x-Bstart_x)*(Bend_y-Bstart_y); d = (Aend_x-Astart_x)*(Bend_y-Bstart_y)-(Aend_y-Astart_y)*(Bend_x-Bstart_x); if (d == 0) { intersect_value = false; } else { intersect_value = true; } r = q/d; q = (Astart_y-Bstart_y)*(Aend_x-Astart_x)-(Astart_x-Bstart_x)*(Aend_y-Astart_y); s = q/d; if (r<0 || r>1 || s<0 || s>1) { intersect_value = false; } else { intersect_value = true; } intersection_x = Astart_x+r*(Aend_x-Astart_x); intersection_y = Astart_y+r*(Aend_y-Astart_y); // New functioon checking intersect 19 juni if (intersect_value == false) { this["intersection"+PostId+"_x"] = 0; this["intersection"+PostId+"_y"] = 0; } else { this["intersection"+PostId+"_symbol"]._x = intersection_x; this["intersection"+PostId+"_symbol"]._y = intersection_y; // // Calculate and show distance this["delta"+PostId+"_x"] = intersection_x-this["fox"+PostId+"_x_pos"]; this["delta"+PostId+"_y"] = intersection_y-this["fox"+PostId+"_y_pos"]; this["distance"+PostId] = (4*Math.round(Math.sqrt(((this["delta"+PostId+"_x"])*(this["delta"+PostId+"_x"]))+((this["delta"+PostId+"_y"])*(this["delta"+PostId+"_y"]))), 2)); } // If competition mode if (_root.ModeCompete == true) { // If close enough if (this["distance"+PostId]