Fraggs
July 13, 2004, 1:05pm
1
I have a mc within a mc, on this inner mc I have the following code, I know it works as when I use the trace command I get an output, but when I replace trace with a function, nothing happens, anyone able to help?
onClipEvent(load) {
this._rotation += 20;
origWidth = _root.myRotation._width;
origHeight = _root.myRotation._height;
}
}onClipEvent(enterFrame) {
if(Key.getCode() == Key.UP) {
_root.myRotation._xscale += 5;
_root.myRotation._yscale += 5;
}else if(Key.getCode() == Key.DOWN) {
_root.myRotation._xscale -= 5;
_root.myRotation._yscale -= 5;
}
}
Regards,
system
July 13, 2004, 3:16pm
2
I don’t know if you noticed that extra close bracket there beside the onClipEvent (enterFrame) {, that may or may not be your problem.
Also, it would be more efficient if you had a listener for the keys instead of an enterFrame:
keyListener = {}; // initiate object
keyListener.onKeyUp = function () {
if(Key.getCode() == Key.UP) {
_root.myRotation._xscale += 5;
_root.myRotation._yscale += 5;
}else if(Key.getCode() == Key.DOWN) {
_root.myRotation._xscale -= 5;
_root.myRotation._yscale -= 5;
}
};
Key.addListener(keyListener);
all of which you would simply place inside the onClipEvent (load).
But that aside, what’s the function you’re trying to replace the trace with?
system
July 13, 2004, 7:35pm
3
I know my code works because have tested it using the trace command and when I press the up key I get the relevant output. Yet when I replace trace with the above code for scaling the clip, nothing happens. It’s really odd.
Regards,
system
July 13, 2004, 7:44pm
4
do a trace(_root.myRotation) and see what it outputs. If it says “undefined” you’ll need to find out what that clip is called.
system
July 13, 2004, 9:27pm
5
the clip is called “myRotation”
system
July 13, 2004, 9:33pm
6
did you actually try the trace? or are you just saying that?
system
July 13, 2004, 9:36pm
7
thats the name of the clip I am trying to manipulate.
system
July 13, 2004, 9:37pm
8
yes, but replace the scaling code with trace(_root.myRotation) and see if it even recognizes the clip you’re trying to manipulate.
system
July 13, 2004, 9:42pm
9
I owe you an apology (sorry) I was trying to be clever (with me thats never a good idea). When I did try it, the trace came up undefined.
system
July 13, 2004, 9:48pm
10
no problem. find out what that clip is called and you should be good.
system
July 13, 2004, 9:48pm
11
I think I know whats wrong.
system
July 13, 2004, 9:58pm
13
What I have is a clip (MC name = Circle) with the instance name myCircle, then inside that mc is another mc called myRotation, I’m looking to rotate this clip by said amount per frame. When I tried using _root.myCircle.myRotation += 5; and _root.Circle._myRotation += 5; and did that trace thing you told me, it still came up undefined.
system
July 13, 2004, 10:16pm
14
Well, if Circle is on the root, and myRotation is inside Circle, this should be valid:
trace(_root.Circle.myRotation);
and not output undefined.
However, if the code you posted above is contained in Circle, all you need to do is refer to myRotation as myRotation, no need for _root.