Whats wrong w/ this Flash Code?

SpellZ

Regular Member
Joined
Feb 8, 2009
Messages
358
Reaction score
292
5 Thumbs
5 pictures

When I click on the third thumb... for example
third picture appears.. well thats how it suppose to work
but for some reason when I test movie it like 'skips' the STOP action and goes on

.. doesn't work

but it says there are no errors..
stop();


button1.addEventListener(MouseEvent.CLICK,showpic1);
button1.addEventListener(MouseEvent.CLICK,showpic2);
button1.addEventListener(MouseEvent.CLICK,showpic3);
button1.addEventListener(MouseEvent.CLICK,showpic4);
button1.addEventListener(MouseEvent.CLICK,showpic5);

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic1");
}

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic2");
}

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic3");
}

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic4");
}

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic5");
}
 
import the event classes
It's not "function" but "private function" or "public function"
The event listeners have nothing assigned to them.
No objects are declared.
On and on and on.
 
Okay, so I figured it out! [finally!]

Thank you so much guys!

Here is the final code: (Silly mistakes that I made)

stop();


button1.addEventListener(MouseEvent.CLICK,showpic1);
button2.addEventListener(MouseEvent.CLICK,showpic2);
button3.addEventListener(MouseEvent.CLICK,showpic3);
button4.addEventListener(MouseEvent.CLICK,showpic4);
button5.addEventListener(MouseEvent.CLICK,showpic5);

function showpic1(Event:MouseEvent):void{
gotoAndStop("pic1");
}

function showpic2(Event:MouseEvent):void{
gotoAndStop("pic2");
}

function showpic3(Event:MouseEvent):void{
gotoAndStop("pic3");
}

function showpic4(Event:MouseEvent):void{
gotoAndStop("pic4");
}

function showpic5(Event:MouseEvent):void{
gotoAndStop("pic5");
}

My NEW QUESTION IS:

Let's say you click on Button #3, and image #3 appears, how do I make it so that after 12 seconds without clicking on nothing it'll go to image #4, and 12 seconds later to image #5, 12 seconds later back to image #1 and so on
 
Yeah, I found this code

stop();
function goNext(){
currentSlide.gotoNextSlide();
clearInterval(timer);
}
var timer = setInterval(goNext, 10);

To be added to each slide

But didn't work.. I'll look for more codes
 
I'll try this

  1. var timer:Timer = new Timer(5000);
  2. timer.addEventListener(TimerEvent.TIMER, onTimer);
  3. timer.start();
  4. function onTimer(evt:TimerEvent):void {
  5. gotoAndPlay("next_frame");
  6. }
 
Balls!

Giving me an error -_-

picture15cw.png
 
you forgot the right brace as stated by the compiler...first learn to copy/paste, then ask for help bro :D
 
On Keyframe 1
When I put

var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
function onTimer(evt:TimerEvent):void {
gotoAndPlay("pic2");
}

It works (yeah, I added the rightbrace lol)

But when I add the same thing to Keyframe 2, 3, 4 and 5 and obvs. change the Pic2 to pic3,4,5, etc

It gives me errors when I "test movie"

What might be the problem? (I can screen shot the error if anything)
 
Back
Top