2 Replies - 2521 Views - Last Post: 03 December 2010 - 10:41 AM

#1 ali_mabey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-December 10

mouse over, press etc. code problems with button in flash

Posted 03 December 2010 - 08:26 AM

Hello I am currently designing a website for my school project and i'm having problems with creating a button in flash. (I'm sure this is really easy but I'm a newbie) The movie clip just plays and loops - it doesn't act like a button should.

I am also receiving an error every time I publish the movie, which is:

Scene 1, Layer 'Layer 1', Frame 1, Line 1 1086: Syntax error: expecting semicolon before leftbrace.


Here is my code for the button:

on (rollOver) {
this.gotoAndPlay("over");
}
on (rollOut) {
this.gotoAndPlay("leave");
}
on (press) {
this.gotoAndPlay("press");
}
on (release) {
this.gotoAndPlay("release");
}
on (releaseOutside) {
this.gotoAndPlay("leave");
}


Help would be much appreciated!!

Thanks :)

Is This A Good Question/Topic? 0
  • +

Replies To: mouse over, press etc. code problems with button in flash

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,148
  • Joined: 07-September 06

Re: mouse over, press etc. code problems with button in flash

Posted 03 December 2010 - 09:57 AM

Well, you didn't say which version of the language you are using so I am going to assume that you are using AS3, at which point you can't attempt to do functions like that. Instead you need to add event listeners which are waiting for a specific event to fire like so:

import flash.events.MouseEvent;
addEventListener(MouseEvent.MOUSE_DOWN, press);

function press(e:MouseEvent):void{
  e.target.gotoAndStop("press");
}


And you would do that for each of your events you want to be listened for.

Hope that helps.
Was This Post Helpful? 0
  • +
  • -

#3 ali_mabey  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 03-December 10

Re: mouse over, press etc. code problems with button in flash

Posted 03 December 2010 - 10:41 AM

Hey thanks for the reply but I actually fixed it in the end!
I was using AS3 and for some reason in the main timeline it was set to AS2. Duh!

Thanks for help though :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1