My problem w/ using Flash for CD's has been loading media and saving variables. Presently, I use a Director shell to deal w/ both problems, but I'm trying to use Flash MX to get away from that. I think its overkill for most of my work and I really like the results I get w/ Flash.
I think I've gathered enough help from various Flashkit (thank you)and Macromedia sources to create a good approach. I'd like to share it and get some feedback.
Solution 1: Saving Varibles
The shared objects that someone described as "like cookies for flash" can be used to save and recall varibles.
Recalling the Variable
so = SharedObject.getLocal("myInfo");
MyColor = so.data.favoriteColor;
Mac compatibility is another problem I've experienced. However, becasue this is a standard Flash MX function, I undersdand that it works for MAC's ... but I haven't tested it on a MAC.
Solution 2: Loading Media
You can use the .load commands to dynamically load pictures, video ( i think ) and sounds. I deal w/ a lot of event sounds and this works quite well.
sndObj = new Sound();
sndObj.loadSound("xjump.mp3");
sndObj.start();
So, if you just need to save user profiles and would like flash to serve as a container for sound and other media, this should work. I'm going to build a prototype now, but, first, I'm curious if anyone anticipate problems w/ these methods?
Hmmm, I'm going to add it but that bothers me becasue its working without the flush. I'm wondering if the flush is only neccesary when the swf is running off the web? In that case, I'll need it depending on how I package this application.
On a related note, I didn't need this line to save:
".flush immediately writes a locally persistent shared object to a local file. If you don't use this method, Macromedia Flash MX writes the shared object to a file when the shared object session ends—that is, when the SWF movie is closed or when the shared object is garbage-collected because it no longer has any references to it."
Originally posted by pitchdog Ok, I get it now ... nothing to do with the web:
".flush immediately writes a locally persistent shared object to a local file. If you don't use this method, Macromedia Flash MX writes the shared object to a file when the shared object session ends—that is, when the SWF movie is closed or when the shared object is garbage-collected because it no longer has any references to it."
Thanks for the link
This is interesting, and I wonder if it can be used to do what I am trying to accomplish: I have a Flash movie on a home page that uses a shared object to detect whether the visitor has been to the site before, and if so, skips the intro part of the movie and goes straight to the static part. So, a visitor only sees the intro once, EVER. Now the client wants to change it so the visitor only sees the intro once PER VISIT.
This is not the same as once PER DAY -- I mean the visitor could visit in the morning and see the intro once during that visit, then logoff the site and the visit would be over. But if they came back that night, they would see the intro again because it was a new "visit."
I can easily modify it up to play the intro once PER DAY, but I'm thinking the only way to play it once per visit is with cookies (which I'm not familiar with). Is this correct, or am I being pessimistic?
That's an interesting problem, and I think it would be a proper application for these "cookies" as I'm skeptical about their long-term use. I guess you'd just have to toggle a varible between "seen" and "notseen" as they left the site.
I have an example, here, that shows the "cookies" working. It "remebers" the hexagons that you selected. You can click a pattern and return a month later and its still there. I though of making it into a flash lite-brite but that won't pay the bills.
Originally posted by pitchdog That's an interesting problem, and I think it would be a proper application for these "cookies" as I'm skeptical about their long-term use. I guess you'd just have to toggle a varible between "seen" and "notseen" as they left the site.
I have an example, here, that shows the "cookies" working. It "remebers" the hexagons that you selected. You can click a pattern and return a month later and its still there. I though of making it into a flash lite-brite but that won't pay the bills.
Here's the HEX. I used ACT and PASS in there a lot - to me it means "Activity" and "Pass."
It does work on a CD. And I hear it works on a MAC as well. I have reservations on making a CD this way becasue I'm not sure if someone could purge the data by accident. In short, I'm not confident enough in the proccess to make a multiuser CD ... I may put a beta test out using this method. I wouldn't have any reservations using it for a demo cd - to indicate areas where the user has already visited, for instance.
I'm not 100% sure what you mean by multiple shared objects becasue I'm thinking too much. If you mean more than one shared varible, its just a matter of defining one. And you can set the path for the stored data. I'm saving to a folder called hexdata and I used the shared object var SO. Check it out and see if that makes sense.
If your interested in colored hexes, I did get around to making the multi-colored hex game. It reminds me of something out of "Land of the Lost" (sorry for that obscure reference) Anyway, the code for the color obscures the point of this string so I think this, though less sophisticated, is better to tear apart.
Thanks alot for that pitchdog, muchly appreciated.
Just to pick your brain even more-so....where is the shared object actually written to on your HDD???
Say I make a project using shared objects, change the shared object through the flash player, then burn a copy of the swf...will the shard object remain if I play this CD in another computer??
Just a thought.
I don't know exactally how all of this works ... and I feel I should make it clear that I've never tried this on a mass-produciton level. Just messing around. Still, I'd like to know more.
This is what I know about the data:
Here's the data path:
C:\WINDOWS\Application Data\Macromedia\Flash Player\localhost\hexdata.sol
Do a search on it ... this is what the data looks like:
So, it looks like you need the player and the data is saved locally and is not attached to the SWF / Player. BTW, I've run this off a standalone / EXE and it works fine.
Thanks loads for your help.
But Im still struggling.Ughhh.
All I really need to get my head around is how to create arrays within a shared object. Im pretty sure you have done this in your land of the lost puzzle(classic!). But Im having probs implementing it in my project.
This is what Im trying to achieve:
2 dynamic text boxes. "tb1" and "tb2"
2 input text boxes. "tb1_edit" and "tb2_edit"
all I want to do is to be able to use the edit boxes to enter text and to save this text in the corresponding dynamic text box..
sounds really easy and probably is...but drivin me nuts + giving me rsi!
I eventually want to make lotsa text boxes and also store variables etc....
But here is where Im stuck.....when I put this swf in a different location (another folder etc)it will not work (recover data from shared object).
I noticed in the land of the lost puzzle that you specified ("hexdata", "/") when you created your shared object.(I havent seen this documented anywhere)
I stuck a "/" in but still no go.
anyways without much further ado heres the fla to show you what Im getting at.
Cheers p - dog
btw, I couldnt find the sol file after doing a search....?
Also like the Land of the Lost, my expertise on shared objects is akin to the humans playing with those ruby hexagons. So, I don't have this worked out in an array, but I have some ideas. I checked out your code and I'm going took another look later today. I do think you should establish the var in the text field as soon as you click the button. I couldn't get that to work until I put a _root. in front of all of the vars. Also, if you can't find the file, I'm guessing its not writting it and I'd start from there. You could also try to see if you can get my hex.fla to display the act or actstatus var in a text field.
I belive mine works for multiple vars becasue the vars are defined in the hex mc's, so each var is tied to the mc. I don't use an array.
* I don't think there's anyway the text file will save on the burn.
* See if you can do a search by last modifed ... if that doesn't work, try to do a search on my hex.