Skip to main content
Known Participant
June 8, 2009
Answered

Error message 1056 and image on top of image problem

  • June 8, 2009
  • 1 reply
  • 832 views

I am trying to place a button on the screen and make it spin when mouse_over (which will be one of mutiple buttons with different instance names. ) The code I wrote is putting  2 colorwheels on the screen, one on top of the other, I can see the bottom one is spinning but I can't seem to figure out why the top one is there.

But then, I get a error code message 1056 with no compile errors when I mouse over the dial:ReferenceError: Error #1056: Cannot create property rotation on builtin.as$0.MethodClosure.
    at fl.transitions::Tween/setPosition()
    at fl.transitions::Tween/set position()
    at fl.transitions::Tween()
    at Colorwheel/rotateKids()

I am pretty new at as3 so thanks for your patience!  I have been trying to figure this out for days!!!  I am guessing that I have to import a class, but don't know what.

here is my code

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;

static_mc.play();

var kids_btn = new Cwcopy_mc;
addChild(kids_btn);
kids_btn.x = 745.1;
kids_btn.y = 122.2;
kids_btn.height = 100;
kids_btn.width = 100;
kids_btn.addEventListener(MouseEvent.MOUSE_OVER, rotateKids);
    function rotateKids(e:MouseEvent):void  {
    var spin:Tween = new Tween(rotateKids, "rotation", Strong.easeInOut, 0, 360, 5, true);
}

This topic has been closed for replies.
Correct answer Ned Murphy

You need to specify the target object in the Tween code, not the function call...

var spin:Tween = new Tween(kids_btn, "rotation", Strong.easeInOut, 0, 360, 5, true);

Once you change that, see what else kicks up, if anything.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Brainiac
June 8, 2009

You need to specify the target object in the Tween code, not the function call...

var spin:Tween = new Tween(kids_btn, "rotation", Strong.easeInOut, 0, 360, 5, true);

Once you change that, see what else kicks up, if anything.

schugabugAuthor
Known Participant
June 8, 2009

ok, i changed that, now it looks like nothing is happening when its moused over, but I don't get any error messages.

Previously it has worked sparatically, i have changed the code so many times I am not sure what is what at this point!

So I just added this code:

kids_btn.addEventListener(MouseEvent.MOUSE_DOWN, goSlide);
    function goSlide(e:MouseEvent):void  {
        gotoAndStop("slide")
    }

Now, when I click on the dial  it goes to the "slide" frame and then the top dial will spin and it appears to have another dial underneath it  (I see this becuz the dial isn't symetrical and spins a bit crooked)

i want the dial to spin continuously when I mouse over it before I click on it.

here's the complete code

import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.Event;

static_mc.play();

var kids_btn = new Cwcopy_mc;
addChild(kids_btn);
kids_btn.x = 745.1;
kids_btn.y = 122.2;
kids_btn.height = 100;
kids_btn.width = 100;
kids_btn.addEventListener(MouseEvent.MOUSE_OVER, rotateKids);
    function rotateKids(e:MouseEvent):void  {
    var spin:Tween = new Tween(kids_btn, "rotation", Strong.easeInOut, 0, 360, 5, true);
}
kids_btn.addEventListener(MouseEvent.MOUSE_DOWN, goSlide);
    function goSlide(e:MouseEvent):void  {
        gotoAndStop("slide")
    }

Ned Murphy
Brainiac
June 8, 2009

I took your code and created a simple test file for it using just the Cwcopy_mc class object and the MOUSE_OVER function.  It functions okay as is, so there has to be something else at work (or not at work).  Due to the easing, it starts off very slowly (in case you aren't hovering long enough).  I wasn't sure about using 0 to 360 because rotation values go from -180 to 180, but it turns the full rotation.

If you want it to rotate continuously while hovering, you don't want to use a Tween.  The tween will end after the 5 second duration, and if you restart it, it will start and stop slowly for each tween.  You could approach it differently such as with the example below...

kids_btn.addEventListener(MouseEvent.MOUSE_OVER, rotateKids);
kids_btn.addEventListener(MouseEvent.MOUSE_OUT, stopIt);

function spinIt(evt:Event):void {
evt.currentTarget.rotation += 5;
}

function stopIt(evt:Event):void {
kids_btn.removeEventListener(Event.ENTER_FRAME, spinIt);
}

function rotateKids(e:MouseEvent):void  {
    kids_btn.addEventListener(Event.ENTER_FRAME, spinIt);
}

If you want it to slow to a stop, you might be able to add a Tween for the mouse out function, or otherwise dampen the rate of rotation somehow before removing the enter frame listener.