SHARE
TWEET

Flash game code

ninjakarp May 8th, 2019 286 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.events.MouseEvent;
  2. import flash.display.MovieClip;
  3. import flash.media.Sound;
  4. import flash.media.SoundChannel;
  5. import flash.utils.Timer;
  6. import flash.events.TimerEvent;
  7.  
  8.  
  9. { /* MAIN */
  10.  
  11.     stop();
  12.     stage.focus = stage;
  13.  
  14.     var initDone: Boolean
  15.     if (!initDone) {
  16.         // stop all movie clips that have more than 1 frame
  17.         stopMovieClips(chair, credits, cup, cvinv, doll, hat, kaktus, karpfen, karpfenhit, laptop, log, luke1, luke3, mini, paper, pickles, portfolio, portfolioinv, poster, pylon, rkcard, smoke, sylvanas, talk_long, talk_short, textbox, trash, triforce, trophy, worbla);
  18.  
  19.         // mask all hitboxes transparent
  20.         setMovieClipsTransparent(chairhit, cuphit, cvinvhit, dollhit, hathit, kaktushit, karpfenhit, laptophit, lukehit, minihit, portfolioinvhit, paperhit, pickleshit, posterhit, pylonhit, rkcardhit, sylvanashit, trashhit, triforcehit, trophyhit, worblahit);
  21.  
  22.         // set hitboxes inactive
  23.         setMovieClipsInactive(cvinvhit, portfolio, pickleshit, portfolioinvhit, rkcardhit, triforcehit);
  24.  
  25.         // mask other movie clips transparent
  26.         setMovieClipsTransparent(cvinv, log, luke3, pickles, portfolio, portfolioinv, rkcard, talk_long, talk_short, triforce);
  27.  
  28.         //start background animations
  29.         //talk_standard.gotoAndPlay(1);
  30.  
  31.         //set initialization as done
  32.         trace("Initialization completed.");
  33.         initDone = true;
  34.     }
  35.  
  36.  
  37. }
  38.  
  39. { /* EVENT LISTENER */
  40.  
  41.     { /* INFLATE OBJECTS ON MOUSEOVER */
  42.         chairhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(chair, textbox, "chair", talk_long, talk_standard));
  43.         cuphit.addEventListener(MouseEvent.MOUSE_OVER, inflate(cup, textbox, "cup", talk_long, talk_standard));
  44.         cvinvhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(cvinv, textbox, "cvinv", talk_long, talk_standard));
  45.         dollhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(doll, textbox, "doll", talk_long, talk_standard));
  46.         hathit.addEventListener(MouseEvent.MOUSE_OVER, inflate(hat, textbox, "hat", talk_short, talk_standard));
  47.         kaktushit.addEventListener(MouseEvent.MOUSE_OVER, inflate(kaktus, textbox, "kaktus", talk_short, talk_standard));
  48.         karpfenhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(karpfen, textbox, "karpfen", talk_short, talk_standard));
  49.         laptophit.addEventListener(MouseEvent.MOUSE_OVER, inflate(laptop, textbox, "laptop", talk_long, talk_standard));
  50.         //lukehit.addEventListener(MouseEvent.MOUSE_OUT, inflate(luke, textbox, "luke", null, null));
  51.         minihit.addEventListener(MouseEvent.MOUSE_OVER, inflate(mini, textbox, "mini", talk_short, talk_standard));
  52.         paperhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(paper, textbox, "paper", talk_long, talk_standard));
  53.         portfolioinvhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(portfolioinv, textbox, "portfolioinv", talk_long, talk_standard));
  54.         pickleshit.addEventListener(MouseEvent.MOUSE_OVER, inflate(pickles, textbox, "pickles", talk_long, talk_standard));
  55.         posterhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(poster, textbox, "poster", talk_long, talk_standard));
  56.         pylonhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(pylon, textbox, "pylon", talk_short, talk_standard));
  57.         rkcardhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(rkcard, textbox, "rkcard", talk_long, talk_standard));
  58.         sylvanashit.addEventListener(MouseEvent.MOUSE_OVER, inflate(sylvanas, textbox, "sylvanas", talk_long, talk_standard));
  59.         trashhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(trash, textbox, "trash", talk_short, talk_standard));
  60.         triforcehit.addEventListener(MouseEvent.MOUSE_OVER, inflate(triforce, textbox, "triforce", talk_short, talk_standard));
  61.         trophyhit.addEventListener(MouseEvent.MOUSE_OVER, inflate(trophy, textbox, "trophy", talk_short, talk_standard));
  62.         worblahit.addEventListener(MouseEvent.MOUSE_OVER, inflate(worbla, textbox, "worbla", talk_long, talk_standard));
  63.     }
  64.  
  65.     { /* DEFLATE OBJECTS ON MOUSEOUT */
  66.         chairhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(chair, textbox, talk_long, talk_standard));
  67.         cuphit.addEventListener(MouseEvent.MOUSE_OUT, deflate(cup, textbox, talk_long, talk_standard));
  68.         cvinvhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(cvinv, textbox, talk_long, talk_standard));
  69.         dollhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(doll, textbox, talk_long, talk_standard));
  70.         hathit.addEventListener(MouseEvent.MOUSE_OUT, deflate(hat, textbox, talk_short, talk_standard));
  71.         kaktushit.addEventListener(MouseEvent.MOUSE_OUT, deflate(kaktus, textbox, talk_short, talk_standard));
  72.         karpfenhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(karpfen, textbox, talk_short, talk_standard));
  73.         laptophit.addEventListener(MouseEvent.MOUSE_OUT, deflate(laptop, textbox, talk_long, talk_standard));
  74.         //lukehit.addEventListener(MouseEvent.MOUSE_OUT, deflate(luke, textbox, null, null));
  75.         minihit.addEventListener(MouseEvent.MOUSE_OUT, deflate(mini, textbox, talk_short, talk_standard));
  76.         paperhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(paper, textbox, talk_long, talk_standard));
  77.         pickleshit.addEventListener(MouseEvent.MOUSE_OUT, deflate(pickles, textbox, talk_long, talk_standard));
  78.         portfolioinvhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(portfolioinv, textbox, talk_long, talk_standard));
  79.         posterhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(poster, textbox, talk_long, talk_standard));
  80.         pylonhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(pylon, textbox, talk_short, talk_standard));
  81.         rkcardhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(rkcard, textbox, talk_long, talk_standard));
  82.         sylvanashit.addEventListener(MouseEvent.MOUSE_OUT, deflate(sylvanas, textbox, talk_long, talk_standard));
  83.         trashhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(trash, textbox, talk_short, talk_standard));
  84.         triforcehit.addEventListener(MouseEvent.MOUSE_OUT, deflate(triforce, textbox, talk_short, talk_standard));
  85.         trophyhit.addEventListener(MouseEvent.MOUSE_OUT, deflate(trophy, textbox, talk_short, talk_standard));
  86.         worblahit.addEventListener(MouseEvent.MOUSE_OUT, deflate(worbla, textbox, talk_long, talk_standard));
  87.     }
  88.  
  89.     { /* ADD TO INVENTORY ON MOUSE CLICK */
  90.         paperhit.addEventListener(MouseEvent.CLICK, addToInventory(portfolioinv, portfolioinvhit));
  91.         laptophit.addEventListener(MouseEvent.CLICK, addToInventory(triforce, triforcehit));
  92.         hathit.addEventListener(MouseEvent.CLICK, addToInventory(pickles, pickleshit));
  93.         chairhit.addEventListener(MouseEvent.CLICK, addToInventory(rkcard, rkcardhit));
  94.         posterhit.addEventListener(MouseEvent.CLICK, addToInventory(cvinv, cvinvhit));
  95.     }
  96.  
  97.     { /* TIMED LISTENERS */
  98.         var randomBlockLuke: Boolean;
  99.         var randomTimerLuke: Timer = new Timer(60 * 1000) // start INITIAL animation after set time (in milliseconds)
  100.         randomTimerLuke.start();
  101.         randomTimerLuke.addEventListener(TimerEvent.TIMER, randomTimedAnimation(luke1, randomTimerLuke, 20000, 45000, randomBlockLuke));
  102.     }
  103.  
  104.  
  105.     { /* SPECIAL LISTENERS */
  106.         var karpfenExchanged: Boolean = false;
  107.         var kawarimiSound: kagebunshin = new kagebunshin();
  108.         //var karpfenRevertTimer: Timer = new Timer(0);
  109.  
  110.         karpfenhit.addEventListener(MouseEvent.CLICK, kawarimi(karpfen, smoke, log, karpfenhit, 13, karpfenExchanged, /*karpfenRevertTimer,*/ kawarimiSound));
  111.         //karpfenRevertTimer.addEventListener(TimerEvent.TIMER, kawarimi(karpfen, karpfenhit, smoke, log, karpfenhit, 13, karpfenExchanged, karpfenRevertTimer, kawarimiSound));
  112.  
  113.         var clickcounterLuke: uint = 0;
  114.         lukehit.addEventListener(MouseEvent.CLICK, multiObjectAnimation(luke1, randomBlockLuke, clickcounterLuke, true, luke3));
  115.  
  116.         trashhit.addEventListener(MouseEvent.CLICK, function () {
  117.             credits.gotoAndStop("credits")
  118.         });
  119.         credits.addEventListener(MouseEvent.CLICK, function () {
  120.             credits.gotoAndStop("normal")
  121.         });
  122.         //titlescreen.titlebutton.addEventListener(MouseEvent.CLICK, closepopup(titlescreen));
  123.     }
  124. }
  125.  
  126. /*
  127. {  //PORTFOLIO LISTENERS
  128.     portfolio.portfolioprevious.addEventListener(MouseEvent.CLICK, gotoFrame(portfolio, "previous"));
  129.     portfolio.portfolionext.addEventListener(MouseEvent.CLICK, gotoFrame(portfolio, "next"));
  130.     portfolio.portfolioprevious.addEventListener(MouseEvent.MOUSE_OVER, gotoFrame(portfolio.portfolioprevious, "hover"));
  131.     portfolio.portfolionext.addEventListener(MouseEvent.MOUSE_OVER, gotoFrame(portfolio.portfolionext, "hover"));
  132.     portfolio.portfolioprevious.addEventListener(MouseEvent.MOUSE_OUT, gotoFrame(portfolio.portfolioprevious, "normal"));
  133.     portfolio.portfolionext.addEventListener(MouseEvent.MOUSE_OUT, gotoFrame(portfolio.portfolionext, "normal"));
  134.     //stage.addEventListener(MouseEvent.CLICK, closepopup(portfolio, portfolio.hitbox));
  135.     //portfolio.mouseEnabled = false;
  136.     //portfolio.portfoliohit.mouseEnabled = false;
  137.    
  138.     trace("portfolio.x: "+portfolio.x)
  139.     trace("portfolio.y: "+portfolio.y)
  140.     trace("portfolio.width: "+portfolio.width)
  141.     trace("portfolio.height: "+portfolio.height+"\n")
  142.    
  143.     trace("portfolio.portfoliohit.x: "+portfolio.portfoliohit.x)
  144.     trace("portfolio.portfoliohit.y: "+portfolio.portfoliohit.y)
  145.     trace("portfolio.portfoliohit.width: "+portfolio.portfoliohit.width)
  146.     trace("portfolio.portfoliohit.height: "+portfolio.portfoliohit.height+"\n")
  147.    
  148.     trace("stage.x: "+stage.x)
  149.     trace("stage.y: "+stage.y)
  150.     trace("stage.width: "+stage.width)
  151.     trace("stage.height: "+stage.height+"\n")
  152.    
  153.     //portfolio.hitbox.mouseEnabled = false;
  154. }
  155. */
  156. { /* FUNKTIONEN */
  157.  
  158.     function inflate(mc1: MovieClip, mc2: MovieClip, textpos: String, mcStartAnim: MovieClip = null, mcStopAnim: MovieClip = null): Function {
  159.         return function (e: MouseEvent): void {
  160.             mc1.gotoAndStop("bump");
  161.             mc2.gotoAndStop(textpos);
  162.  
  163.             if (mcStartAnim != null) {
  164.                 mcStartAnim.alpha = 1;
  165.                 if (mcStopAnim != null) {
  166.                     mcStopAnim.alpha = 0;
  167.                     mcStopAnim.gotoAndPlay(0);
  168.                 };
  169.  
  170.                 mcStartAnim.addFrameScript(mcStartAnim.totalFrames - 1, lastFrameReached);
  171.                 mcStartAnim.gotoAndPlay(1);
  172.  
  173.                 function lastFrameReached(): void {
  174.                     mcStartAnim.gotoAndStop(1);
  175.                     if (mcStopAnim != null) {
  176.                         mcStartAnim.alpha = 0;
  177.                     };
  178.                 };
  179.             };
  180.         };
  181.     };
  182.  
  183.     function deflate(mc1: MovieClip, mc2: MovieClip, mcStopAnim: MovieClip = null, mcStartAnim: MovieClip = null): Function {
  184.         return function (e: MouseEvent): void {
  185.             mc1.gotoAndStop("normal");
  186.             mc2.gotoAndStop(1);
  187.  
  188.             if (mcStopAnim != null) {
  189.                 mcStopAnim.gotoAndStop(1);
  190.                 if (mcStartAnim != null) {
  191.                     mcStartAnim.gotoAndPlay(1);
  192.                     mcStartAnim.alpha = 1;
  193.                     mcStopAnim.alpha = 0;
  194.                 };
  195.             };
  196.         };
  197.     };
  198.  
  199.     function kawarimi(mcBefore: MovieClip, mcAnim: MovieClip, mcAfter: MovieClip, mcHit: MovieClip, exchangeFrame: int = -1, statusExchanged: Boolean = false, /*timerRevert: Timer = null,*/ mcAnimSound: * = null): Function {
  200.         var blocked: Boolean = false;
  201.         var instance: MovieClip = this;
  202.         return function (e: MouseEvent): void {
  203.             if (!blocked) {
  204.                 blocked = true;
  205.                 var mcBeforeTmp: MovieClip;
  206.                 var mcAfterTmp: MovieClip;
  207.                 var mcHitFrame: uint;
  208.  
  209.                 if (statusExchanged) {
  210.                     mcBeforeTmp = mcAfter;
  211.                     mcAfterTmp = mcBefore;
  212.                     mcHitFrame = 2;
  213.  
  214.                 } else {
  215.                     mcBeforeTmp = mcBefore;
  216.                     mcAfterTmp = mcAfter;
  217.                     mcHitFrame = 1;
  218.                 }
  219.                 /*
  220.                 if (timerRevert != null) {
  221.                     timerRevert.stop();
  222.                 };
  223. */
  224.                 //setMovieClipsInactive(mcBeforeHitTmp);
  225.  
  226.                 //mc2.x = mc1.x - mc1.width/2 - mc2.width/2;
  227.                 //mc2.y = mc1.y + mc1.height/2 + mc1.height/2;
  228.                 mcAnim.addFrameScript(mcAnim.totalFrames - 1, lastFrameReached);
  229.  
  230.  
  231.                 if (exchangeFrame < 0) {
  232.                     exchangeFrame = 1;
  233.                 } else if (exchangeFrame >= mcAnim.totalFrames) {
  234.                     exchangeFrame = mcAnim.totalFrames;
  235.                 };
  236.                 mcAnim.addFrameScript(exchangeFrame - 1, exchangeAssets);
  237.  
  238.  
  239.                 mcAnim.gotoAndPlay(2);
  240.                 if (mcAnimSound != null) {
  241.                     mcAnimSound.play();
  242.                 };
  243.  
  244.  
  245.                 function lastFrameReached(): void {
  246.                     mcAnim.gotoAndStop(1);
  247.                     /*
  248.                     if (!statusExchanged && timerRevert != null) {
  249.                         timerRevert.delay = 10000;
  250.                         timerRevert.repeatCount = 1;
  251.                         timerRevert.start();
  252.                         trace("Timer started");
  253.                     }
  254. */
  255.                     statusExchanged = !statusExchanged;
  256.                     blocked = false;
  257.                 };
  258.  
  259.                 function exchangeAssets(): void {
  260.                     mcBeforeTmp.alpha = 0;
  261.                     mcAfterTmp.alpha = 1;
  262.                     mcHit.gotoAndStop(mcHitFrame);
  263.                 };
  264.             };
  265.         };
  266.     };
  267.     /*
  268.     function revertAssets(): void {
  269.         kawarimi(log, smoke, karpfen, 13, null);
  270.     };
  271. */
  272.  
  273.     function setMovieClipsTransparent(...listMC): void {
  274.         for each(var mc: MovieClip in listMC) {
  275.             mc.alpha = 0;
  276.         };
  277.     };
  278.  
  279.     function stopMovieClips(...listMC): void {
  280.         for each(var mc: MovieClip in listMC) {
  281.             mc.stop();
  282.         };
  283.     };
  284.  
  285.     function setMovieClipsInactive(...listMC): void {
  286.         for each(var mc: MovieClip in listMC) {
  287.             mc.mouseEnabled = false;
  288.             mc.mouseChildren = false;
  289.         };
  290.     };
  291.  
  292.     function setMovieClipsActive(...listMC): void {
  293.         for each(var mc: MovieClip in listMC) {
  294.             mc.mouseEnabled = true;
  295.             mc.mouseChildren = true;
  296.         };
  297.     };
  298.  
  299.     function addToInventory(mcObj: MovieClip, mcHit: MovieClip): Function {
  300.         return function (e: MouseEvent): void {
  301.             mcObj.alpha = 1;
  302.             setMovieClipsActive(mcHit);
  303.         }
  304.     }
  305.  
  306.  
  307.     function randomTime(minTime: uint, maxTime: uint): uint {
  308.         var range: uint = maxTime - minTime;
  309.         var Time: Number = Math.ceil(Math.random() * range) + minTime;
  310.         return (Time);
  311.     };
  312.  
  313.     function randomTimedAnimation(mc1: MovieClip, timer: Timer, minTime: uint, maxTime: uint, blockObject: Boolean = true): Function {
  314.         return function (e: TimerEvent): void {
  315.             if (!blockObject) {
  316.                 blockObject = true;
  317.                 mc1.addFrameScript(mc1.totalFrames - 1, lastFrameReached);
  318.                 mc1.gotoAndPlay(1);
  319.  
  320.                 function lastFrameReached(): void {
  321.                     mc1.gotoAndStop(1);
  322.  
  323.                     var interval: uint = randomTime(minTime, maxTime);
  324.                     timer.delay = interval;
  325.                     trace("Timer for " + mc1.name + " started with " + interval + " milliseconds.");
  326.                     blockObject = false;
  327.                 };
  328.             };
  329.         };
  330.     }
  331.  
  332.     function multiObjectAnimation(mc1: MovieClip, blockObject: Boolean = true, clickcounter: uint = 0, onlyif: Boolean = true, ...listMC): Function {
  333.         var blocked: Boolean = false;
  334.  
  335.         return function (e: MouseEvent): void {
  336.             if (!blocked) {
  337.                 blocked = true;
  338.                 blockObject = true;
  339.  
  340.                 if (clickcounter >= listMC.length - 1) { // if all elements have been iterated once...
  341.                     clickcounter = 0; // ...then reset clickcounter and start from anew.
  342.                     trace("Resetted click counter for " + mc1.name + ".");
  343.                 };
  344.  
  345.  
  346.                 mc1.gotoAndStop(1);
  347.                 listMC[clickcounter].gotoAndStop(1);
  348.                 mc1.alpha = 0;
  349.                 listMC[clickcounter].alpha = 1;
  350.  
  351.                 listMC[clickcounter].addFrameScript(listMC[clickcounter].totalFrames - 1, lastFrameReached);
  352.                 listMC[clickcounter].gotoAndPlay(1);
  353.  
  354.                 function lastFrameReached(): void {
  355.                     listMC[clickcounter].gotoAndStop(1);
  356.                     mc1.gotoAndStop(1);
  357.                     mc1.alpha = 1;
  358.                     listMC[clickcounter].alpha = 0;
  359.                     clickcounter += 1;
  360.                     trace("Set click counter for " + mc1.name + " to: " + clickcounter + ".");
  361.                     blocked = false;
  362.                     blockObject = false;
  363.                 };
  364.             };
  365.         };
  366.     };
  367.  
  368.  
  369.  
  370.     function gotoFrame(mc1: MovieClip, frameLabel: String, alpha: int = -1): Function {
  371.         return function (e: MouseEvent): void {
  372.             if (alpha >= 0) { // only change alpha is a value is specified in function call
  373.                 mc1.alpha = alpha;
  374.             };
  375.             switch (frameLabel) {
  376.                 case "previous":
  377.                     if (mc1.currentFrame == 1) {
  378.                         mc1.gotoAndStop(mc1.totalFrames);
  379.                     } else {
  380.                         mc1.gotoAndStop(mc1.currentFrame - 1);
  381.                     };
  382.                     break;
  383.                 case "next":
  384.                     if (mc1.currentFrame == mc1.totalFrames) {
  385.                         mc1.gotoAndStop(1);
  386.                     } else {
  387.                         mc1.gotoAndStop(mc1.currentFrame + 1);
  388.                     };
  389.                     break;
  390.                 case "first":
  391.                     mc1.gotoAndStop(1);
  392.                     break;
  393.                 case "last":
  394.                     mc1.gotoAndStop(mc1.totalFrames);
  395.                     break;
  396.                 default:
  397.                     mc1.gotoAndStop(frameLabel);
  398.                     break;
  399.             };
  400.  
  401.         };
  402.     };
  403.  
  404.  
  405. };
  406.  
  407. //-------------------------------------------------------------------------
  408.  
  409. //stage.addEventListener(MouseEvent.CLICK,vanish);
  410. /*
  411. trace(sylvanas.readGraphicsData());
  412.  
  413. for( var obj : String in sylvanas ) //here objectData is your object
  414. {
  415.   trace( "Object Name Is : " + obj );
  416.   var data : Object = sylvanas[obj]; //here we get the object value by using the property name
  417.   trace( "Value Is : " + data ); //Converts object to string
  418. }
  419. */
  420.  
  421. //window.reset();
  422.  
  423.  
  424.  
  425. //sylvanas.addEventListener(MouseEvent.MOUSE_OVER,sylvtext);
  426.  
  427.  
  428. //function sylvtext(event:MouseEvent):void{
  429. //textbox.gotoAndStop("sylvanas");}
  430.  
  431.  
  432. /*sylvanas.addEventListener(MouseEvent.MOUSE_OUT,hide);
  433.     function hide(event:MouseEvent):void{
  434.     textbox.gotoAndStop("hidden");}
  435. sylvanas.addEventListener(MouseEvent.CLICK,vanish);
  436. function vanish(event:MouseEvent):void{
  437.     textbox.gotoAndStop("hidden");}
  438. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top