arianhojat
02-24-2006, 07:35 PM
blah i havent done flash actionscript in a while and was wondering about some simple coding. Bascially what happens is a user clicks on a combo box and a event fires which adds a bullseye movieclip on a layout of the Office where the user is located.
I have a clip in my library set for actionscript export called bullseye, i attach a clip of this to the stage when a user clicks on the drop down, pretend the drop down has data 24, then the clip is called "bullseye24". then i remove it when user clicks another option... the thing is that without the remove code, it will still remove it, which stumps me.
any ideas? event code below...
function change(evt)
{
newEmployee = evt.target.selectedItem.data;//ID of employee given from ComboBox
//if lastClickedEmployee was set before from clicking a previous employee, remove his bullseye before adding new one.
if( !isNaN(lastClickedEmployee) )
{
var hideOldBullsEye = "bullseye"+lastClickedEmployee;
//trace("Removing "+hideOldBullsEye + "from position at x="+ _root[hideOldBullsEye]._x );
//removeMovieClip( this[hideOldBullsEye] ); //doesnt matter if this code is commented out, new clip still gets removed?
}
var locationBox = emp_locationsArray[newEmployee]; // has location info for the employee ID
var textBoxX = _root["textbox"+locationBox]._x; //finds position of a textbox that has users name in their Cube, and this is where the bullseye MC is placed
var textBoxY = _root["textbox"+locationBox]._y;
var newMC:MovieClip = this.attachMovie("bullseye", "bullseye"+newEmployee, 100, {_x: textBoxX, _y: textBoxY} );//seems like this removes the old one even thou 2 different instance names
trace("Adding "+ "bullseye"+newEmployee + "; @x="+textBoxX+", y="+textBoxY);
lastClickedEmployee = newEmployee; //set new last clicked employee
}
empComboBox.addEventListener("change", this);
btw where the heck is the 'Red Flash Code' icon for posting code from before? i am using the PHP code instead and seems to be fine
I have a clip in my library set for actionscript export called bullseye, i attach a clip of this to the stage when a user clicks on the drop down, pretend the drop down has data 24, then the clip is called "bullseye24". then i remove it when user clicks another option... the thing is that without the remove code, it will still remove it, which stumps me.
any ideas? event code below...
function change(evt)
{
newEmployee = evt.target.selectedItem.data;//ID of employee given from ComboBox
//if lastClickedEmployee was set before from clicking a previous employee, remove his bullseye before adding new one.
if( !isNaN(lastClickedEmployee) )
{
var hideOldBullsEye = "bullseye"+lastClickedEmployee;
//trace("Removing "+hideOldBullsEye + "from position at x="+ _root[hideOldBullsEye]._x );
//removeMovieClip( this[hideOldBullsEye] ); //doesnt matter if this code is commented out, new clip still gets removed?
}
var locationBox = emp_locationsArray[newEmployee]; // has location info for the employee ID
var textBoxX = _root["textbox"+locationBox]._x; //finds position of a textbox that has users name in their Cube, and this is where the bullseye MC is placed
var textBoxY = _root["textbox"+locationBox]._y;
var newMC:MovieClip = this.attachMovie("bullseye", "bullseye"+newEmployee, 100, {_x: textBoxX, _y: textBoxY} );//seems like this removes the old one even thou 2 different instance names
trace("Adding "+ "bullseye"+newEmployee + "; @x="+textBoxX+", y="+textBoxY);
lastClickedEmployee = newEmployee; //set new last clicked employee
}
empComboBox.addEventListener("change", this);
btw where the heck is the 'Red Flash Code' icon for posting code from before? i am using the PHP code instead and seems to be fine