|
-
removeMovieClip Problem
I wonder if someone can help me out with this
I have 9 buttons on stage that get an MC call planetdiscmc attached to it. how can I remove the planetdiscmc each time a BTN has been click onto.
here my script for removing
thanks
Code:
function planetBtns() {
var btnCnt = buttons.length;
for (i=0; i<btnCnt; i++) {
var btnplanet = this.ee["planet"+i];
btnplanet.onRelease = function() {
removeMovieClip(this.ee["planet"+i].planetdiscmc);
};
}
}
buttons = new Array("planet1", "planet2", "planet3", "planet4", "planet5", "planet6", "planet7", "planet8", "planet9");
planetBtns();
-
Senior Member
Add to this line:
var btnplanet = this.ee["planet"+i];
btnplanet.i = i;
and inside the button script refer to to i as this.i.
- The right of the People to create Flash movies shall not be infringed. -
-
maybe it sfriday and my brain is on overdrive but i can't seem to get this to work. I have an on release on each button and i am trying to refer to the value of i in each button as you have instructed
what am I doing wrong?
Code:
on (release) {
this._parent._parent.displayline();
this.XPos = -193;
this.YPos = 19.9;
this.XPlanet = 161.2;
this.YPlanet = 122.8;
this.attachMovie("planetdisbox", "planetdiscmc", this.getNextHighestDepth(), {_x:XPos, _y:YPos});
this._parent._parent.attachMovie("mer", "mer_mc", 1, {_x:XPlanet, _y:YPlanet});
var tween_handler:Object = new mx.transitions.Tween(this._parent._parent.mer_mc, "_alpha", mx.transitions.easing.Regular.easeIn, 0, 100, 0.5, true);
this._parent.planet1.planetdistance = function(param:String) {
this._parent._parent.planetnametxt.text = "Mearcair";
if (this.count1<this.maxCount1) {
this._parent._parent.planetdistance.text = this.planetdist[this.count1++];
this.gotoAndStop(2);
} else {
clearInterval(this.intervalId);
}
if (this.count2<this.maxCount2) {
this.planetdiscmc.distancetxt.text = this.planetdisttxt[this.count2++];
this._parent._parent
} else {
clearInterval(this.intervalId);
}
};
this.intervalId;
this.count1 = 0;
this.count2 = 0;
this.maxCount1 = 20;
this.maxCount2 = 20;
this.duration = 40;
this.planetdist = new Array("0 km", "220 km", "440 km", "830 km", "1 767 km", "3 530 km", "7 068 km", "14 138 km", "28 276 km", "56 552 km", "113 104 km", "226 208 km", "452 416 km", "904 931 km", "1 809 662 km", "3 619 324 km", "7 238 647 km", "11 477 294 km", "28 954 588 km", "57 909 175 km");
this.planetdisttxt = new Array("0 km", "220 km", "440 km", "830 km", "1 767 km", "3 530 km", "7 068 km", "14 138 km", "28 276 km", "56 552 km", "113 104 km", "226 208 km", "452 416 km", "904 931 km", "1 809 662 km", "3 619 324 km", "7 238 647 km", "11 477 294 km", "28 954 588 km", "57 909 175 km");
if (this.intervalId != null) {
clearInterval(this.intervalId);
}
this.intervalId = setInterval(this, "planetdistance", this.duration);
}
-
Senior Member
Don't use any scripts associated with buttons or movieclips. You have two onRelesae functions: one, which you declare in the for loop. That one you have to use. And now you you show another onRelease function associated with a button. That does not work. You need to put the whole script into the button function in the for loop and delete the associated script.
- The right of the People to create Flash movies shall not be infringed. -
-
Resolved
RESOLVED thanks for the help.
What was I trying to do?? My head must have been completly gone! It will be good to get some design work done for a change!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|