Be a Supporter!

AS:Starting Out

  • 3,480 Views
  • 21 Replies
New Topic Respond to this Topic
Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
AS:Starting Out 2005-10-27 01:09:52 Reply

@5:/\/\@1|\|!!!!1111
________________
In this tutorial,you will learn a bunch of basic stuff like variables and stop(); actions without to much moving around and asking!Let's start.I'll just go down a list and tell you what each action does.

Timeline Control

gotoAndPlay(#); - gotoAndPlay is used in both buttons to go to certain places and used in frames to go to certain frames.Some people are to lazy to click buttons you know :)

EXAMPLE
on(press){
gotoAndPlay(1);
}

This can be used as a simple 'replay' button in Flash.

EXAMPLE 2
gotoAndPlay(1);

Goes to a certain frame without the use of a button.

Where the number '1' is,you can change to whatever to go to whatever frame you want.

During gotoAndPlay,we're led into the _root. function.You may be trying to use a gotoAndPlay() in a movieclip and find that the button/frame won't do anything but change some stuff.This is where _root. comes in(or _parent).The _root function simply uses something like rooting into something or something...I actually don't know,but it's really easy to use.You can use it to change movieclips or the main timeline from in a movieclip.You can use the _root. function in almost every line of script.

EXAMPLE
on(press){
_root.gotoAndPlay(1);
}

Not to hard :)

EXAMPLE 2
_root.gotoAndPlay(1);

Same thing but inside a frame.

gotoAndStop(#); - Everything with this is the same as gotoAndPlay,except for it stops the main timeline/movieclip instead of letting it keep playing.I usually use this in my codes or for maybe a button.

EXAMPLE
_root.gotoAndStop(1);

This will stop the movie on whichever frame chosen.

EXAMPLE 2
on(press){
_root.gotoAndStop(1);
}

This will stop the frame on whichever frame is chosen after pressing a button.

nextFrame(); - This is a really simple thing.It just goes to the next frame.The cool thing about this specific code,however,is that it can be used as a fast-forward button.

EXAMPLE
on(press){
_root.nextFrame();
}

The 'press' function for the button must be used for this to work.

prevFrame(); - Same thing as the nextFrame,except is goes to the previous frame.It can be used as a rewind button.

EXAMPLE
on(press){
_root.prevFrame();
}

play(); - This is for a simple 'play' button.It can also be used in frames in a movieclip or something.

EXAMPLE
on(press){
_root.play();
}

Simply 'play's your movie.

EXAMPLE 2
_root.play();

Starts playing the movie automatically with no buttons.

nextScene(); - This can be used in a button to get to the next scene.I'm not sure if anyone uses it in the timeline though.It could probably be used as a fast-forward through scenes(aka nextScene button).

EXAMPLE
on(press){
_root.nextScene();
}

Simply goes to the next scene.Change 'press' to 'release' if you want to keep people from a fast-forward.

EXAMPLE 2
_root.nextScene();

Goes to the next scene from a frame in the timeline.

prevScene(); - The same as 'nextScene',just backwards.

EXAMPLE
on(press){
_root.prevScene();
}

Used in a button to go to the previous scene.

EXAMPLE 2
_root.prevScene();

Goes to the previous scene from a frame in the main timeline.Could probably be used for a never ending cartoon(endless loop,just like "Triangles vs. Squares".

stop(); - The name says it alls.This code stops the movie during the timeline.It can be used in buttons and on the main timeline very easily.

EXAMPLE
on(press){
_root.stop();
}

Stops the movie on a button press.Used in movie control a lot.

EXAMPLE 2
root.stop();

Stops the timeline without the use of a button.Used on preloader screens,menu screens,and replay screens a lot.

stopAllSounds(); - This stops all the sounds playing(event started sounds).I usually never use this anymore.It's always used to stop music at the end of a movie or something like that.A lot of movies have event looping clips(short loops from Flashkit or something).Then again,a lot of movies stream the music.It doesn't matter,stopAllSounds(); just stops event clips in my mind.

EXAMPLE
on(press){
stopAllSounds();
}

This will stopAllSounds(); on the press of a button.Notice how _root. isn't there?It isn't needed.

EXAMPLE 2
stopAllSounds();

Really simple.Just stops the sounds on a keyframe.

That ends all I have to say about the main timeline.It should be clear enough now,right?

I'll add in variables and stuff next.(in this thread)


wat a compessor wil raise the volume while lowering the db - chronamut

Blaze
Blaze
  • Member since: Aug. 4, 2005
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to AS:Starting Out 2005-10-27 01:30:21 Reply

Pretty simple, yet, so damn helpful for AS n00bs.

I did know all that, still, great tutorial.

dELtaluca
dELtaluca
  • Member since: Apr. 16, 2004
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to AS:Starting Out 2005-10-27 03:27:24 Reply

ehm, _root isnt a function? otherwise helpful to noobs ;] i think anyways, i didnt bother reading it all


using ShamelessPlug; NapePhysicsEngine.advertise();

BBS Signature
Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS:Starting Out 2005-10-27 04:50:07 Reply

At 10/27/05 03:27 AM, dELta_Luca wrote: ehm, _root isnt a function? otherwise helpful to noobs ;] i think anyways, i didnt bother reading it all

