Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Movie Clip Help- Actionscript help

(162 views • 17 replies)

This topic is 1 page long.

<< < > >>
None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 08:07 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

I need code for.....
I want to be able to push the arrow keys to move back and forth one frame in my movie clip
example.....
if(Key.isDown(Key.LEFT)){
(move ahead 1 frame on moveclip time line)------ this is where I need the code

and then if I get to the last frame of that movie clip timeline can I make it go to the first frame and viseversa?

Any help would be great


None

PyroflameProductions

Reply To Post Reply & Quote

Posted at: 12/28/07 08:14 PM

PyroflameProductions NEUTRAL LEVEL 09

Sign-Up: 08/04/07

Posts: 1,957

This?

onClipEvent (enterFrame){
if(Key.isDown(Key.LEFT)){
_root.nextFrame();
}
}

Free .fla's are currently down.

BBS Signature

None

El-Presidente

Reply To Post Reply & Quote

Posted at: 12/28/07 08:15 PM

El-Presidente LIGHT LEVEL 23

Sign-Up: 06/02/05

Posts: 4,372

onClipEvent(load){
a = true;
b = true;
}

onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){
if(a == true){
a = false;
gotoAndStop(_currentframe - 1);
}
} else {
a = true;
} else
if(Key.isDown(Key.RIGHT)){
if(b == true){
b = false;
gotoAndStop(_currentframe + 1);
}
} else {
b = true;
}
}

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
AS: Main || AS3: Main || CampNorth || FAB: Warning! Only for real men.

BBS Signature

None

DrJam

Reply To Post Reply & Quote

Posted at: 12/28/07 08:17 PM

DrJam LIGHT LEVEL 35

Sign-Up: 12/20/04

Posts: 23

onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe == this._totalframes) {
gotoAndStop(1);
} else {
this.nextFrame();
}
}
}


None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 08:22 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

I m writing the code on the main timeline on frame 1 but I want to switch between the frames on the movie clip I made. IS this the right code for that?


None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 08:50 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

At 12/28/07 08:15 PM, El-Presidente wrote: onClipEvent(load){
a = true;
b = true;
}

onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){
if(a == true){
a = false;
gotoAndStop(_currentframe - 1);
}
} else {
a = true;
} else
if(Key.isDown(Key.RIGHT)){
if(b == true){
b = false;
gotoAndStop(_currentframe + 1);
}
} else {
b = true;
}
}

There is a error with one of your "if" statements,


None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 08:52 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

