Guest User

Untitled

a guest
Jun 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. function addFullsizeInstance(type:String, src:String) {
  2. var fullsizeLoader:Loader = new Loader();
  3.  
  4. fullsizeLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadFullsizeComplete);
  5. fullsizeLoader.load(new URLRequest(src));
  6.  
  7. function onLoadFullsizeComplete(e:Event):void {
  8. var fullsize:LoadedSprite = new LoadedSprite();
  9.  
  10.  
  11. //Loop to Remove Other Instances From Stage
  12. for (var q in ComponentsOnStage[type]) {
  13. trace (q);
  14. removeChild(q);
  15. }
  16. ComponentsOnStage[type] = [];
  17.  
  18. addChild(fullsize);
  19.  
  20. ComponentsOnStage[type] = [fullsize];
  21.  
  22. fullsize.addChild(fullsizeLoader);
  23. fullsize.x = 300;
  24. fullsize.y = 300;
  25. fullsize.addEventListener(MouseEvent.MOUSE_UP, dragFnstop);
  26. fullsize.addEventListener(MouseEvent.MOUSE_DOWN, dragFn);
  27. fullsize.bodyType = type;
  28. fullsize.src = src;
  29.  
  30. //body
  31. if(type == 'body') {
  32. fullsize.x = 130;
  33. fullsize.y = 167;
  34. }
  35.  
  36. //eyes
  37. if(type == 'eyes') {
  38. fullsize.x = 130;
  39. fullsize.y = 167;
  40. }
  41.  
  42. //hair
  43. if(type == 'hair') {
  44. fullsize.x = 130;
  45. fullsize.y = 167;
  46. }
  47.  
  48. //nose
  49. if(type == 'nose') {
  50. fullsize.x = 130;
  51. fullsize.y = 167;
  52. }
  53.  
  54. //mouth
  55. if(type == 'mouth') {
  56. fullsize.x = 130;
  57. fullsize.y = 167;
  58. }
  59.  
  60. function dragFn(event:MouseEvent){
  61. fullsize.startDrag();
  62. };
  63.  
  64. function dragFnstop(event:MouseEvent){
  65. fullsize.stopDrag();
  66. var target = fullsize.dropTarget.parent;
  67.  
  68. if(target == remove_btn) {
  69. removeChild(fullsize);
  70. }
  71. };
  72.  
  73.  
  74.  
  75. }
  76. }
Add Comment
Please, Sign In to add comment