home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 231 / PCG231DB1011.ISO / pc / main.swf / scripts / DefineSprite_161 / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-01  |  2.3 KB  |  111 lines

  1. function smoothImageLoad(imgURL, targetMovie)
  2. {
  3.    var _loc1_ = new Object();
  4.    var _loc2_ = new MovieClipLoader();
  5.    _loc1_.onLoadInit = function(mc)
  6.    {
  7.       sizeImage(mc);
  8.    };
  9.    _loc1_.onLoadComplete = function(mc)
  10.    {
  11.       imgGallery.gotoAndPlay("image_fade");
  12.    };
  13.    _loc2_.addListener(_loc1_);
  14.    _loc2_.loadClip(imgURL,targetMovie);
  15. }
  16. function sizeWideImage(target_mc)
  17. {
  18.    mw = target_mc._width;
  19.    mh = target_mc._height;
  20.    ratio = ow / mw;
  21.    fw = mw * ratio;
  22.    fh = mh * ratio;
  23.    if(fh > oh)
  24.    {
  25.       ratio = oh / fh;
  26.       fh *= ratio;
  27.       fw *= ratio;
  28.    }
  29.    target_mc._width = fw;
  30.    target_mc._height = fh;
  31.    xoff = (ow - fw) / 2;
  32.    yoff = (oh - fh) / 2;
  33.    target_mc._x = xoff;
  34.    target_mc._y = yoff;
  35. }
  36. function sizeTallImage(target_mc)
  37. {
  38.    mw = target_mc._width;
  39.    mh = target_mc._height;
  40.    ratio = oh / mh;
  41.    fw = mw * ratio;
  42.    fh = mh * ratio;
  43.    if(fw > ow)
  44.    {
  45.       ratio = ow / fw;
  46.       fh *= ratio;
  47.       fw *= ratio;
  48.    }
  49.    target_mc._width = fw;
  50.    target_mc._height = fh;
  51.    xoff = (ow - fw) / 2;
  52.    yoff = (oh - fh) / 2;
  53.    target_mc._x = xoff;
  54.    target_mc._y = yoff;
  55. }
  56. function sizeImage(target_mc)
  57. {
  58.    if(target_mc._width > target_mc._height)
  59.    {
  60.       sizeWideImage(target_mc);
  61.    }
  62.    else
  63.    {
  64.       sizeTallImage(target_mc);
  65.    }
  66. }
  67. function mainLoop()
  68. {
  69.    if(active)
  70.    {
  71.       imageTimer += 1;
  72.       if(imageTimer >= imageDelay)
  73.       {
  74.          curImage != imgList.length - 2 ? (curImage += 1) : (curImage = 0);
  75.          imageTimer = 0;
  76.          gotoAndStop("preloader_fade");
  77.          play();
  78.       }
  79.    }
  80. }
  81. function loadNext()
  82. {
  83.    smoothImageLoad(imgList[curImage],imgLoader);
  84. }
  85. function loadImages(imgs)
  86. {
  87.    imgList = imgs;
  88.    curImage = 0;
  89.    trace(imgList[curImage]);
  90.    smoothImageLoad(imgList[curImage],imgLoader);
  91.    imgGallery.gotoAndStop("loading_image");
  92.    active = true;
  93. }
  94. var imgList = new Array();
  95. var mcl = new MovieClipLoader();
  96. var mclListener = new Object();
  97. var imageDelay = 5;
  98. var imageTimer = 0;
  99. var curImage = 0;
  100. var imgGallery = this;
  101. var active = false;
  102. var ow = 420;
  103. var oh = 262;
  104. _global.galleryClip = this;
  105. imgLoader.smoothImageLoadComplete = function()
  106. {
  107.    sizeImage(this);
  108.    galleryClip.gotoAndPlay("image_fade");
  109. };
  110. var loopTimer = setInterval(mainLoop,1000);
  111.