User:Fkids/Toy That Changes Due To Number Of Avatars In Room

Coding
Let's make a toy that changes due to number of avatars in room.

I was making a thermometer so now I'm teaching you how to make a simmilar thing.

All you need is this code to scene you are working on:

import com.whirled.FurniControl; import com.whirled.AvatarControl; // not sure is it needed :P import com.whirled.EntityControl; import com.whirled.ControlEvent;

import flash.utils.Timer; import flash.events.TimerEvent;

var tmer:Timer=new Timer(2000); //1000 milliseconds in a second tmer.addEventListener(TimerEvent.TIMER, updateTerm); //adds a listener on the timer to call the function when the timer reaches the end tmer.start; //starts the timer and loops

var _ctrl :FurniControl = new FurniControl(this); _ctrl.addEventListener(ControlEvent.ENTITY_ENTERED, updateTerm); _ctrl.addEventListener(ControlEvent.ENTITY_LEFT, updateTerm); // triggers function when someone entered or left

var numAvatars:int = 1 // by default there's 1 people in room

updateTerm; // triggers function when loads

function updateTerm(evt:TimerEvent) { numAvatars = _ctrl.getEntityIds(EntityControl.TYPE_AVATAR).length; // checks how many people in room if (numAvatars == 1) { Thermometer.gotoAndStop("1"); // Thermometer is movieclip instance name, in which there are some keyframes // you can also use gotoAndPlay instead of gotoAndStop // 1 is frame label, don't forget to label frames in movieclip } if (numAvatars == 2) { Thermometer.gotoAndStop("2"); } // etc }