Yeah, wait, so is it a readon property? Nah, can't be...

At 10/27/05 01:30 AM, Darkfire_Blaze wrote: Pretty simple, yet, so damn helpful for AS n00bs.

Not at all, it might be useful for newbs, but not noobs.


BBS Signature
Lucozadedude
Lucozadedude
  • Member since: Jul. 28, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS:Starting Out 2005-10-27 05:17:18 Reply

although even i know all that it will still be helpful for people who have only just gotten flash, i applaud you!

*clap* *clap* *clap*

Gamertag: Medieval Turkey. I also make signatures - PM what you want, and I'll make it.

BBS Signature
Devenger
Devenger
  • Member since: Dec. 24, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS:Starting Out 2005-10-27 05:28:06 Reply

Maybe I'm just an idiot, but I thought that _root was like a movieclip, or at least shares most of it's properties with a movieclip.

It's definitely not a function, anyway. :D

Good tutorial, hopefully another thing we can link newbies to.


I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS:Starting Out 2005-10-27 05:33:35 Reply

_root. is basically everything in your stage. If you say like
_root._x += 5;
It will move every single object(which can be a line, a button, a movieclip, everything!) by 5 pixels.


BBS Signature
Devenger
Devenger
  • Member since: Dec. 24, 2004
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS:Starting Out 2005-10-27 05:37:58 Reply

Toast, was that directed against me? FFS, I know what I can do with _root. :D But it does share properties with movieclips, e.g. _x, _y, _xscale, _rotation (which is very fun to use sometimes), etc.


I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to AS:Starting Out 2005-10-27 07:27:23 Reply

_root is a timeline, that's it.. so Devenger you are right, it shares Movie Clip properties because Movie Clips are timelines too.


Sup, bitches :)

BBS Signature
Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to AS:Starting Out 2005-10-27 08:21:48 Reply

I seem to learn something new every day :)


wat a compessor wil raise the volume while lowering the db - chronamut

Toast
Toast
  • Member since: Apr. 2, 2005
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to AS:Starting Out 2005-10-27 08:24:06 Reply

At 10/27/05 08:21 AM, -Thomas- wrote: I seem to learn something new every day :)

Lol, at least make tutorials after learning those new things :P


BBS Signature
Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS:Starting Out 2005-10-27 08:25:36 Reply

At 10/27/05 08:24 AM, -Toast- wrote:
At 10/27/05 08:21 AM, -Thomas- wrote: I seem to learn something new every day :)
Lol, at least make tutorials after learning those new things :P

Heh you can talk toast you though _currentframe was a function/method


- Matt, Rustyarcade.com

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to AS:Starting Out 2005-10-27 08:27:46 Reply

NC,I think you need to fix up Nightmare Castle a bit,it seems like a really good game,but it came out with a bad score because of glithiness and stuff...

Maybe cut it into separate levels?


wat a compessor wil raise the volume while lowering the db - chronamut

Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS:Starting Out 2005-10-27 08:29:37 Reply

At 10/27/05 08:27 AM, -Thomas- wrote: NC,I think you need to fix up Nightmare Castle a bit,it seems like a really good game,but it came out with a bad score because of glithiness and stuff...

Heh off topic but hey

Yeah unfortunatly I wont be fixing glitches because that game was my work experience for school and I had a week deadline
It wasnt a planned project

Maybe cut it into separate levels?

It is?
Go into doors with SPACE

The game sucks though
Look out for the newest game Cicla and I have made coming very soon (this week)


- Matt, Rustyarcade.com

Thomas
Thomas
  • Member since: Feb. 14, 2005
  • Offline.
Forum Stats
Member
Level 13
Musician
Response to AS:Starting Out 2005-10-29 18:50:51 Reply

Continued-Starting API
____________________
(NOTE:All codes are made in the Action Script menu,press F9 on your keyboard to open it up)

I'm not one that could do to much with API,but I know I could explain the basic parts of it.This post might be short,but whatever.

Explaining API:API is mostly something people use to make KB games,which is trying to keep the KB file size low,which means that they don't use anything but coding,which is API.API can never be animated into a good full length movie(well,good that is...the longest your movie would be is less than 1 second)and is always used for games...most of the time.

EXAMPLE CODE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
endFill();

(copy+paste into first movie frame)-I know it's not a box even though it should be,but it doesn't matter.It's an API code.Lemme explain each code as best I can.

createEmptyMovieClip("t",2) - This creates the movieclip item.It also must start any code that you make in API,otherwise nothing happens.Where "t" is at is the name of the movieclip.In almost all API games,there are at least 2 empty movie clips.Name them well.2 is the depth of the object.I really don't know what this is for,so I just put 2 or 5 in.

lineStyle(5, 000000, 100) - This is creating the lineStyle of you object.The first number is the size of your line(0-10.This is your chance to see what a 100 sized line is like),the second number(or 6 numbers) is the RBG or RGB,whatever is is.When choosing a color for something,a fill,you'll notice the numbers at the top of the fill box(or line box).That 6 part number the RBG.000000 is black,FFFFFF is white,FF0000 is red.There are endless numbers.I usually use black for lines...ok,the last number is the alpha of the line.100 will make the object solid,any lower will make the object start disappearing.

beginFill(0xFF0000, 100) - This,as the code part says,is beginning the fill...as in fills in the object you make with a color.The first number,once again,is the RBG.notice how I added 0x before the number?I dunno if it's needed,but I had to to make the fill appear.The second number...(sigh)...is the alpha.Change it lower to make the object start disappearing.

lineTo(50, 0) - This is the part where your shape will start taking form.The first number is the X value of where the X line goes to.The second number is the same,but deals with Y.

EXAMPLE
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);

This should make a square,but it isn't working,so instead you come out with a butterfly or something...REMEMBER that your object will always start in the top left hand corner.

endFill() - Simple.This will end the first object you make.A better way to say it is \it separates this objects edits from the other objects/

Now,this next part can be done 2 ways...it's for moving your object to where you want it at.

FIRST WAY
The first way you can do with is by using the moveTo code or whatever.

moveTo(0, 0) - This is sorta like lineTo,but instead,it moves the object to the X and Y value places.The first number is for moving the object to a selected X place,and the second number is moving it to the Y place.

EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
moveTo(345, 200);
endFill();

I can never get moveTo to work,but I'm pretty sure that this would be the code.

SECOND WAY
The second way is simple.It's just saying something like \_x = 300/ or something.

EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
_x = 225;
_y = 200;
endFill();

Notice how the object moved close to the center of the stage or something?I like to use this way better.

I know there are more ways to use API,but I can't figure any of them out.

Final note:With API,you can create platforms and stuff without to much trouble.It's mostly just adding the script to the objects edit and changing it a bit to make it work.When making a platform,however,you need to make another movieclip to be the platform.

Well,that's all!(I'll post a new post for helping out in a bit day or 2...or more)


wat a compessor wil raise the volume while lowering the db - chronamut

Rustygames
Rustygames
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to AS:Starting Out 2005-10-29 18:58:45 Reply

Wait what??
I thought...
Okay im confused


- Matt, Rustyarcade.com

kingofnopants
kingofnopants
  • Member since: Dec. 22, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS:Starting Out 2006-08-07 07:16:44 Reply

gud tut i can make click and point games now

sniffy-gerbil
sniffy-gerbil
  • Member since: Apr. 14, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS:Starting Out 2007-03-31 16:36:32 Reply

what kind of object / data type does the MovieClip.gotoAndStop() method base it's argument on?

sniffy-gerbil
sniffy-gerbil
  • Member since: Apr. 14, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS:Starting Out 2007-04-01 07:40:01 Reply

Anyone?

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS:Starting Out 2007-04-01 07:46:10 Reply

The actual type is 'Object -> Number', the first argument being either a string (for scenes, requires the second parameter) or a number (for the current scene). 'Object' is the base class of AS and any other type is a subclass to it.


BBS Signature
sniffy-gerbil
sniffy-gerbil
  • Member since: Apr. 14, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS:Starting Out 2007-04-01 07:57:33 Reply

Thanks,
And yes, I know 'Object' is the dominant class of AS, but an object is and instance of a class.

I've come to realize that my probably is actually part of my variable being undefined, yet i assigned a value.

cmac458
cmac458
  • Member since: Aug. 22, 2007
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS:Starting Out 2008-01-12 18:48:59 Reply

hey really good tutorial usually the stuff people leave out when doin tutorials and just expect you to know well done