Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I made something similar using MiniBuilder:</p> <p><a href="http://www.swfcabin.com/open/1360282440" rel="nofollow">http://www.swfcabin.com/open/1360282440</a></p> <p>Here are the classes:</p> <p>Application.as</p> <pre><code>package com.multiClicker { import flash.display.*; import flash.events.*; public class Application extends Sprite { public function Application() { addEventListener( Event.ENTER_FRAME, onEnterFrame ); } private function onEnterFrame( e:Event ):void { var circle:Target; var n:Number = Math.random(); // 33% of 2% chance each of being added per frame if ( n &lt;= 0.00667 ) circle = new RedTarget(); else if( n &lt;= 0.01334 ) circle = new GreenTarget(); else if( n &lt;= 0.02 ) circle = new BlueTarget(); if ( circle ) { circle.x = Math.random() * stage.stageWidth; circle.y = Math.random() * stage.stageHeight; addChild( circle ); } // Remove dead for ( var i:int = 0; i &lt; numChildren; i++ ) { var child:Target = getChildAt( i ) as Target; if ( child ) { if ( child.dead ) { removeChild( child ); i--; } } } } } } </code></pre> <p>Target.as</p> <pre><code>package com.multiClicker { import flash.display.*; import flash.events.*; public class Target extends Sprite { protected var hp:Number; public function Target() { addEventListener( MouseEvent.CLICK, onClick ); } public function get dead():Boolean { if ( alpha &lt;= 0 ) return true; return false; } protected function drawTarget( color:uint ):void { graphics.beginFill( color ); graphics.drawCircle( 0, 0, 30 ); graphics.endFill(); } private function onClick( e:MouseEvent = null ):void { if ( --hp &lt;= 0 ) addEventListener( Event.ENTER_FRAME, onEnterFrame ); } private function onEnterFrame( e:Event ):void{ alpha -= 0.1; if ( alpha &lt;= 0 ) { removeEventListener( Event.ENTER_FRAME, onEnterFrame ); removeEventListener( MouseEvent.CLICK, onClick ); } } } } </code></pre> <p>RedTarget.as</p> <pre><code>package com.multiClicker { public class RedTarget extends Target { public function RedTarget() { super(); hp = 3; drawTarget( 0xff0000 ); } } } </code></pre> <p>GreenTarget.as</p> <pre><code>package com.multiClicker { public class GreenTarget extends Target { public function GreenTarget() { super(); hp = 2; drawTarget( 0x00ff00 ); } } } </code></pre> <p>BlueTarget.as</p> <pre><code>package com.multiClicker { public class BlueTarget extends Target { public function BlueTarget() { super(); hp = 1; drawTarget( 0x0000ff ); } } } </code></pre> <p>I hope that helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload