home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Demo / Elearn / Fizica / vol1 / interfata.swf / scripts / MediaPlayer.as < prev    next >
Text File  |  2005-01-03  |  6KB  |  236 lines

  1. Object.MediaPlayerClass = function()
  2. {
  3.    var s = "@";
  4.    this.filmDiv = "filmuletzDIV";
  5.    if(this.behaviour == 1)
  6.    {
  7.       this.cMovie = 0;
  8.    }
  9.    else
  10.    {
  11.       this.cMarker = "";
  12.       this.watch("cMarker",function(id, o, n)
  13.       {
  14.          this.cMarker = n;
  15.          this.setCMarker(n);
  16.       }
  17.       );
  18.    }
  19.    this.mEnded = 0;
  20.    this.end = 0;
  21.    this.watch("mEnded",function(id, o, n)
  22.    {
  23.       this.mEnded = n;
  24.       this.setMEnded();
  25.    }
  26.    );
  27.    this.onLoad = function()
  28.    {
  29.       this.loadRadioBtn();
  30.       this.cMarker = 0;
  31.       this.continuous = false;
  32.       this.ply = 0;
  33.       this.playBtn.cntrl = this;
  34.       this.playBtn.onRelease = function()
  35.       {
  36.          if(this.cntrl.ply == 0)
  37.          {
  38.             this.cntrl.playM();
  39.          }
  40.          else
  41.          {
  42.             this.cntrl.pauseM();
  43.          }
  44.       };
  45.       getURL("FSCommand:register",this.filmDiv + s + this);
  46.       this.update(this.filmDiv,this.films[0],this.x,this.y,this.width,this.height,this.loopM[this.cMovie]);
  47.       this.playM();
  48.       tis.marker = 0;
  49.       this.nm = 1;
  50.    };
  51. };
  52. Object.MediaPlayerClass.prototype = new MovieClip();
  53. Object.MediaPlayerClass["extends"](MovieClip);
  54. Object.MediaPlayerClass.prototype.update = function(div, film, x, y, width, height)
  55. {
  56.    var s = "@";
  57.    getURL("FSCommand:load",div + s + film + s + x + s + y + s + width + s + height);
  58.    if(this.behaviour == 1)
  59.    {
  60.       this._parent.setMv(this.cMovie);
  61.       this.lMovie = this.cMovie;
  62.       this["rd" + this.cMovie].setState(true);
  63.    }
  64. };
  65. Object.MediaPlayerClass.prototype.playM = function()
  66. {
  67.    var s = "@";
  68.    this.ply = 1;
  69.    this.playBtn.gotoAndStop("Play");
  70.    if(this.behaviour == 1 && this.lMovie != this.cMovie)
  71.    {
  72.       this.update(this.filmDiv,this.films[this.cMovie],this.x,this.y,this.width,this.height,this.loopM[this.cMovie]);
  73.       this["rd" + this.cMovie].setState(true);
  74.    }
  75.    if(this.behaviour == 0 && this.end == 1)
  76.    {
  77.       this.end = 0;
  78.       this.cMarker = 0;
  79.    }
  80.    if(this.nm == 1)
  81.    {
  82.       this["rd" + this.marker].setState(true);
  83.       this._parent.setMv(this.marker);
  84.       this.nm = 0;
  85.    }
  86.    getURL("FSCommand:play",this.filmDiv);
  87. };
  88. Object.MediaPlayerClass.prototype.pauseM = function()
  89. {
  90.    var s = "@";
  91.    this.ply = 0;
  92.    this.playBtn.gotoAndStop("Stop");
  93.    getURL("FSCommand:pause",this.filmDiv);
  94. };
  95. Object.MediaPlayerClass.prototype.stopM = function()
  96. {
  97.    var s = "@";
  98.    this.ply = 0;
  99.    this.playBtn.gotoAndStop("Stop");
  100.    getURL("FSCommand:stop",this.filmDiv);
  101. };
  102. Object.MediaPlayerClass.prototype.loadRadioBtn = function()
  103. {
  104.    var i = 0;
  105.    while(i < this.moments.length)
  106.    {
  107.       if(this.aBtn == true)
  108.       {
  109.          var mc = this.attachMc("FRadioButtonSymbol","rd" + i,100,i * 25 + 5);
  110.          mc.setLabel(this.moments[i]);
  111.          mc.setData(i);
  112.          mc.setGroupName("radioGroupM");
  113.       }
  114.       else
  115.       {
  116.          this["rd" + i] = this._parent["rd" + i];
  117.          this["rd" + i].setData(i);
  118.          this["rd" + i].setGroupName("radioGroupM");
  119.       }
  120.       i++;
  121.    }
  122.    if(this.aBtn == false)
  123.    {
  124.       this.radioGroupM = this._parent.radioGroupM;
  125.    }
  126.    if(this.behaviour == 0)
  127.    {
  128.       this.radioGroupM.setChangeHandler("setCurrentMarker",this);
  129.       trace(this.radioGroupM.setChangeHandler);
  130.    }
  131.    else
  132.    {
  133.       this.radioGroupM.setChangeHandler("setCurrentMovie",this);
  134.    }
  135. };
  136. Object.MediaPlayerClass.prototype.setCurrentMarker = function()
  137. {
  138.    var s = "@";
  139.    var mk = arguments[0].getData();
  140.    if(undefined == mk)
  141.    {
  142.       mk = arguments[0];
  143.    }
  144.    getURL("FSCommand:setCurrentMarker",this.filmDiv + s + mk);
  145.    if(mk == 0)
  146.    {
  147.       this.cMarker = 0;
  148.    }
  149.    this.playM();
  150.    this.fromMarker = 1;
  151. };
  152. Object.MediaPlayerClass.prototype.setCMarker = function(n)
  153. {
  154.    if(this.fromMarker == 1)
  155.    {
  156.       this["rd" + this.cMarker].setState(true);
  157.       this._parent.setMv(this.cMarker);
  158.       this.fromMarker = 0;
  159.    }
  160.    else
  161.    {
  162.       this.nm = 1;
  163.    }
  164.    this.marker = n;
  165.    if(this.continuous == false)
  166.    {
  167.       this.pauseM();
  168.    }
  169.    else
  170.    {
  171.       this["rd" + this.cMarker].setState(true);
  172.       this._parent.setMv(this.cMarker);
  173.       this.nm = 0;
  174.    }
  175. };
  176. Object.MediaPlayerClass.prototype.setCurrentMovie = function()
  177. {
  178.    var s = "@";
  179.    var mk = arguments[0].getData();
  180.    if(undefined == mk)
  181.    {
  182.       mk = arguments[0];
  183.    }
  184.    this.cMovie = mk;
  185.    this.playM();
  186. };
  187. Object.MediaPlayerClass.prototype.setContinuous = function()
  188. {
  189.    this.continuous = arguments[0].getValue();
  190.    if(this.continuous == true)
  191.    {
  192.       this.playM();
  193.    }
  194.    var i = 0;
  195.    while(i < this.moments.length)
  196.    {
  197.       this["rd" + i].setEnabled(!this.continuous);
  198.       i++;
  199.    }
  200. };
  201. Object.MediaPlayerClass.prototype.setMEnded = function(arg)
  202. {
  203.    this.end = 1;
  204.    if(this.behaviour == 1 && this.cMovie < this.films.length - 1)
  205.    {
  206.       if(this.loopM[this.cMovie] == 1 && this.continuous == false)
  207.       {
  208.          return undefined;
  209.       }
  210.       this.cMovie = this.cMovie + 1;
  211.       if(this.continuous == true)
  212.       {
  213.          this.playM();
  214.       }
  215.       else
  216.       {
  217.          this.pauseM();
  218.       }
  219.    }
  220.    else
  221.    {
  222.       if(this.loopM[this.cMovie] == 1)
  223.       {
  224.          this.end = 0;
  225.          return undefined;
  226.       }
  227.       this.pauseM();
  228.    }
  229. };
  230. Object.MediaPlayerClass.prototype.onUnload = function()
  231. {
  232.    this.stopM();
  233.    getURL("FSCommand:hide",this.filmDiv);
  234. };
  235. Object.registerClass("MediaPlayer",Object.MediaPlayerClass);
  236.