forked from: forked from: flash on 2010-3-20

by entioabx
♥0 | Line 128 | Modified 2011-05-16 05:30:44 | MIT License
play

ActionScript3 source code

/**
 * Copyright entioabx ( http://wonderfl.net/user/entioabx )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/sPpk
 */

// forked from hacker_j47hfqaa's forked from: flash on 2010-3-20
// forked from hacker_j47hfqaa's flash on 2010-3-20
package {
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            var n = 0;
var s = 0;
_forcusrect = false;
attachMovie("mask", "mask_mc", 0);
mask_mc._x = mask_mc._y=28;
load_mc = createEmptyMovieClip("load_mc", -1);
var mcLoader:MovieClipLoader = new MovieClipLoader();
var oListener = new Object();

function searchTotal() {
  s++;
  $jpg = "img/pic"+s+".jpg";
  mcLoader.loadClip($jpg, load_mc);
  load_mc._alpha = 0;
  oListener.onLoadError = function() {
    total = s;
    clearInterval(sID);
    n = 0;
    autoExchange();
  };
  mcLoader.addListener(oListener);
}
function p_load(n) {
  $jpg = "img/pic"+n+".jpg";
  mcLoader.loadClip($jpg, load_mc);
  p_direction(n);
  load_mc._x = 10;
  load_mc._y = 10;
  load_mc._alpha = 0;
  _root.onEnterFrame = function() {
    load_mc.setMask(mask_mc);
    load_mc._alpha += (100-load_mc._alpha)/40;
    load_mc._x += (targetx-load_mc._x)/40;
    load_mc._y += (targety-load_mc._y)/40;
    current_num.text = n;
    total_num.text = total-1;
  }
}
function autoExchange() {
  if (n>=total-1) {
    n = 1;
    p_load(n);
  } else {
    n++;
    p_load(n);
  }
}
function p_direction(n) {
  dir = Math.floor(Math.random()*8)+1;
  x0 = y0=10;
  xm = ym=25;
  switch (dir) {
  case 1 :
    targetx = xm;
    targety = ym;
    break;
  case 2 :
    targetx = xm;
    targety = y0;
    break;
  case 3 :
    targetx = xm;
    targety = 2*y0-ym;
    break;
  case 4 :
    targetx = x0;
    targety = 2*y0-ym;
    break;
  case 5 :
    targetx = 2*x0-xm;
    targety = 2*y0-ym;
    break;
  case 6 :
    targetx = 2*x0-xm;
    targety = y0;
    break;
  case 7 :
    targetx = 2*x0-xm;
    targety = ym;
    break;
  case 8 :
    targetx = x0;
    targety = ym;
  }
}
play_btn.onRelease = function() {
  flag=0;
  forcusManager.setFocus(play_btn);
  clearInterval(pID);
  autoExchange();
  pID = setInterval(autoExchange, myCombo.value*1000);
  mx.behaviors.DepthControl.sendBackward(this);
};
stop_btn.onRelease = function() {
  flag=1;
  forcusManager.setFocus(stop_btn);
  clearInterval(pID);
  mx.behaviors.DepthControl.sendBackward(this);
};
f_btn.onRelease = function() {
  forcusManager.setFocus(f_btn);
  autoExchange();
};
b_btn.onRelease = function() {
  forcusManager.setFocus(b_btn);
  if (n<2) {
    n = total-1;
  } else {
    n--;
  }
  p_load(n);
};

sID = setInterval(searchTotal, 70);
pID = setInterval(autoExchange, 4000);
myComboBoxListener = new Object();
myComboBoxListener.change = function() {
  clearInterval(pID);
  if (flag!==1) {
   pID = setInterval(autoExchange, myCombo.value*1000);
  }
};
myCombo.addEventListener("change", myComboBoxListener);
            
        }
    }
}