Simple scaling problem

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,

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?

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,

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.

the clip is called “myRotation”

did you actually try the trace? or are you just saying that?

thats the name of the clip I am trying to manipulate.

yes, but replace the scaling code with trace(_root.myRotation) and see if it even recognizes the clip you’re trying to manipulate.

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.

no problem. find out what that clip is called and you should be good.

I think I know whats wrong.

nope, still undefined :stuck_out_tongue:

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.

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.