Groups | Blog | Home
all groups > flash actionscript > october 2005 >

flash actionscript : Passing data between screens in a Form App


gatorjoe
10/25/2005 8:52:02 PM
I would think this should be pretty simple, however after searching the
Internet for hours I can't find the answer. If I have two screens, A and B,
how do I pass variables between the two? Also, can I call a function in screen
A from screen B, passing it a parameter? Thanks!
G_Swank
10/25/2005 9:02:23 PM
There are several ways to do this and I just learned of one.

Let's assume you have an input text field called myInput and that is in Frame 1
You have another text field called myOutput and that is in Frame 2.
You want to input some text in Frame 1 and then hit a button and have it go to
frame 2 and show up there.

In Frame 1 create an Action and create a global variable.
_global.myEntry = ""

Now open an Action for the button
on (release) }
_global.myEntry = myInput.text;
gotoAndStop (2);

Now in Frame 2 create another Action and put this there.
myOutput.text = _global.myEntry

That should do it.

unthinkMedia
10/26/2005 3:16:15 AM
rlc5611
10/26/2005 3:34:18 AM
You can either declare variables to be global or you can access variables from
one screen to another following the correct path. If screens are at the same
nesting level (i.e. one is not the child of another), screenA can access the
content of screenB by

this._parent.screenB.varName

where "this" refers to screenA within the context of that screen.
"this._parent" points to the timeline that holds both screenA and screenB where
the reference to screenB can then be found.

You can also drive down from the top (assuming that "presentation" is the name
of the main screen

_root.presentation.screenB.varName

Screens are movie clips and follow the same rules as movie clips in a normal
timeline. Two sibling screens share the timeline of their parent screen (i.e.
movie clip). The "presentation" screen is a movie clip in the _root timeline of
the SWF.

You do not need a localConnection.
AddThis Social Bookmark Button