jQuery Tools에는 구성 매개 변수로 JSON 객체를 포함 Flash 객체에 전달할 수있는 flashembed가 있습니다. the official page을 참조하십시오.jQuery Tools의 flashembed에서 JSON을 구성으로 사용
그러나 Flash에서 JSON 객체를 가져 오는 방법을 정확하게 알려주지 않습니다. 그리고 그것은 질문입니다 ... 어떻게?
jQuery Tools에는 구성 매개 변수로 JSON 객체를 포함 Flash 객체에 전달할 수있는 flashembed가 있습니다. the official page을 참조하십시오.jQuery Tools의 flashembed에서 JSON을 구성으로 사용
그러나 Flash에서 JSON 객체를 가져 오는 방법을 정확하게 알려주지 않습니다. 그리고 그것은 질문입니다 ... 어떻게?
HTML과 JS : 플레시 부분에
<script type="text/javascript" src="js/jquery.tools.min.js"></script>
<script type="text/javascript">
$(function(){
$("#flashPlacement").flashembed(
{
src:"Main.swf"
},
{ //flashvars
myJsonObj:
{
someString:"string",
someNumber:123,
someOtherObj:
{
someString:"string2",
someNumber:456
}
}
}
);
$("#flashPlacement *").show();
});
</script>
, 난 Casalib의 FlashVarUtil 사용. 그러나 예, Christopher W. Allen-Poole이 말한 것 (loaderInfo.parameters.myJsonObj
)도 그 일을 할 것입니다. (그것에 대해 투표 한)
JSON에서 String
이 될 것입니다. 질문 할 때 알아낼 수 없었던 부분입니다.
AS3 :
import com.adobe.serialization.json.JSONDecoder;
import org.casalib.util.FlashVarUtil;
import org.casalib.util.StageReference;
StageReference.setStage(stage);
var jsonString:String = FlashVarUtil.getValue("myJsonObj");
//use as3corelib's JSONDecoder
//http://code.google.com/p/as3corelib/
var obj:Object = new JSONDecoder(jsonString).getValue();
//now it can be used like...
trace(obj.someOtherObj.someString); //output: string2
당신이 AS2 또는 AS3 중 어디에 있는지에 따라 다릅니다. 나는 AS2가 단순히 _root에 변수를 설정한다고 믿지만, 나는 틀릴 수있다. AS3에서는 root.loaderInfo.parameters 객체로 이동해야합니다. 모든 변수는 키/값 쌍으로 저장됩니다.
예 :
myAS2Swf.swf?example=72&other="Quack"
// in the swf:
trace(_root.example); // 72
trace(_root.other ); // Quack
// in AS3
myAS3Swf.swf?example=42&other="Duck"
// in the swf:
trace(root.loaderInfo.parameters.example); // 42
trace(root.loaderInfo.parameters.other ); // Duck