Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm finding it hard to get my head 1

Status
Not open for further replies.

nickpark

Programmer
Jan 17, 2002
517
GB
I'm finding it hard to get my head around Flash.

I want to produce a site, with common design features - ie
embedded movie clips in my main movie, which are data and event driven.

What I find difficult to understand is actionscript and frames.

If I have actionscript on Frame 1 which says
gotoAndPlay(2);
i++;

If it goes to Frame 2, which has no actionscript (or different actionscript), how will i++ be executed. And when will it be - as
frame 2 is played or Frame 1.

Do any good books explain this???

cheers
nick
 
Why are you incrementing i? Are you trying to keep track of frames? Was i ever defined?

Perhaps you could better explain what you are trying to do?

Wow JT that almost looked like you knew what you were doing!
 
I asked a question a while ago, regarding actionscript books. Check out this thread, there's some great feedback here:

thread250-705760

The one I ended up buying, 'ActionScript for Flash 5 - the Definitive Guide' by Colin Moock', was a great help, he also has an MX version.
 
It was a random example. I just need to get the philosophy correct.

I think I understand that the playhead will move to frame 2, the variable i will be incremented and then as the code has finished, the playhead action will be done. (ie move to frame 2)

I'm getting there I think. I've ordered Moock's definitive guide (oreilly) anyway...

Cheers!
 
You know what, I overlooked those. I did a few at flashkit, but i was concentrating on the fancy effects...
Thanks very much!
 
Actionscript.com does have some good tutorials.

This may help you:

Using your example if you want i to increment on each frame you would do the following.

Create a new movie.

Place a key frame on frame 1 and frame 2. Right click the key frame in frame 1 and select "Actions".

In your actions pallette enter:
i=1;

Click on the frame 2 key frame. In the actions pallette enter:
i=++i;
trace(i);


Use Ctrl + Enter to test your movie. What you have done is create a looping movie that counts incrementally indefinitely.

One of the biggest hurdles to understanding for a programmer is the play head. The play head always moves unless you tell it to stop. Once you tell it to stop it remains that way until you tell it to play again.

So as an alternative in your second frame actionscript you could enter the following:
if (i==30){
stop();
}else{
i=++i;
}
trace(i);


This would stop the play head after i reaches 30. Flash movies automatically loop unless you tell them otherwise.

I hope that helps you out a bit.

Good luck!

Wow JT that almost looked like you knew what you were doing!
 
I'd check out that script as posted... Doesn't increment indefinitely, since it loops back to frame 1, where you set it as being 1 again...
 
Thanks!

Old is right. For that script to work as described your first frame action would be:

if (i==null){
i=1;
}

Good Luck!

Wow JT that almost looked like you knew what you were doing!
 
That is good help! I must be getting old.

BUT.... what about the MX fla here:

Why does the dynamic text reset to the Default text ?

AND TRY THIS.... edit the symbol and turn the mask layer into a guide layer. The text is changed fine!???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top