/*HoG Radio, Updates information based on a file and calculates a timer. Copyright (C) 2006 name of Christopher Pollard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ // This is a rewrite to attempt perfect code for the HoG radio. // Written by Christopher Pollard: cdpollard@gmail.com // 1/31/2006 my 2 day of actionscripting // The logic is quite simple after writing it down. // This movie clip is the controller of everything else. /* This is basically the logic i have come up with Start Switch vars loaded? no Switch am i already loading? no load vars set loading flag yes print song info calculate timer switch time = 0? yes set loaded vars to false set loading flag to false */ onClipEvent (enterFrame) { // Start switch (_root.update_success) { default: // We need to load the vars switch (loading_vars) { // check to see if we are already loading case "1": // While loading, we should display loading info tmp = _root.song_title.substr(0, 1); _root.song_title_lable = _root.song_title.substr(1, _root.song_title.length-1)+tmp; _root.song_artist_lable = "Loading..."; _root.timeleft_lable = "0:00"; _root.timeleft_lable = "8:88"; _root.update_success = 0; break; default: // We aren't loading vars yet, start loading them. loading_vars = "1"; // Let flash know we are already loading vars loaded_time = 0; loaded_time = new Date(); loaded_time = loaded_time.getTime() / 1000; loadVariables("http://www.firetabs.com/radio/nowplaying.txt", "/"); // Location to vars. break; } break; case "1": // Song info has been updated, now we can put it in the radio. // When the time runs out. if (total_seconds <= 0 || _root.timeleft == "8:88"){ _root.song_title_lable = "Retrieving new track information."; _root.song_artist_lable = _root.song_artist; reverse_clock += count_down_start; _root.update_success = 0; // Will run through loading vars again. loading_vars = 0; // Will allow loadvars to be run again. // Print 88:88 in the box. // Reset values. } else if (total_seconds == 10){ _root.load_song_info (); } else { _root.timeleft_lable = total_minutes + ":" + remaining_seconds; _root.song_genre_lable = _root.song_genre; } // Calculate Timeleft total_delay = Math.round(loaded_time - _root.time_stamp); count_down_start = _root.song_length - total_delay ; total_seconds = Math.round(count_down_start - (getTimer() / 1000) + reverse_clock); if (total_seconds >= 60){ total_minutes = Math.floor(total_seconds / 60); } else if (total_seconds < 60) { total_minutes = 0; } remaining_seconds = total_seconds - (total_minutes * 60); // Print TimeLeft if (remaining_seconds <10 && remaining_seconds >=0 ){ remaining_seconds = "0"+remaining_seconds; } // End Calculate Timeleft if (_root.song_title.length >= 50){ // Start Scrolling song title // Grab the first letter of the title. tmp = _root.song_title.substr(0, 1); // Print the title, start from 2 character of the string, then print everything but the last char // then add the first char of the title to the end. _root.song_title = _root.song_title.substr(1, _root.song_title.length-1)+tmp; // End Scrolling song title } if (_root.song_artist.length >= 20){ // Start Scrolling song title // Grab the first letter of the title. tmp = _root.song_artist.substr(0, 1); // Print the title, start from 2 character of the string, then print everything but the last char // then add the first char of the title to the end. _root.song_artist = _root.song_artist.substr(1, _root.song_artist.length-1)+tmp; // End Scrolling song title } break; } } /* I leave this version by noting the following hopefull updates. The display information needs to change as it is being updated. It should count down from 15 and display the info in the screen. Even more possible a status bar displaying the data. */