this is the error message

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 14: 'else' encountered without matching 'if'
} else {


None

gorman2001

Reply To Post Reply & Quote

Posted at: 12/28/07 09:12 PM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,850

At 12/28/07 08:22 PM, aonefischer wrote: I m writing the code on the main timeline on frame 1 but I want to switch between the frames on the movie clip I made. IS this the right code for that?
YOURMCNAMEHERE.a = true;
YOURMCNAMEHERE.b = true;

YOURMCNAMEHERE.onEnterFrame=function(){

if(Key.isDown(Key.LEFT)){
if(a == true){
a = false;
gotoAndStop(_currentframe - 1);
}
} else {
a = true;
} 

if(Key.isDown(Key.RIGHT)){
if(b == true){
b = false;
gotoAndStop(_currentframe + 1);
}
} else {
b = true;
}

}

put this code on your frame, and replace YOURMCNAMEHERE with the linkage ID of your MC


None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 09:26 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

thankx


None

El-Presidente

Reply To Post Reply & Quote

Posted at: 12/28/07 09:30 PM

El-Presidente LIGHT LEVEL 23

Sign-Up: 06/02/05

Posts: 4,372

There is a error with one of your "if" statements,

Yeah, sorry about that, I put an } else { and then an } else...you should just get rid of the } else { and move it to the end where the other } else { is. Then it will work. Anyways, you should try and learn how to do ACTIONSCRIPT yourself and not just take it off of Newgrounds.com.

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
AS: Main || AS3: Main || CampNorth || FAB: Warning! Only for real men.

BBS Signature

None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 09:41 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

that code didnt work, it only takes me to a different frame on my main time line, i want to go to a different frame of my movieclip time line.


None

El-Presidente

Reply To Post Reply & Quote

Posted at: 12/28/07 09:43 PM

El-Presidente LIGHT LEVEL 23

Sign-Up: 06/02/05

Posts: 4,372

At 12/28/07 09:41 PM, aonefischer wrote: that code didnt work, it only takes me to a different frame on my main time line, i want to go to a different frame of my movieclip time line.

Don't be an idiot. You have to do at least SOME things yourself. I wrote the script really quickly in a post. You might want to learn to be at least a little bit self-dependant and not totally rely on everyone elses stuff. "this." accesses it within the movieclip and you probably did it totally wrong when you put it in. Sorry for the tiny mistake you aren't able to fix.

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
AS: Main || AS3: Main || CampNorth || FAB: Warning! Only for real men.

BBS Signature

None

gorman2001

Reply To Post Reply & Quote

Posted at: 12/28/07 09:45 PM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,850

then replace the second part with this one:

YOURMCNAMEHERE.onEnterFrame=function(){

if(Key.isDown(Key.LEFT)){
if(a == true){
a = false;
this.gotoAndStop(this._currentframe - 1);
}
} else {
a = true;
} else if(Key.isDown(Key.RIGHT)){
if(b == true){
b = false;
this.gotoAndStop(this._currentframe + 1);
}
} else {
b = true;
}

}

None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 09:46 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

wooo buddy chill out just tring to get a little help here. I m totally new to actionscript. I m learning the basics.


None

gorman2001

Reply To Post Reply & Quote

Posted at: 12/28/07 09:50 PM

gorman2001 NEUTRAL LEVEL 14

Sign-Up: 08/18/02

Posts: 1,850

At 12/28/07 09:46 PM, aonefischer wrote: wooo buddy chill out just tring to get a little help here. I m totally new to actionscript. I m learning the basics.

did you read the sticky on the flash forum index ? ("Read this first!")


None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/28/07 09:56 PM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

here the thing your code didnt work when I put it into frame 1 of the main time line. I deleted it then put it on the movie clip instance on the stage and deleted the pill.a = true and pill.b = true and then it worked. The thing is I want that code to work for every piece on the stage that appears, think of tetris. So it needs that function. I also want to be able to go from the last frame in the movieclip timeline back to the front using the same arrow key so it keeps cycling through. Is that possible?


None

El-Presidente

Reply To Post Reply & Quote

Posted at: 12/28/07 11:47 PM

El-Presidente LIGHT LEVEL 23

Sign-Up: 06/02/05

Posts: 4,372

No see it was supposed to be in the movieclip:

onClipEvent(load){
var a:Boolean = false;
var b:Boolean = false;
}

onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
if(a == false){
a = true;
this.gotoAndStop(_currentframe + 1); //or nextFrame();
}
} else
if(Key.isDown(Key.LEFT)){
if(b == false){
b = true;
this.gotoAndStop(_currentframe - 1); //or preFrame();
}
} else {
a = false;
b = false;
}
}

MY E-PENIS IS BIGGER THAN YOURS
8=================================>
AS: Main || AS3: Main || CampNorth || FAB: Warning! Only for real men.

BBS Signature

None

aonefischer

Reply To Post Reply & Quote

Posted at: 12/29/07 11:33 AM

aonefischer NEUTRAL LEVEL 05

Sign-Up: 09/23/07

Posts: 85

Yea that worked. My next thing I want to do is be able to go from the last frame of the movie clip to the first frame. Is that possible. So I can cycle right through. I also want to be able to go from the first frame to the last using the same arrow keys. Thanx for the help


All times are Eastern Daylight Time (GMT -4) | Current Time: 11:23 PM

<< 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!