home *** CD-ROM | disk | FTP | other *** search
/ Hentai Interactivo 17 / HENTAI_17.bin / imgs.swf / scripts / DefineSprite_83 / frame_3 / DoAction.as
Text File  |  2006-11-13  |  10KB  |  383 lines

  1. function select()
  2. {
  3.    for(i in playlist_mc.target_mc)
  4.    {
  5.       if(playlist_mc.target_mc[i].songNum != songNum)
  6.       {
  7.          playlist_mc.target_mc[i].gotoAndStop(1);
  8.       }
  9.       else
  10.       {
  11.          playlist_mc.target_mc[i].gotoAndStop(2);
  12.       }
  13.    }
  14. }
  15. function fadeOut()
  16. {
  17.    if(music.getVolume() > 0)
  18.    {
  19.       music.setVolume(music.getVolume() - 5);
  20.    }
  21.    else
  22.    {
  23.       music.stop();
  24.       pos_mc.slider_mc._visible = false;
  25.       pos_mc.slider_mc._x = 0;
  26.    }
  27. }
  28. function nextSong()
  29. {
  30.    if(loop == true and skipLoop != true)
  31.    {
  32.       music.stop();
  33.       music.start(0,0);
  34.    }
  35.    else
  36.    {
  37.       if(shuffle == true)
  38.       {
  39.          songNum = Math.floor(Math.random() * (numTracks - 1));
  40.       }
  41.       else
  42.       {
  43.          songNum++;
  44.          if(songNum == songInfo.content.length)
  45.          {
  46.             songNum = 0;
  47.          }
  48.       }
  49.       loading = true;
  50.       playing = false;
  51.       paused = false;
  52.       select();
  53.       if(skipLoop == true)
  54.       {
  55.          skipLoop = false;
  56.       }
  57.       music.loadSound(songInfo.content[songNum].path,false);
  58.    }
  59. }
  60. function prevSong()
  61. {
  62.    songNum--;
  63.    if(songNum < 0)
  64.    {
  65.       songNum = songInfo.content.length - 1;
  66.    }
  67.    loading = true;
  68.    playing = false;
  69.    paused = false;
  70.    select();
  71.    music.loadSound(songInfo.content[songNum].path,false);
  72. }
  73. music = new Sound(this);
  74. trkInfo = new Date();
  75. playing = false;
  76. paused = false;
  77. loading = true;
  78. vol_mc.slider_mc._x = 70;
  79. bal_mc.slider_mc._x = 50;
  80. pos_mc.slider_mc._x = 0;
  81. pos_mc.slider_mc._visible = false;
  82. vol_mc.slider_mc.slider.useHandCursor = false;
  83. bal_mc.slider_mc.slider.useHandCursor = false;
  84. pos_mc.slider_mc.slider.useHandCursor = false;
  85. scroller_mc.slider_mc.slider.useHandCursor = false;
  86. loop_mc.radio_mc.useHandCursor = false;
  87. shuffle_mc.radio_mc.useHandCursor = false;
  88. songNum = 0;
  89. numTracks = songInfo.content.length;
  90. i = 0;
  91. while(i < numTracks)
  92. {
  93.    songInfo.content[i].songNum = i;
  94.    playlist_mc.target_mc.attachMovie("playlistItem","item" + i,i + 1,songInfo.content[i]);
  95.    playlist_mc.target_mc["item" + i]._y = i * 18;
  96.    if(playlist_mc.target_mc["item" + i].title == songInfo.content[songNum].title)
  97.    {
  98.       playlist_mc.target_mc["item" + i].gotoAndStop(2);
  99.    }
  100.    else
  101.    {
  102.       playlist_mc.target_mc["item" + i].gotoAndStop(1);
  103.    }
  104.    i++;
  105. }
  106. scrollWindowHeight = 72;
  107. scrollMax = playlist_mc.target_mc._y + playlist_mc.target_mc._height - scrollWindowHeight;
  108. if(playlist_mc._height <= scrollWindowHeight)
  109. {
  110.    scroller_mc.slider_mc._visible = false;
  111. }
  112. else
  113. {
  114.    scroller_mc.visible = true;
  115. }
  116. music.loadSound(songInfo.content[songNum].path,false);
  117. this.onEnterFrame = function()
  118. {
  119.    dur = music.duration;
  120.    pos = music.position;
  121.    total = music.getBytesTotal();
  122.    loaded = music.getBytesLoaded();
  123.    if(loading == true)
  124.    {
  125.       if(music.getBytesLoaded() == music.getBytesTotal() and dur > 0)
  126.       {
  127.          loading = false;
  128.          playing = true;
  129.          music.start(0,0);
  130.          music.setVolume(vol_mc.slider_mc._x);
  131.          music.setPan((bal_mc.slider_mc._x - 50) * 2);
  132.          status = "playing";
  133.          pos_mc.slider_mc._visible = true;
  134.       }
  135.       else
  136.       {
  137.          pos_mc.slider_mc._visible = false;
  138.          if(music.getBytesTotal() != undefined)
  139.          {
  140.             artist = Math.round(music.getBytesLoaded() / music.getBytesTotal() * 100) + "% loaded";
  141.          }
  142.          else
  143.          {
  144.             artist = undefined;
  145.          }
  146.          title = undefined;
  147.          status = "loading";
  148.       }
  149.    }
  150.    else if(playing == true)
  151.    {
  152.       vol = music.getVolume() + "%";
  153.       bal = music.getPan();
  154.       if(whichDrag != "pos_mc")
  155.       {
  156.          pos_mc.slider_mc._x = music.position / music.duration * 100;
  157.       }
  158.       music.setVolume(vol_mc.slider_mc._x);
  159.       music.setPan((bal_mc.slider_mc._x - 50) * 2);
  160.       titleArtist = songInfo.content[songNum].path;
  161.       title = songInfo.content[songNum].title;
  162.       artist = songInfo.content[songNum].artist;
  163.       music.onSoundComplete = nextSong;
  164.    }
  165.    else
  166.    {
  167.       titleArtist = undefined;
  168.       fadeOut();
  169.       status = "stopped";
  170.    }
  171.    if(scrolling == true)
  172.    {
  173.       if(playlist_mc._height > scrollWindowHeight)
  174.       {
  175.          percentScroll = scroller_mc.slider_mc._y / (scroller_mc.scrollBg_mc._y + scroller_mc.scrollBg_mc._height);
  176.          scrollValue = scrollMax * percentScroll;
  177.          playlist_mc.target_mc._y = - scrollValue;
  178.       }
  179.    }
  180.    if(timeWay == "forward" or timeWay == undefined)
  181.    {
  182.       trkInfo.setSeconds(music.position / 1000);
  183.       trkInfo.setMinutes(music.position / 1000 / 60);
  184.       trkInfo.setHours(music.position / 1000 / 3600);
  185.    }
  186.    else
  187.    {
  188.       trkInfo.setSeconds((music.duration - music.position) / 1000);
  189.       trkInfo.setMinutes((music.duration - music.position) / 1000 / 60);
  190.       trkInfo.setHours((music.duration - music.position) / 1000 / 3600);
  191.    }
  192.    seconds = trkInfo.getSeconds();
  193.    minutes = trkInfo.getMinutes();
  194.    hours = trkInfo.getHours();
  195.    if(seconds < 10)
  196.    {
  197.       seconds = 0 + seconds.toString();
  198.    }
  199.    if(minutes < 10)
  200.    {
  201.       minutes = 0 + minutes.toString();
  202.    }
  203.    if(hours < 10)
  204.    {
  205.       hours = 0 + hours.toString();
  206.    }
  207.    trkHrs = Math.floor(music.duration / 1000 / 3600);
  208.    trkMin = Math.floor(music.duration / 1000 / 60);
  209.    trkSec = Math.floor(music.duration / 1000 - 60 * trkMin);
  210.    if(trkSec < 10)
  211.    {
  212.       trkSec = 0 + trkSec.toString();
  213.    }
  214.    if(trkMin < 10)
  215.    {
  216.       trkMin = 0 + trkMin.toString();
  217.    }
  218.    if(trkHrs < 10)
  219.    {
  220.       trkHrs = 0 + trkHrs.toString();
  221.    }
  222.    if(loading != true)
  223.    {
  224.       time = hours + ":" + minutes + ":" + seconds;
  225.       totalTrkTime = trkHrs + ":" + trkMin + ":" + trkSec;
  226.    }
  227.    else
  228.    {
  229.       time = undefined;
  230.       totalTrkTime = undefined;
  231.    }
  232. };
  233. play_mc.onRelease = play_mc.onReleaseOutside = function()
  234. {
  235.    if(playing != true or paused == true)
  236.    {
  237.       if(loading != true)
  238.       {
  239.          if(paused == true)
  240.          {
  241.             seconds = pos / 1000;
  242.             music.start(seconds,0);
  243.             paused = false;
  244.          }
  245.          else if(loading != true)
  246.          {
  247.             loading = true;
  248.             music.loadSound(songInfo.content[songNum].path,false);
  249.          }
  250.       }
  251.    }
  252. };
  253. stop_mc.onRelease = stop_mc.onReleaseOutside = function()
  254. {
  255.    loading = false;
  256.    playing = false;
  257.    paused = false;
  258.    artist = undefined;
  259.    title = undefined;
  260. };
  261. pause_mc.onRelease = pause_mc.onReleaseOutside = function()
  262. {
  263.    if(playing == true)
  264.    {
  265.       if(paused == false)
  266.       {
  267.          pos = music.position;
  268.          music.stop();
  269.          paused = true;
  270.       }
  271.       else
  272.       {
  273.          seconds = pos / 1000;
  274.          music.start(seconds,0);
  275.          paused = false;
  276.       }
  277.    }
  278. };
  279. next_mc.onRelease = next_mc.onReleaseOutside = function()
  280. {
  281.    if(loading != true)
  282.    {
  283.       skipLoop = true;
  284.       nextSong();
  285.    }
  286. };
  287. back_mc.onRelease = back_mc.onReleaseOutside = function()
  288. {
  289.    if(loading != true)
  290.    {
  291.       prevSong();
  292.    }
  293. };
  294. loop_mc.radio_mc.onRelease = shuffle_mc.radio_mc.onRelease = function()
  295. {
  296.    if(this._parent._currentframe == 1)
  297.    {
  298.       this._parent.gotoAndStop(2);
  299.    }
  300.    else
  301.    {
  302.       this._parent.gotoAndStop(1);
  303.    }
  304.    if(this._parent._name == "loop_mc")
  305.    {
  306.       if(loop == true)
  307.       {
  308.          loop = false;
  309.       }
  310.       else
  311.       {
  312.          loop = true;
  313.       }
  314.    }
  315.    if(this._parent._name == "shuffle_mc")
  316.    {
  317.       if(shuffle == true)
  318.       {
  319.          shuffle = false;
  320.       }
  321.       else
  322.       {
  323.          shuffle = true;
  324.       }
  325.    }
  326. };
  327. vol_mc.slider_mc.slider.onPress = bal_mc.slider_mc.slider.onPress = pos_mc.slider_mc.slider.onPress = function()
  328. {
  329.    whichDrag = this._parent._parent._name;
  330.    this._parent.onMouseMove = function()
  331.    {
  332.       updateAfterEvent();
  333.    };
  334.    this._parent.startDrag(false,0,this._y,100,this._y);
  335. };
  336. vol_mc.slider_mc.slider.onRelease = vol_mc.slider_mc.slider.onReleaseOutside = bal_mc.slider_mc.slider.onRelease = bal_mc.slider_mc.slider.onReleaseOutside = pos_mc.slider_mc.slider.onRelease = pos_mc.slider_mc.slider.onReleaseOutside = function()
  337. {
  338.    if(whichDrag == "pos_mc")
  339.    {
  340.       if(pos_mc.slider_mc._x == 100)
  341.       {
  342.          pos_mc.slider_mc._x = 99.5;
  343.       }
  344.       newPos = pos_mc.slider_mc._x * (music.duration / 1000) / 100;
  345.       music.stop();
  346.       music.start(newPos,0);
  347.    }
  348.    whichDrag = undefined;
  349.    beenDragged = "pos_mc";
  350.    this._parent.onMouseMove = undefined;
  351.    this._parent.stopDrag();
  352.    if(bal_mc.slider_mc._x > 47 and bal_mc.slider_mc._x < 53)
  353.    {
  354.       bal_mc.slider_mc._x = 50;
  355.    }
  356. };
  357. scroller_mc.slider_mc.slider.onPress = function()
  358. {
  359.    scrolling = true;
  360.    this._parent.startDrag(0,this._parent._x,this._parent._parent.scrollBg_mc._y,this._parent._x,this._parent._parent.scrollBg_mc._y + this._parent._parent.scrollBg_mc._height);
  361. };
  362. scroller_mc.slider_mc.slider.onRelease = function()
  363. {
  364.    scrolling = false;
  365.    this._parent.stopDrag();
  366. };
  367. timeButton_mc.onRelease = function()
  368. {
  369.    if(timeWay == undefined)
  370.    {
  371.       timeWay = "back";
  372.    }
  373.    else if(timeWay == "forward")
  374.    {
  375.       timeWay = "back";
  376.    }
  377.    else if(timeWay == "back")
  378.    {
  379.       timeWay = "forward";
  380.    }
  381. };
  382. stop();
  383.