Guest User

Untitled

a guest
Jul 1st, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function make2D(){
  2.     createEmptyMovieClip("objectHolder",100);
  3.    
  4.     object = xml.firstChild.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
  5.     totalObjects = object.length;
  6.     trace("Total objects: "+totalObjects);
  7.        
  8.     for(i=0;i<totalObjects;i++){
  9.         myObj = objectHolder.attachMovie(objectMc,objectName+i,i);
  10.         myObj.image = object[i].attributes.image;
  11.         myObj.id = i;
  12.         myObj.isClicked = false;
  13.         if(i==totalObjects-1){
  14.             myObj.isFront = true;
  15.         } else {
  16.             myObj.isFront = false;
  17.         }
  18.         myImg = myObj.createEmptyMovieClip("imageHolder",10);
  19.         myImg._x = (myObj._width + 20)/-2; //centers image
  20.         myImg._y = (myObj._height + 20)/-2; //centers image
  21.        
  22.         var myImgLoader:MovieClipLoader = new MovieClipLoader();
  23.         var myImgListener:Object = new Object();
  24.         myImgLoader.addListener(myImgListener);
  25.         myImgLoader.loadClip(imageURL+myObj.image,myImg);
  26.        
  27.         myObj._x = Math.floor(Math.random() * (Stage.width - 100));
  28.         myObj._y = Math.floor(Math.random() * (Stage.height - 100));
  29.        
  30.         myObj.xpos = myObj._x;
  31.         myObj.ypos = myObj._y;
  32.        
  33.         myObj.onPress = function(){
  34.             this.isClicked = true;
  35.             startDrag(this,false,10,50,Stage.width-10,Stage.height-40);
  36.             if(!this.isFront){
  37.                 prevObj = getMcAtDepth(totalObjects-1);
  38.                 prevObj.isFront = false;
  39.                 this.swapDepths(totalObjects-1);
  40.                 prevObjNewDepth = prevObj.getDepth();
  41.                 myObj = getShiftValue(prevObjNewDepth);
  42.                 //prevObj.xpos = prevObj._x;
  43.                 //prevObj.ypos = prevObj._y;
  44.                 prevObj.xpos = Math.floor(prevObj._x + myObj.X);
  45.                 prevObj.ypos = Math.floor(prevObj._y + myObj.Y);
  46.            
  47.                 depthBlurShift();
  48.             }
  49.            
  50.         }
  51.         myObj.onRelease =
  52.         function(){
  53.             if(!this.isFront){
  54.                 this.isFront = true;
  55.             } else {
  56.                 object[i].attributes.func();//this._parent["object[i].attributes.func"]();// _root[object[i].attributes.func]();
  57.             }
  58.             stopDrag();
  59.             this._x = Math.floor(this._x);
  60.             this._y = Math.floor(this._y);
  61.             myObj = getShiftValue(totalObjects-1);
  62.             this.xpos = Math.floor(this._x + myObj.X);
  63.             this.ypos = Math.floor(this._y + myObj.Y);
  64.             this.isClicked = false;
  65.             currentObject = this;
  66.            
  67.         }
  68.        
  69.         applyBlur(myObj,i);
  70.         applyScale(myObj,i);
  71.        
  72.     }
  73. }
Add Comment
Please, Sign In to add comment