Having trouble adding a SharedObject to a .AS file, I am trying to add the users name to the .flv file in red 5 like "username_myfile" I am not sure I am adding the code thats saves the name in the correct part of the class. is there a proper way to add a SharedObject to a .AS file?
-- added:
import flash.net.SharedObject;
package app
{
import flash.display.BitmapData;
import flash.display.Stage;
import flash.external.ExternalInterface;
**import flash.net.SharedObject;**
public class DataHolder
{
private static var dataHolder:DataHolder;
public var savedstuff:SharedObject = SharedObject.getLocal("myStuff2","/");
if (savedstuff.size > 0)
{
public var username = savedstuff.data.username;
}
public var filename:String = (String(username) + "_myfile");
public var rtmpPath:String = "rtmp://numbershere.compute-1.amazonaws.com/oflaDemo/";
public var recorder:Recorder;
public var navigation:Navigation;
public var cameraFPS:Number = 30;
public var cameraWidth:Number = 640;
public var cameraHeight:Number = 480;
public var cameraQuality:Number = 88;// camera quality
public var timelimit:Number = 25;// limit count of seconds
public var stage:Stage;
public function DataHolder()
{
if (dataHolder)
{
throw new Error("Only one DataHolder instance should be instantiated");
}
}
public static function getInstance():DataHolder
{
if (dataHolder == null)
{
dataHolder = new DataHolder();
}
return dataHolder;
}
}
}
Remove the conditional declaration of your shared object and declare as usual, ie:
private var savedStuff:SharedObject;
Then, in your constructor:
try {
savedStuff = SharedObject.getLocal("savedData");
} catch (error) {
cookiesActive = false;
};
Then check cookiesActive==true to save data to the SharedObject, eg:
if (cookiesActive) {
savedStuff.data.levelsFinished = 1;
}