You have to imagine that different scenes are very similar to individual films, and the flash has problems with sharing.
The right way to do this is to start using OOP (Object Oriented Programming) AS3. You will need to create something called a document class. This is an efficient code that lives forever behind the scenes (no pun intended). You can store things in this class and read them later when you want.
Its easier than it seems, and after setting it up - this will allow you to start moving the code from your timeline.
First create a file called "DocumentClass.as". You can really call it anything, but calling it is a very good practice.
Save this file in the same place as the FLA you are working with - in the same folder.
In CS3 - in the properties panel at the bottom of the screen - when you select a scene, a small field will appear allowing you to enter the document class name in it. Enter the name of the file you just made "DocumentClass" * without the .as extension. - click the link if you donβt know where exactly you need to enter.
http://curtismorley.com/wp-content/uploads/2007/07/documentclasspath_bad.JPG
Pay attention to capitlization is good practice
Open this file in Flash and write the following code. Exactly how i write it
DocumentClass.as
package {
You can see inside all the guff that I write for you. I have a variable called myName. You can create what you want. myAge ... textToBeInAllScenes ... girlfriendsWeightToday ... Call then something.
Further explanation
A class is a block of code that is created in memory when necessary. DocumentClass is that, but it is completely up to your application.
The package - just freaky as3 says it "put it in a box" - it may become more advanced, but that is jist.
the DocumentClass class extends MovieClip - you say flash "my class is called DocumentClass" - this extends something called MovieClip.
MovieClip is a class exactly the same as yours, but made for you and residing inside flash memory. This contains a lot of code for the animation to work. Your Flash scene itself is just the visible version of this MovieClip thing.
you need to extend this class because you pretty much want to [in fake] copy paste all the finished code and use it in your DocumentClass. You are now expanding MovieClip and so your code is stacked on top of existing material.
public function DocumentClass () - yes, this is a function. But it is called "construction." This is a special type of function that lives inside a class. Firstly, it has the same name. This allows Flash to easily find it. Its special task is to instantly run its code automatically when this class is created and seen in a flash. All automatic see ....
The important part for you is the public var , which I added. This is a bucket in which you can store your information.
The public part reports flash, everyone can see it, if they want, scenes, other classes ... people on the street - nothing!
String: after the name of the variable (or bucket), which indicates what information will be stored inside var. This is not an application that matters, but for good OOP code - do it. (listing of Google variable AS3)
There are many types var, String, Number, int, Boolean, etc. about 7 major.
I think the answer is enough for StackOverflow - it will work -
Most errors will be warned - your spelling mistakes ... Flash doesn't like spelling mistakes.
Enjoy it!