home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Software / Demo / Chimie / interfata.swf / scripts / MediaPlayer.as < prev   
Text File  |  2005-01-03  |  6KB  |  226 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.playM();
  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.    if(this.behaviour == 1 && this.lMovie != this.cMovie)
  70.    {
  71.       this.update(this.filmDiv,this.films[this.cMovie],this.x,this.y,this.width,this.height,this.loopM[this.cMovie]);
  72.       this["rd" + this.cMovie].setState(true);
  73.    }
  74.    if(this.behaviour == 1 && this.end == 1)
  75.    {
  76.       this._parent.mediaPlayerStateIs(2);
  77.       this.end = 0;
  78.    }
  79.    if(this.behaviour == 0 && this.end == 1)
  80.    {
  81.       this.end = 0;
  82.       this.cMarker = 0;
  83.    }
  84.    this._parent.mediaPlayerStateIs(1);
  85.    getURL("FSCommand:play",this.filmDiv);
  86. };
  87. Object.MediaPlayerClass.prototype.pauseM = function()
  88. {
  89.    var s = "@";
  90.    this.ply = 0;
  91.    this._parent.mediaPlayerStateIs(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._parent.mediaPlayerStateIs(0);
  100.    this.playBtn.gotoAndStop("Stop");
  101.    getURL("FSCommand:stop",this.filmDiv);
  102. };
  103. Object.MediaPlayerClass.prototype.loadRadioBtn = function()
  104. {
  105.    var i = 0;
  106.    while(i < this.moments.length)
  107.    {
  108.       if(this.aBtn == true)
  109.       {
  110.          var mc = this.attachMc("FRadioButtonSymbol","rd" + i,100,i * 25 + 5);
  111.          mc.setLabel(this.moments[i]);
  112.          mc.setData(i);
  113.          mc.setGroupName("radioGroupM");
  114.       }
  115.       else
  116.       {
  117.          this["rd" + i] = this._parent["rd" + i];
  118.          this["rd" + i].setData(i);
  119.          this["rd" + i].setGroupName("radioGroupM");
  120.       }
  121.       i++;
  122.    }
  123.    if(this.aBtn == false)
  124.    {
  125.       this.radioGroupM = this._parent.radioGroupM;
  126.    }
  127.    if(this.behaviour == 0)
  128.    {
  129.       this.radioGroupM.setChangeHandler("setCurrentMarker",this);
  130.       trace(this.radioGroupM.setChangeHandler);
  131.    }
  132.    else
  133.    {
  134.       this.radioGroupM.setChangeHandler("setCurrentMovie",this);
  135.    }
  136. };
  137. Object.MediaPlayerClass.prototype.setCurrentMarker = function()
  138. {
  139.    var s = "@";
  140.    this.end = 0;
  141.    var mk = arguments[0].getData();
  142.    if(undefined == mk)
  143.    {
  144.       mk = arguments[0];
  145.    }
  146.    getURL("FSCommand:setCurrentMarker",this.filmDiv + s + mk);
  147.    if(mk == 0)
  148.    {
  149.       this.cMarker = 0;
  150.    }
  151.    this.fromMarker = mk;
  152.    this.playM();
  153. };
  154. Object.MediaPlayerClass.prototype.setCMarker = function()
  155. {
  156.    this["rd" + this.cMarker].setState(true);
  157.    this._parent.setMv(this.cMarker);
  158.    if(this.continuous == false)
  159.    {
  160.       this.pauseM();
  161.    }
  162. };
  163. Object.MediaPlayerClass.prototype.setCurrentMovie = function()
  164. {
  165.    var s = "@";
  166.    var mk = arguments[0].getData();
  167.    if(undefined == mk)
  168.    {
  169.       mk = arguments[0];
  170.    }
  171.    this.cMovie = mk;
  172.    this.playM();
  173. };
  174. Object.MediaPlayerClass.prototype.setContinuous = function()
  175. {
  176.    this.continuous = arguments[0].getValue();
  177.    if(this.continuous == true)
  178.    {
  179.       this.playM();
  180.    }
  181.    var i = 0;
  182.    while(i < this.moments.length)
  183.    {
  184.       this["rd" + i].setEnabled(!this.continuous);
  185.       i++;
  186.    }
  187. };
  188. Object.MediaPlayerClass.prototype.setMEnded = function(arg)
  189. {
  190.    this.end = 1;
  191.    if(this.behaviour == 1 && this.cMovie < this.films.length - 1)
  192.    {
  193.       if(this.loopM[this.cMovie] == 1 && this.continuous == false)
  194.       {
  195.          this._parent.mediaPlayerStateIs(2);
  196.          this._parent.mediaPlayerStateIs(1);
  197.          this.end = 0;
  198.          return undefined;
  199.       }
  200.       this.cMovie = this.cMovie + 1;
  201.       if(this.continuous == true)
  202.       {
  203.          this.playM();
  204.       }
  205.       else
  206.       {
  207.          this.pauseM();
  208.       }
  209.    }
  210.    else
  211.    {
  212.       if(this.loopM[this.cMovie] == 1)
  213.       {
  214.          this.end = 0;
  215.          return undefined;
  216.       }
  217.       this.pauseM();
  218.    }
  219. };
  220. Object.MediaPlayerClass.prototype.onUnload = function()
  221. {
  222.    this.stopM();
  223.    getURL("FSCommand:hide",this.filmDiv);
  224. };
  225. Object.registerClass("MediaPlayer",Object.MediaPlayerClass);
  226.