On-Click Animation Not Working

Most likely due to ActionScript Error

Page 1 of 1

3 Replies - 2707 Views - Last Post: 11 May 2010 - 01:29 PM

#1 Cbeppe   User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 216
  • Joined: 16-September 09

On-Click Animation Not Working

Posted 11 May 2010 - 10:51 AM

Hello,

This is the first time I'm trying anything in Flash. With only a very basic understanding of how things work, I am trying to create an app where I will have a series of pictures in a row, and once a picture is clicked, it will zoom to the front. The animation is set and done, but creating the on-click event seems to be harder.

So far, I have the following piece of actionscript attached to the "Symbol" that is the picture I want to zoom.

Catcher.addEventListener(MouseEvent.rollOver, zoom);
function zoom(event:MouseEvent) { gotoAndPlay(1); }



The problem is basically, that when I click the image in the preview, nothing happens. I realize this is not much to go on, but it's as much as I understand.

Thanks for your patience.

This post has been edited by Cbeppe: 11 May 2010 - 10:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: On-Click Animation Not Working

#2 maxrock   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 70
  • Joined: 13-September 09

Re: On-Click Animation Not Working

Posted 11 May 2010 - 11:22 AM

Suppose "slideImage1" is the name of the movieclip that you want to zoom on click then
- add a mouseEvent.CLICK event listener on "slideImage1".
- in the event handler function use the scaleX and scaleY properties on "slideImage1" to zoom the image.

Hope this helps. Cheers :wink:
Was This Post Helpful? 1
  • +
  • -

#3 Cbeppe   User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 216
  • Joined: 16-September 09

Re: On-Click Animation Not Working

Posted 11 May 2010 - 12:34 PM

Thanks for looking into it, Maxrock.

The scaling works, but to replace the animation I had to get rid of, I would like it to scale smoothly. Is there any way I can do this in the script?

Also, I will need to move the picture slightly, and I can't get the .move method to work.
Code:
Catcher.addEventListener(MouseEvent.CLICK, zoom);
function zoom(event:MouseEvent) { 
Catcher.scaleX = 3;
Catcher.scaleY = 3;
Catcher.move(20,40); 
stop();
}



The scaling works fine, although it should be smooth. However, I receive this error saying that move is not a function:

Quote

TypeError: Error #1006: move is not a function.
at Flash_fla::MainTimeline/zoom()


Any ideas?

EDIT:
I have also tried this, which gives me the same error:
Catcher.move(Catcher.x + 10, Catcher.y + 50);


Thanks again, the above post really helped.

This post has been edited by Cbeppe: 11 May 2010 - 12:37 PM

Was This Post Helpful? 0
  • +
  • -

#4 maxrock   User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 70
  • Joined: 13-September 09

Re: On-Click Animation Not Working

Posted 11 May 2010 - 01:29 PM

for smooth transitions you need to do some "tweening". Research on Tween classes available in Flash.

You need to import these classes.

import fl.transitions.Tween;
import fl.transitions.easing.*;

Also let me give you a line of code sample for tweening.

var myTween:Tween = new Tween(this, "scaleX", Regular.easeOut, 1,1.5, 1, true);


The error you are getting is because there is no move function in flash for the movieclips.

Either you have to write that method yourself or use alternatives to achieve that.

Again tweening can be used here.

The above line of code was used to tween the scaling.

You can similiarly tween "x" and "y" property of the movieclip along with "scaleX" and "scaleY" to get the effect you need.

Thus you will need 4 tween statements all-together.

That should do the trick.

Cheers :wink:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1