AS3 SharedObject getlocal cant use with Adobe AIR but works well with Flash Projector - actionscript-3

I am currently reading and writing .sol file by using Flash Projector with localpath "/" and .sol file is being saved at "C:\Users\<username>\AppData\Roaming\Macromedia\Flash Player\#SharedObjects\<randomcode>\localhost" and works fine with projector so
Problem is:
When i try to use it Adobe AIR it saves the .sol file at "C:\Users\<username>\AppData\Roaming\<app id>\Local Store\#SharedObjects" and i cant use it with Adobe AIR
Some part of the code:
{
if(!olympData)
{
Security.exactSettings = false;
skidData = SharedObject.getLocal("OlympDATA","/");
}
return olympData;
}
Which localpath should i write instead of "/" to be able to use it with Adobe AIR?

Related

SWFLoader Working in Air Project but not Web Project

I have been developing a Web type Flex project in Flash builder. In this project I have been trying to load a swf file using the SWFLoader. I have had trouble getting the debugger working, so I have instead created an identical Air project that I can run and debug with (I keep it up to date with a script). I have successfully loaded the swf file in my Air project with no trouble. But, when I went to test this in my Web project, the SWFLoader does not seem to work, I just get a blank area where my SWFLoader element should display the loaded swf file.
private function get_swf_file_binary_amf(event:ResultEvent):void {
Alert.show("SWF Returned");
var decoder:Base64Decoder=new Base64Decoder();
decoder.decode(event.result);
var swf_bytes:ByteArray=decoder.toByteArray();
var context:LoaderContext=new LoaderContext();
context.allowLoadBytesCodeExecution=true;
context.parameters = {myval: "test_string"};
swf_loaded_file.loaderContext = context;
swf_loaded_file.addEventListener(Event.COMPLETE, loadComplete);
swf_loaded_file.load(swf_bytes);
}
private function loadComplete(completeEvent:Event):void{
trace("load Complete")
}
Above is the code that works in my Adobe Air project. I am receiving the binary data of my swf file and converting it into a ByteArray, not using the URLLoader like so many example suggest. Could this be the cause of my problems when I try to run this in my Web project?
Edit/Update: I have found the particular line where the Web project fails:
context.allowLoadBytesCodeExecution=true;
I am still not sure why my Web project does not like this line, yet my Air project doesn't care.
I have removed the accursed line:
context.allowLoadBytesCodeExecution=true;
This seems to have fixed the problem. I am not even quite sure what this line does, I had just carried it over from a tutorial. Getting rid of it didn't seem to break anything that worked in my Air project, so I think that solved my problem.

Open PDF in PDF Reader from AIR Desktop Application

I'been trying to open a pdf document from inside of an Adobe Air Desktop application created with Adobe Flash CS 6.
I Used this code:
import flash.filesystem.*;
var thePDF = "mypdf.pdf";
var realFile:File = File.applicationDirectory.resolvePath(thePDF);
var destination:File = File.documentsDirectory;
destination = destination.resolvePath(thePDF);
realFile.copyTo(destination,true);
destination.openWithDefaultApplication();
This works fine when I am testing inside Flash CS6, but stops to work when I publish the application in an .exe file (Same case in MACOS with .app file).
I tryied with all the resources I found in google, nothing works!!!
Actualy I found a code from a AS3 library called Shu (com.cjt.Shu) but there is no any documentation recorded in the web.
If any body knows about this Shu or some other alternative even no Open Source. Please let me know.
Thank you all in advance, regards from México.
Are you sure that your PDF content is in the folder of the actual published AIR?
It looks like the PDF is out of scope.
EDIT: Here´s some code to explain a bit more:
file1.addEventListener(MouseEvent.CLICK, pdf1, false, 0, true);
function pdf1(e:MouseEvent):void{
navigateToURL(new URLRequest(File.applicationDirectory.nativePath + "/files/My_PDF_File.pdf" ));
}
Double check the route of your target file. In my case, it is in the local folder of my published AIR folder in the "files" folder.
Hope this can help you.

AS3: Exit desktop flash player

How do I exit the desktop flash player using Actionscript 3?
System.exit(0);
Results in
SecurityError: Error #2018: System.exit is only available in the
standalone Flash Player.
The error appears both while previewing the project in Flash CS6 and while playing the exported swf-file in Flash Player Debugger.
You can use
fscommand("quit");
This will terminate your swf.
Don't forget to import fscommand:
import flash.system.fscommand;
There is a difference between Flash Player and the stand alone version.
When you export a fla, you export a swf that is played by flash player. Its not stand alone.
Just compile it, then go to File -> Create projector. Now its a stand alone and System.exit(0) should work.
How about:
NativeApplication.nativeApplication.exit();

is it possible to open external swf in new flash player with AS3 or AS2?

is it possible to open external swf in new flash player with AS3 or AS2? I've been searching everywhere for this, but most of what i found is that it's loading into new browser tab not other flash player.
There is no function to execute a new Flash Player.
If you think in this way: Flash Player is an executable in visitor's computer. If you can launch Flash Player, you can launch any executable you want. This causes security problem.
Therefore, you can't launch a new Flash Player.
fscommand(exec) only works with Windows Projector(exe) File, not SWF.

I need to import something in order to use JSON in AS3?

When using the following codeline:
var myjson:Object = JSON.parse("path_to_my.json");
I got the following error:
1120: Access of undefined property JSON.
I had to import any package in order to use the JSON.parse?
Thank you!
[with: Flash CS5 (11.0.0.485), AS3]
JSON is built in to the ActionScript default package starting at Flash Player 11, and is notably higher performance than 3rd party serializers.
With Flash CS5, you need to update the target Flash Player from the Publish Settings. By default it will target up to Flash Player 10.2.
Adobe has a blog regarding Adding Flash Player 11 support to Flash Pro CS5 and CS5.5.
At that page you will find an extension (MXP) install as well as manual instruction of updating Flash Player to 11.
Load CS5 or CS.5 MXP with Adobe Extension Manager, and you will be able to target Flash Player 11.0 from your Publish Settings:
Note that JSON parse takes an object, and not a path to a file.  Your code should give Error #1132: Invalid JSON parse input.