Sorry for the delay,
no worries at all.
here is a sample of how it works attached. look how i setup the enterframe events. and how i'm using the array "a" to add the events and remove them.
the real logic is these few lines:
//HERE WE ARE SETTING UP THE ENTER FRAME EVENTS :
var a:Array = [];
function onSetupEnterframes(evt:MouseEvent):void{
EC.addGroup(a);
}
//this rem shows how to remove a cluster.
function onClearEnterframes(evt:MouseEvent):void{
a = EC.remove(PROJECT_UID+"enterFrame");
}
I have a global variable a and I'm putting the results into the addGroup or garbing them from the remove function.
here is the full code (but you can grab that from the fla as well and see it in action:
/**
* VERSION: 1.3
* AS3
* UPDATES AND DOCUMENTATION AT:
http://fla.as/ec * ...
* @author Ben Fhala with support by Core team.
* @site
http://fla.as/ec
* @date 03/08/2010
* Copyright (c) 2009-2010 Everything Nice Inc.
* Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
**/
import _
as.fla.events.EC; //download library source from :
http://fla.as///project ID for clustering
const PROJECT_UID:String="sample_";
var sprContainer:Sprite = addChild(new Sprite()) as Sprite; //container for movieclips
var mcButtons:MovieClip;
startup();
function startup() { //creating 100 movieclips and starting up the events reset method
for(var i:int=0;i<100;i++) createElement();
addChild(mcButtons);
addControlEvents();
for (i=0; i<sprContainer.numChildren; i++)
EC.add(sprContainer.getChildAt(i),Event.ENTER_FRAME,onChildEnterFrame, PROJECT_UID+"enterFrame");
}
function onChildEnterFrame(evt:Event):void{
evt.target.x+=5-Math.random()*10 ;
evt.target.y+=5-Math.random()*10;
}
function createElement():void{
var spr:Sprite = new Sprite();
spr.graphics.beginFill(int(Math.random()*0xffffff)); //random color
spr.graphics.drawCircle(0,0,Math.random()*5);
spr.graphics.endFill();
spr.x = Math.random()*stage.stageWidth;
spr.y = Math.random()*stage.stageHeight;
spr.buttonMode = true;
sprContainer.addChild(spr);
}
function addControlEvents(evt:*=null):void{
EC.add(mcButtons.cbEnterFrameAdd,MouseEvent.CLICK,onSetupEnterframes,PROJECT_UID+"controlls");
EC.add(mcButtons.cbEnterFrameRem,MouseEvent.CLICK,onClearEnterframes,PROJECT_UID+"controlls");
}
//HERE WE ARE SETTING UP THE ENTER FRAME EVENTS :
var a:Array = [];
function onSetupEnterframes(evt:MouseEvent):void{
EC.addGroup(a);
}
//this rem shows how to remove a cluster.
function onClearEnterframes(evt:MouseEvent):void{
a = EC.remove(PROJECT_UID+"enterFrame");
}
--
Best regards,
Ben Fhala
http://local.anxpl.comPhone #:
+1.347.409.4499eFax # :
+1.973.807.5903Israel #: 03.970.8777