home *** CD-ROM | disk | FTP | other *** search
/ The Great Adventure of Natural Gas / start / start.swf / scripts / frame_3 / DoAction.as
Encoding:
Text File  |  2007-01-01  |  6.2 KB  |  223 lines

  1. function setQuitter(s)
  2. {
  3.    if(s !== "quitgmf")
  4.    {
  5.       btnquitter.onRelease = function()
  6.       {
  7.          trace("quitter le jeu");
  8.          _root.attachMovie("quitgame","quitgame",200);
  9.          quitgame._visible = true;
  10.       };
  11.       btnquitter.onRollOver = function()
  12.       {
  13.          _level0.showToolTip("Retourner au menu");
  14.          btnquitter._alpha = 100;
  15.          btnquitter.gotoAndPlay("in");
  16.       };
  17.       btnquitter.onRollOut = btnquitter.onDragOut = function()
  18.       {
  19.          _level0.hideToolTip("");
  20.          btnquitter._alpha = 40;
  21.          btnquitter.gotoAndPlay("out");
  22.       };
  23.    }
  24.    else
  25.    {
  26.       btnquitter.onRelease = function()
  27.       {
  28.          trace("quitter gmf");
  29.          menu._visible = false;
  30.          clipRes._visible = false;
  31.          appliquit._visible = true;
  32.       };
  33.       btnquitter.onRollOver = function()
  34.       {
  35.          btnquitter.gotoAndPlay("in");
  36.          btnquitter._alpha = 100;
  37.          _level0.showToolTip("Quitter");
  38.       };
  39.       btnquitter.onRollOut = btnquitter.onDragOut = function()
  40.       {
  41.          btnquitter.gotoAndPlay("out");
  42.          btnquitter._alpha = 40;
  43.          _level0.hideToolTip("");
  44.       };
  45.    }
  46. }
  47. function retourMenu()
  48. {
  49.    gotoAndStop("menu");
  50.    _root.mcscene.efface();
  51.    _root.mcscene.resetObjs();
  52.    activeZoom(false);
  53.    menu._visible = true;
  54.    menu.gotoAndPlay("grand");
  55.    quizzz.removeMovieClip();
  56. }
  57. function playSound(s, v)
  58. {
  59.    if(_global.sonActif != false)
  60.    {
  61.       var _loc1_ = new Sound();
  62.       _loc1_.attachSound(s);
  63.       if(v != null)
  64.       {
  65.          _loc1_.setVolume(v);
  66.       }
  67.       _loc1_.start();
  68.    }
  69. }
  70. function zoomSouris()
  71. {
  72.    var _loc1_ = this;
  73.    var _loc2_ = _root;
  74.    if(zoom)
  75.    {
  76.       _loc1_._xscale += (targetscale - _loc1_._xscale) * 0.1;
  77.       _loc1_._yscale = _loc1_._xscale;
  78.       if(enfonce && souris)
  79.       {
  80.          _loc1_._x = mousex - centrex * _loc1_._xscale / 100;
  81.          _loc1_._y = mousey - centrey * _loc1_._xscale / 100;
  82.       }
  83.       if(!enfonce || !souris)
  84.       {
  85.          if(souris)
  86.          {
  87.             if(_loc2_._xmouse < minXmouse)
  88.             {
  89.                targetx += Math.abs(_loc2_._xmouse - minXmouse) * accel;
  90.             }
  91.             if(_loc2_._xmouse > maxXmouse)
  92.             {
  93.                targetx -= Math.abs(_loc2_._xmouse - maxXmouse) * accel;
  94.             }
  95.             if(_loc2_._ymouse < minYmouse)
  96.             {
  97.                targety += Math.abs(_loc2_._ymouse - minYmouse) * accel;
  98.             }
  99.             if(_loc2_._ymouse > maxYmouse)
  100.             {
  101.                targety -= Math.abs(_loc2_._ymouse - maxYmouse) * accel;
  102.             }
  103.          }
  104.          else
  105.          {
  106.             targetx = largeur * 0.5 - ciblex * _loc1_._xscale / 100;
  107.             targety = hauteur * 0.5 - cibley * _loc1_._yscale / 100;
  108.             _loc1_._x += (targetx - _loc1_._x) * 0.5;
  109.             _loc1_._y += (targety - _loc1_._y) * 0.5;
  110.             if(Math.abs(targetscale - _loc1_._xscale) < 5)
  111.             {
  112.                _loc1_.callback();
  113.                _loc1_.callback = null;
  114.             }
  115.          }
  116.          if(targetx + _loc1_.getBounds(_loc1_).xMin * _loc1_._xscale / 100 > 0)
  117.          {
  118.             targetx = (- _loc1_.getBounds(_loc1_).xMin) * _loc1_._xscale / 100;
  119.          }
  120.          else if(targetx + _loc1_.getBounds(_loc1_).xMax * _loc1_._xscale / 100 < largeur)
  121.          {
  122.             targetx = largeur - _loc1_.getBounds(_loc1_).xMax * _loc1_._xscale / 100;
  123.          }
  124.          if(targety + _loc1_.getBounds(_loc1_).yMin * _loc1_._xscale / 100 > 0)
  125.          {
  126.             targety = (- _loc1_.getBounds(_loc1_).yMin) * _loc1_._xscale / 100;
  127.          }
  128.          else if(targety + _loc1_.getBounds(_loc1_).yMax * _loc1_._xscale / 100 < hauteur)
  129.          {
  130.             targety = hauteur - _loc1_.getBounds(_loc1_).yMax * _loc1_._xscale / 100;
  131.          }
  132.          _loc1_._x += (targetx - _loc1_._x) * 0.1;
  133.          _loc1_._y += (targety - _loc1_._y) * 0.1;
  134.       }
  135.       if(_loc1_._x + _loc1_.getBounds(_loc1_).xMin * _loc1_._xscale / 100 > 0)
  136.       {
  137.          _loc1_._x = (- _loc1_.getBounds(_loc1_).xMin) * _loc1_._xscale / 100;
  138.       }
  139.       else if(_loc1_._x + _loc1_.getBounds(_loc1_).xMax * _loc1_._xscale / 100 < largeur)
  140.       {
  141.          _loc1_._x = largeur - _loc1_.getBounds(_loc1_).xMax * _loc1_._xscale / 100;
  142.       }
  143.       if(_loc1_._y + _loc1_.getBounds(_loc1_).yMin * _loc1_._xscale / 100 > 0)
  144.       {
  145.          _loc1_._y = (- _loc1_.getBounds(_loc1_).yMin) * _loc1_._xscale / 100;
  146.       }
  147.       else if(_loc1_._y + _loc1_.getBounds(_loc1_).yMax * _loc1_._xscale / 100 < hauteur)
  148.       {
  149.          _loc1_._y = hauteur - _loc1_.getBounds(_loc1_).yMax * _loc1_._xscale / 100;
  150.       }
  151.    }
  152. }
  153. function zoomTo(x, y, z, f)
  154. {
  155.    playSound("sonzoom",20);
  156.    zoom = true;
  157.    targetscale = z;
  158.    souris = false;
  159.    mcscene.callback = f;
  160.    ciblex = x;
  161.    cibley = y;
  162. }
  163. function pageRes()
  164. {
  165.    menu._visible = false;
  166.    clipRes._visible = true;
  167. }
  168. stop();
  169. souris = true;
  170. zoom = false;
  171. accel = 0.08;
  172. safezoneX = 80;
  173. safezoneY = 80;
  174. largeur = 550;
  175. hauteur = 300;
  176. btnquitter.gotoAndStop(1);
  177. btnquitter._alpha = 40;
  178. targetx = mcscene._x;
  179. targety = mcscene._y;
  180. minXmouse = (Stage.width - safezoneX) / 2;
  181. maxXmouse = (Stage.width + safezoneX) / 2;
  182. minYmouse = (Stage.height - safezoneY) / 2;
  183. maxYmouse = (Stage.height + safezoneY) / 2;
  184. targetscale = 100;
  185. mouseEcouteur = {};
  186. enfonce = false;
  187. mouseEcouteur.onMouseUp = function()
  188. {
  189.    playSound("sonzoom",20);
  190.    centrex = mcscene._xmouse;
  191.    centrey = mcscene._ymouse;
  192.    mousex = _root._xmouse;
  193.    mousey = _root._ymouse;
  194.    targetscale = 100;
  195.    enfonce = false;
  196. };
  197. mouseEcouteur.onMouseDown = function()
  198. {
  199.    enfonce = true;
  200.    playSound("sonzoom",20);
  201.    centrex = mcscene._xmouse;
  202.    centrey = mcscene._ymouse;
  203.    mousex = _root._xmouse;
  204.    mousey = _root._ymouse;
  205.    targetscale = 400;
  206. };
  207. _global.activeZoom = function(bool)
  208. {
  209.    if(bool)
  210.    {
  211.       Mouse.addListener(mouseEcouteur);
  212.       zoom = true;
  213.       souris = true;
  214.    }
  215.    else
  216.    {
  217.       Mouse.removeListener(mouseEcouteur);
  218.       zoom = false;
  219.       souris = false;
  220.    }
  221. };
  222. mcscene.onEnterFrame = zoomSouris;
  223.