all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

help with localconnection


Re: help with localconnection tralfaz
2/13/2006 3:54:53 PM
flash actionscript: [quoted text, click to view]

You can either have the loading file report in with localConnection
and ask for the variable to be sent or you could save the variable in
a localObject and have the other file read the variable in when it
loads.

// save some information before loading the other file..
mso = sharedObject.getLocal("stuff2save","/");
mso.data.something = 100;
mso.data.somethingElse = "elephant";
mso.flush(); // write to the file


// The other swf file loads and gets the variables..
mso = sharedObject.getLocal("stuff2save","/");
var thing = mso.data.something;
mytext.text = mso.data.somethingElse;

tralfaz

help with localconnection dvwatkins
2/13/2006 8:56:02 PM
Im trying to transfer variables between two different movies using
localconnection. it works when i have both movies open in different windows.
For example i have the login screen and the first page of the course open at
the same time. I type my name in and press submit. My name then shows up on
the first page of the course. However, i want it to load the first page of the
course in the same window as the login when i hit submit. When i do this the
variable doesn't get transferred and doesn't show up. The first page of the
course doesn't load the variable at all.

How do I get the variable to transfer properly when im loading the movie or
the htm file in the same window as the login?
Re: help with localconnection dvwatkins
2/16/2006 6:45:21 PM
I tried using the sharedObject, but that doesn't seem to do anything. When i
try and retrieve the data from the sharedObject, they come up undefined.not
sure if im doing it correct or what, but i still can't get either method to
work. Basically, I have one Movie where they enter their name and when they
hit submit, it takes them to the course, which is a seperate movie. I can't
get the name variables to transfer from the login movie, to the actual course
movie.
Re: help with localconnection tralfaz
2/17/2006 2:27:30 PM
[quoted text, click to view]

I have found it necessary to delete the reference to the shared object
after using it to allow it to be refreshed later on the next read. If
you don't delete the reference to it, the next read will pull the
information from a cache somewhere instead of reloading the file.
Here is a little demo with MX sourcecode..
http://members.cox.net/4my5cats/localObject/test.html

One warning though.. I have found that sometimes if you click two
sends (from alternate swfs) in rapid succession, you can cause a
malfunction that makes further reading of the sol file mess up. After
that, each file reads it's own copy of the file and the changes made
by one file don't effect the other until you restart the swf. I think
it's a timing issue related to two files accessing the same sol file
at the same time. There are ways around it, like holding sends and
reads until a certain clock value so that each file has it's own time
slice to use in accessing the sol file.
tralfaz

Re: help with localconnection dvwatkins
2/17/2006 7:08:39 PM
ok, i figured some stuff out about using SharedObject. It stores the variable
properly, but the second picks it up as being blank. However, when i re-run
the first one, it picks it up fine. So for some reason, my second movie won't
load the SharedObject correctly. Or it doesn't load the correct one. I have
checked like 5 million times to make sure it's all spelled the same and even
copied and pasted from one movie to the other the function that grabs the data
from the shared object and it still doesn't work. it keeps coming up undefined.

If there is anything special i need to do to fix this, i could use some info
please. Im testing it on a local machine and its all stored in the my
documents folder, so if maybe this has anything to do with it i would like to
know please.

basically the first movie stores it and loads it all correctly, but the second
movie doesn't load it correctly. i have the first movie check to see if there
is data already on the users computer and if there is, it preloads the text
fields with the data and when i re-run the first movie, it picks up the data.
but the second movie won't pick up the data at all.
Re: help with localconnection dvwatkins
2/21/2006 6:19:54 PM
Thanks a lot for your help. I finally got what i needed working pretty well.

Next question is something that i didn't think of at the time. It came up
after i figured the first part up and I noticed it loading the data. but one of
the variables I want to store, I want to expire or be deleted when they leave
the program.

Is there a way to make the Shared Object expire, or a way to delete it off the
system when the user leaves the program? Or do you know of a way to keep parts
of the program from opening up unless the user goes to another part of the
program first. That way they cant just open up section 2 without actually
going through the login for example.
AddThis Social Bookmark Button