在向.AS文件添加SharedObject時遇到困難,我試圖將用戶名添加到.flv文件中,名稱爲「username_myfile」,紅色爲5我不確定我是否將代碼保存在正確部分的類。有沒有一種將SharedObject添加到.AS文件的正確方法?將SharedObject添加到.AS文件的正確方法是什麼?
- 補充說:
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;
}
}
}
@RobertHarvey謝謝! – shelfish
你的代碼看起來很奇怪。 if語句直接在類定義中?甚至是什麼問題?它是否編譯? –
我添加了這個,現在得到更少的錯誤** import flash.net.SharedObject; ** – shelfish