Forum Topic: One Frame Programming

(109 views • 6 replies)

This topic is 1 page long.

<< < > >>
None

serthigh

Reply To Post Reply & Quote

Posted at: 7/16/09 07:56 PM

serthigh LIGHT LEVEL 11

Sign-Up: 07/10/08

Posts: 21

Hi everyone. I'm working on a quiz, but I need some help with some programming. There is this frame I'm trying to program, but I can't get it to work. What I want to do is to have this one frame wait a couple of seconds and then proceed to the next frame. In other words, pause the frame for a certain time. How can I do this? Here's my code that I have so far. This is AS 3.0, CS3 Professional.
.
stop();
var i:Number = 0;

while(i<5000) {
gotoAndStop(350);
i++;
a100.addEventListener(MouseEvent.MOUSE_D OWN,
aa100);
function aa100(event:MouseEvent):void {
gotoAndStop(340);
}
}

gotoAndStop(351);
.
There are no errors in this simple program. Assume that the packages and imports are correct as follows.


Questioning

kylelyk

Reply To Post Reply & Quote

Posted at: 7/16/09 09:01 PM

kylelyk LIGHT LEVEL 10

Sign-Up: 05/15/08

Posts: 490

I'm kind of new to as3 but...
is it ok to have an event function inside a while function?
i never tried it before in as2 or as3, but it seems kind of unnecessary to put it in there anyway.

Kylelyk: Forwards and Backwards, Over and Out.

BBS Signature

None

UknownXL

Reply To Post Reply & Quote

Posted at: 7/16/09 09:14 PM

UknownXL EVIL LEVEL 10

Sign-Up: 05/22/05

Posts: 1,335

Ive never used as3 but maybe you need to add
on EnterFrame = function (){
at the top. So it knows its a function.


None

onezerothrice

Reply To Post Reply & Quote

Posted at: 7/16/09 09:15 PM

onezerothrice NEUTRAL LEVEL 01

Sign-Up: 07/16/09

Posts: 30

K, lotta things wrong with this from an OOP perspective, but we'll get them solved. :)

stop();
var timer:Timer = new Timer(1000, 1);  // First parameter milliseconds, the second repeats

a100.addEventListener(MouseEvent.MOUSE_DOWN, onA100MouseDown);

timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
timer.start();

function onTimerComplete(event:TimerEvent):void
{
     timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
     a100.removeEventListener(MouseEvent.MOUSE_DOWN, onA100MouseDown);
     gotoAndStop(351);
}

function onA100MouseDown(event:MouseEvent):void
{
     timer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
     a100.removeEventListener(MouseEvent.MOUSE_DOWN, onA100MouseDown);
     gotoAndStop(340);
}

None

serthigh

Reply To Post Reply & Quote

Posted at: 7/16/09 09:56 PM

serthigh LIGHT LEVEL 11

Sign-Up: 07/10/08

Posts: 21

I'll go ahead and try these tips. Thanks for your help guys. I'll let you know on the status to see if it works or not.


None

ShirkDeio

Reply To Post Reply & Quote

Posted at: 7/16/09 10:50 PM

ShirkDeio LIGHT LEVEL 16

Sign-Up: 03/29/07

Posts: 989

All it looks like your code is doing is setting an event handler 5000 times in one frame :\

I am a servant of the Most High God
The Hanging Collab || The Legend of Newgrounds (Game) || Crystal Rays (Song)


None

serthigh

Reply To Post Reply & Quote

Posted at: 7/16/09 11:04 PM

serthigh LIGHT LEVEL 11

Sign-Up: 07/10/08

Posts: 21

Hey it works now. Thanks onezerothrice for the huge help that you gave me, as well as the others who helped contribute to my coding as well. Now I can move on to the next step. =)


All times are Eastern Standard Time (GMT -5) | Current Time: 10:07 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!