0

thanks for reading. I have a small animation in Flash that is scripted to enable the eyes to follow the mouse. This further animates upwards on mouse click, but the eyes that are scripted do not follow the tween. I have childed/ embedded the eyes objects inside the main animating layer but this also seems to NOT follow. I'm a bit confused and expect I have missed some fundamental structural/ layering issue -but I'm at a bit of a loss and am concerned if it is not me, then is it a bug or something in Flash and scripted layers working together or something:(

Anyway, I enclose the actual .fla and the .swf in vain of any help that you wonderful dudes can pass down to me.

https://drive.google.com/open?id=0B4yGmvZlwZmWanJJX1IzTk5pYXM

I would really love to know why and what if there is something I have fundamentally missed here. (I haven't checked for AS3 in the Symbol conversion Advanced options dialogue for the eye instance, but this has not effected the interactive eye part and I suspect it shouldn't be the cause of the conflict as a result - happy to be wrong here though of course :)) Edit: Here is the code for the project {which started out as a youtube tut showing how to control a circular movement of some eye objects with the mouseMove event }

//this is an action script window
//we  can code into here :)
this.stop();
this.loop = false;

stage.addEventListener(MouseEvent.MOUSE_MOVE, MoveEyes);
stage.addEventListener(MouseEvent.MOUSE_DOWN, PlayTimeline);


function MoveEyes(e:MouseEvent): void
{
   var mouseYPosition = mouseY - EyeR.y;
   var mouseXPosition = mouseX - EyeR.x;
   var radiusR = Math.atan2(mouseYPosition, mouseXPosition);
   var degreesR = radiusR / (Math.PI / 180);
   EyeR.rotation = degreesR;

   mouseYPosition = mouseY - EyeL.y;
   mouseXPosition = mouseX - EyeL.x;
   var radiusL = Math.atan2(mouseYPosition, mouseXPosition);
   var degreesL = radiusL / (Math.PI / 180);
   EyeL.rotation = degreesL;
}

//when clicked start the animation
function PlayTimeline(e: MouseEvent) : void
{
   this.play(); 
}

...In fairness, and I am totally happy to be wrong of course but, I don't think the code is causing or has anything to do with the fault, it may be more my stage layer positions or something along those lines, hence the full .fla file for someone better than me to point out my mistake.

Cheers all and thanks again for reading and taking the time here. :) Gruffy

gruffy321
  • 175
  • 2
  • 13
  • 2
    Can we have some code or something? – Glitcher Jun 07 '16 at 11:32
  • Hey Glitcher, Yeah sure. But the complete .fla with code is on the provided link... However. I make a quick edit here too to show the code :) Just have to swap machines a sec :) – gruffy321 Jun 07 '16 at 16:28
  • Interestingly, on here I have discovered a question relating to my issue, I will repost the link here, but my issue remains unsolved. However, with this I might get somewhere and it may help others to find quicker. – gruffy321 Jun 07 '16 at 18:10
  • Further to this I have now changed my tact a little and moved into pure scripting as there appears to be a major issue between an object's control code and taking advantage of the timeline to animate it simultaneously. The issue is till not resolved but now I have much more control over positional outcomes. – gruffy321 Jun 07 '16 at 19:53

1 Answers1

1

That's actually a very interesting bug. I believe what's happening is that by interacting with the Eyes' properties, you're removing it from the timeline tween.

Your best bet would be to simply remake the timeline tween in code like so:

function PlayTimeline(e: MouseEvent) : void
{
    this.play();
    new Tween(EyeL, "y", fl.transitions.easing.None.easeInOut, EyeL.y, 141.95, 100);
    new Tween(EyeR, "y", fl.transitions.easing.None.easeInOut, EyeR.y, 141.95, 100);

}

This gives the affect you need. However if you start messing with the timeline animation you will need to change the tween, so perhaps it would be best to move all the tweening code side?

EDIT: I notice that the eyes don't animate whilst the bird is moving unless you continue to move the mouse. The solution for this would be to change the mouseEvent listener to an enterframe listener so that it will happen every frame regardless of whether the mouse is moving or not. That's not the best solution, as it's a bit overkill, but to do anything else would likely involve some timers or third part libraries, which I don't think are strictly necessary at this point

Glitcher
  • 1,078
  • 6
  • 14