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