Hi,
I have in a for statement made 12 movieclip buttons, which are called step1, step2, step3.
When you click on a “step” button I want to add a different movieclip called item on the stage and the same number as the clicked button.
This is not so hard, and I managed to do this. The problem is the following: when I click again on another Step, I want to remove the previously added item and replace this by a new item. How can I do this?
Here is the code I got so far:
package
{
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class circular extends MovieClip {
public var numItems:int = 12;
public var angleStep:Number = 360 / numItems;
var particlesArray:Array = new Array();
public var circleMenu = new MovieClip
public var obj:MovieClip
public var contentadded:Boolean = false
public var item1:MovieClip = new Step1()
public var item2:MovieClip = new Step2()
public var step:MovieClip;
private var radius:Number = 150
private var angle:Number = 0
private var centerX:Number = stage.stageWidth/2
private var centerY:Number = stage.stageHeight/2
public function circular() {
createCircle ();
}
function createCircle ():void {
for (var i=0; i < numItems; i++) {
var particle:MyMenuItem = new MyMenuItem();
//Set the starting position (we must convert angles to radians)
particle.y = centerY + Math.sin(angle* Math.PI/180)*radius;
particle.x = centerX + Math.cos(angle * Math.PI/180)*radius;
particle.txt.text = 'Step ' + (i + 1);
particle.txt.mouseEnabled = false;
particle.name = i
particle.buttonMode = true
particle.rotation = angleStep * i
particle.addEventListener( MouseEvent.CLICK, onMenuItemClick );
//Add the particle to the stage and push it to array for later use.
addChild (particle);
particlesArray.push (particle);
angle += angleStep;
}
}
private function onMenuItemClick(evt:MouseEvent):void {
var addContent:Array = new Array();
addContent.push(item1)
addContent.push(item2)
var i:int = evt.target.name
addChild (addContent*)
addContent*.x = 100
addContent*.y = 100
}