Skip to main content
Known Participant
November 8, 2008
Question

[CS3] this._root. or this._parent just won't work + retrieving a MC's y position.

  • November 8, 2008
  • 7 replies
  • 928 views
I've got some buttons which when i click them i want them to make a particular MC move downwards. Well the thing is that when i try to reference to that particular MC it just won't happen (yes the MC has an instance name). For the button i tried something like

btn1.onRelease = function() {
var mcReferece = this._root.myMC;
trace(mcReference);
}

or

btn1.onRelease = function() {
var mcReferece = this._parent.myMC;
trace(mcReference);
}

since they have the same parent.

Both returned undefined.

I've also tried putting directly myMC in the tween, with no effects whatsoever.

The second question is, how can i retrieve the y position of a MC?

Also i've tried putting the tween on the MC itself...

onClipEvent(enterFrame){
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myTween:Tween = new Tween(_level0.myMC, "_y", Elastic.easeOut, 195, 545, 10, false);
}

But not only does it not animate it doesn't even go where it's supposed to go...

Thanks in advance.

P.S. This might be rlly simple to solve but it's been bugging me and can't go on without it. Couldn't figure it myself. Got rlly annoyed at some point 😐
This topic has been closed for replies.

7 replies

K0raXAuthor
Known Participant
November 13, 2008
Ill have to bump this one... i can't find a way to solve the problem and i still havent found out why it's instance 7
:S

EDIT: UNBELIEVABLE!!... when i add some AS to the clip itself (the tax), the trace returns as it should return _level0.tax ... Also the tween works correctly!!
K0raXAuthor
Known Participant
November 10, 2008
The only 7 i can think of that i have in the project is what comes after 6 (ridiculous i know... xD) :


for (i=1; i<=6; i++) {

var current_btn = this["btn"+i];

current_btn.onRollOver = function() {
var currentAlpha = this.cover_mc._alpha;
var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Strong.easeOut, currentAlpha, 0, 0.5, true);
};

current_btn.onRollOut = function() {
var currentAlpha = this.cover_mc._alpha;
var myHoriTween:Tween = new Tween(this.cover_mc, "_alpha", Regular.easeIn, currentAlpha, 100, 0.5, true);

};
}

but that's just the animation for the individual buttons.
kglad
Community Expert
Community Expert
November 10, 2008
why are you getting instance7 output?
K0raXAuthor
Known Participant
November 10, 2008
I got connection error on trying to post the above and thought it didnt post so i pressed back and re-posted. Will some mod delete this please? :)
K0raXAuthor
Known Participant
November 10, 2008
Well here's what i get with the code above...

mc_level0.instance7
undefined

As for the previous one:
U said on the timeline of the mc.. so i went in and added on the first frame simply
trace("mc"+this);
and on the button
trace(this);
and that was the output.
kglad
Community Expert
Community Expert
November 10, 2008
that's not the output that would result from the code i gave and there shouldn't be 3 different objects traced if you followed the directions correctly.

but assuming you copied the code i gave incorrectly and you're right about tax, use:

btn1.onRelease = function() {
trace(this._parent.tax);
new Tween(this._parent.tax, "_y", Elastic.easeOut, 195, 545, 10, false);
}
kglad
Community Expert
Community Expert
November 8, 2008
on the timeline of the movieclip you're trying to reference place:

trace("mc "+this);

and in your btn1.onRelease function instead of trace(mcReference) place:

trace(this);

what's the trace output?
K0raXAuthor
Known Participant
November 10, 2008
I got back:

mc_level0.instance7
mc_level0.tax
_level0.btn1

where tax is the mc i'm talking about... (it doesn't contain any animation, only a bitmap).

Hm.. what does this mean?
Thanks for your reply.