I am struggling to find a solution to a shared object problem. I am trying to push data without a user having to enter anything into a text field. My goal is for a user to start on a home page swf, click on a link taking them to another swf. Once the user clicks through this other swf they encounter a "Return to Menu" button. When the user clicks on the Return to Menu button a bit of data (number or letter I preselect) is written to a sharedobject. When the user re-enters the Main swf that number or letter from the other screen is displayed. I am using this to indicate to the user that they have already visited this screen. There will be many screens that the user can enter so this will be a good way to visually indicate to the user that they have already viewed a particular screen. I have included the working code I have that uses a text input field with a submit button - I want predetermined data to be saved to a sharedobject once the user clicks a Return to Menu button without having to enter any text. Hope someone can help. thanks
I have an input text field labeled "yourtext" and a submit button. The actionscript in the first line of the main.swf is:
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
//the "/" looks in the root area of Flash's shared object repository
//the course's "domain name" defines the root level for the
//shared object
if( (so.data.yourtext != null) )
{
//checks to see if "one" object has data in it,
yourtext = so.data.yourtext;
//gets data and displays in input box object
}
the submit button code:
on (press) {
loadMovie("main.swf", 0);
{
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
if( (yourtext != null) )
//checks if the input box contains data
{
so.data.yourtext = yourtext;
//gets input box variable content and updates shared object "one"
so.flush();
//sends new one input variable to the learner's local machine
}
}
}
In the receiving swf I have a dynamic text field labeled yourtext. The AS in the first frame is:
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
//if shared object has data already in it
if( (so.data.yourtext != null) )
{
//gets data and stores in text box object
yourtext = so.data.yourtext;
}
I have an input text field labeled "yourtext" and a submit button. The actionscript in the first line of the main.swf is:
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
//the "/" looks in the root area of Flash's shared object repository
//the course's "domain name" defines the root level for the
//shared object
if( (so.data.yourtext != null) )
{
//checks to see if "one" object has data in it,
yourtext = so.data.yourtext;
//gets data and displays in input box object
}
the submit button code:
on (press) {
loadMovie("main.swf", 0);
{
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
if( (yourtext != null) )
//checks if the input box contains data
{
so.data.yourtext = yourtext;
//gets input box variable content and updates shared object "one"
so.flush();
//sends new one input variable to the learner's local machine
}
}
}
In the receiving swf I have a dynamic text field labeled yourtext. The AS in the first frame is:
if( init == null )
init = true;
so = SharedObject.getLocal( "one", "/");
//if shared object has data already in it
if( (so.data.yourtext != null) )
{
//gets data and stores in text box object
yourtext = so.data.yourtext;
}