So i'm running air 3.7, the latest starling frameworks, added -swf-version=20 -target-player=11.7 in compiler arguments and running the code
[Embed(source="/assets/wtf4.atf", mimeType="application/octet-stream")]
private static const why:Class;
var data:ByteArray = new why();
var texture:starling.textures.Texture = starling.textures.Texture.fromAtfData(data);
var image:Image = new Image(texture);
addChild(image);
if I'm using the starling atf that came with the framework demo it works fine, but whenever i try to display my own png that I create in photoshop converted into atf it gives me a error saying
ArgumentError: Error #3677: Texture decoding failed. Internal error.
The image I'm trying to convert into atf is just a red square png with 512x512 sizes with the compiler arguments: png2atf -c -i example.png -o example.atf. I'm not sure whether my flash builder isn't setup to decode atfs or if i'm creating the atfs wrong for some reason, if someone could shed some light on this it would be awesome!
When creating the .atf, did you created mipmaps also? If not, you need to set the second argument of the Texture.fromAtfData() function to false - don't use Mipmaps.
From Starlign wiki:
"If you omit mipmaps, you must set the parameter “useMipMaps” of the “Texture.fromAtfData()” method to “false”! Otherwise, you'll get a run-time error."
http://wiki.starling-framework.org/manual/atf_textures
The latest version of ATF requires AIR 3.8 (which is currently in beta). You need to download the AIR installer, and the latest AIR SDK. More details here: http://forum.starling-framework.org/topic/error-3677-texture-decoding-failed-internal-error
Related
I'm getting the error even though the import is not throwing errors:
1046: Type was not found or was not a compile-time constant: EncryptedLocalStore.
Here is my code:
import flash.data.EncryptedLocalStore;
var str:String = "Bob";
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(str);
EncryptedLocalStore.setItem("firstName", bytes);
var storedValue:ByteArray = EncryptedLocalStore.getItem("firstName");
trace(storedValue.readUTFBytes(storedValue.length)); // "Bob"
EncryptedLocalStore.removeItem("firstName");
I've checked and EncryptedLocalStore was introduced in AIR 1.0 (or 3.0). I'm using AIR 3.6. I'm also using this in a library project.
It's strange. I was somehow able to get rid of the errors by doing the following:
Clean
Restart
Select Include Adobe AIR libraries in the Project Properties > Compiler settings
Add -swf-version=19 to compiler arguments
Clean
Choose Use minimum Flash Player version
Clean
Change to different SDK
Clean project.
NOTE: It's working at this point. I then reversed back through those changes and after doing the following it still works.
Change back to original SDK
Clean
Uncheck Include Adobe AIR libraries in the Project Properties > Compiler settings
Clean
Remove -swf-version=19 from compiler arguments
Clean
Remove Use minimum Flash Player version and enter Flash Player 15.0.0
I'm back to where I started but now it's working?
UPDATE:
OK I figured it out:
Select "Include Adobe AIR libraries"
Switch SDK (Clicking apply doesn't work)
Errors should go away
Switch back to previous SDK
The Problem
When I was creating a test program using Flash Professional CC, I got the message "Test Movie Launch Failed" while compiling, and when I tried to open it, nothing happened and it didn't open. However, I got no compiler errors whatsoever, it just said "Test Movie Terminated." in the output.
What Might be Going on
I was thinking it might have been an error in my code, but I can't tell since the error message is extremely vague and no runtime errors appear.
So Here's my code (just in case if it's an error of the code)
Info:
Target: Air 3.6 for Desktop
Script: ActionScript 3.0
Objects:
Input Text Box with instance name of "writeT"
Dynamic Text Box with instance name of "readT"
MovieClip with instance name of "Write" (Too lazy to make buttons)
MovieClip with instance name of "Read"
import flash.filesystem.*;
import flash.events.MouseEvent;
Write.addEventListener(MouseEvent.CLICK, writeToFile);
Read.addEventListener(MouseEvent.CLICK, readFile);
var file:File = File.desktopDirectory.resolvePath("stuff.txt");
var fs:FileStream = new FileStream();
function writeToFile(e:MouseEvent):void{
fs.open(file, FileMode.APPEND);
var text:String = writeT.text;
fs.writeUTF(text);
writeT.text = "";
fs.close();
}
function readFile(e:MouseEvent):void{
fs.open(file, FileMode.READ);
var text:String = fs.readUTF();
readT.text = text;
fs.close();
}
EDIT: I commented all of my code and the error still showed up, so ignore the code
I typically see this if I use a library (.swc or .ane) that the desktop debugger cannot use.
If you using any libraries, perhaps uncouple them to see if the error disappears.
Difficult to say what the exact problem could be. From what I read, seems like a version issue. This thread maybe of some help : https://forums.adobe.com/thread/1007928
On a side note, I noticed that you have your instance named as Write and Read. I would typically avoid such names as they might conflict with reserved keywords, and while naming instances, it's best to name them using a camel case convention.
So, I would name them something Iike writeMc and readMc.
Hope this helps.
if you're publishing a mobile app, test on a mobile. you will get that error when using certain mobile-only code in the test environment. ie, test on an appropriate (ios/android) mobile.
I get a runtime error that JPEGEncoderOptions is an undefined variable when running the below code in AIR 3.5:
rawBitmapData.encode(rawBitmapData.rect, new JPEGEncoderOptions(), rawByteArray);
Make sure the following files in your sdk are up-to-date in the folder \yoursdk\frameworks\
air-config.xml
flex-config.xml
airmobile-config.xml
Update this:
<target-player>11.5</target-player>
<swf-version>18</swf-version>
This ensures your runtime is up-to-date
See : Use Adobe Air 3.3 SDK with Flash Builder
You may be missing an import of the flash.display.JPEGEncoderOptions package, or you may fully quality the package inline as below.
Example from Adobe Flash Platform Compressing bitmap data:
// Compress a BitmapData object as a JPEG file.
var bitmapData:BitmapData = new BitmapData(640,480,false,0x00FF00);
var byteArray:ByteArray = new ByteArray();
bitmapData.encode(new Rectangle(0,0,640,480), new flash.display.JPEGEncoderOptions(), byteArray);
If you get a runtime error, it can't be a missing import. You must be running it in a Flash Player that's too old, or an AIR runtime that's too old.
I've tested PNG encoding a while back and did this:
var bitmapData:BitmapData = yourBitmapDataHere;
if("encode" in bitmapData)
{
// use the native encode method
png = bitmapData.encode(bitmapData.rect, new PNGEncoderOptions(false));
}
else
{
// use old png encoder (from AS3CoreLib)
png = PNGEncoder.encode(bitmapData);
}
This effectively tests if your player or runtime environment supports BitmapData's .encode() method. If that test fails, you must be using a player that's too old.
Are you definitely including the class at the top of your code?
You need the latest Flex SDK to compile that, because those classes were only introduced in Flash Player 11.3. Flex SDK 4.6 worked for me, while Flex SDK 4.5 and lower gave me the same compiler error.
If its a runtime error, then you are running the content in a lower AIR version, or in a lower Flash Player version. Use the following method to fallback to normal code if the class is not present in the FP version you are running in. Useful for web content.
try {
// use FP 11.3 encoding
var options:Object = new JPEGEncoderOptions(quality);
var bytes:ByteArray = new ByteArray();
bitmap.encode(bitmap.rect, options, bytes);
} catch (e:Error){
// use manual JPEG encoding
}
It may be that you are missing a playerglobal for the version you are targeting or it's an incorrect playerglobal.swc in the SDK's player directory.
Download the latest Apache Flex SDK and switch to that if you can and try to create an instance of the class in a new project or your main application.
Honestly, I think it was a bug in the compiler or playerglobal. When I looked at the sdk folders I think that the playerglobal.swc might have been incorrect (all versions are named playerglobal.swc) OR it might have been the fact that I only had one directory in the SDK I was using and it had an "/11.2/playerglobal.swc" but no other folders. I think I would have needed a directory called "/11.5/playerglobal.swc" to have -swf-version make any difference.
It would be nice if the compiler threw an error when the playerglobal for the swf-version was not found at compile time. Go into the SDK folder and download and add the playerglobals to the SDK directory for the minimum targeted player to use this class.
In my Flex 4.6.0 SDK player directory, "$Flash Builder/sdks/4.6.0/frameworks/libs/player/" the swcs in:
11.1 dated 10/30/2012 351kb
11.2 dated 01/27/2013 352kb
11.5 dated 11/23/2014 351kb
11.6 dated 01/27/2013 352kb
15.0 dated 11/20/2014 388kb
In the Apache Flex 4.14RC install is:
11.1 dated 10/30/2012 351kb
11.2 dated 01/27/2013 352kb
11.5 dated 11/23/2014 351kb
11.6 dated 01/27/2013 352kb
15.0 dated 01/12/2015 388kb
It's possible something was installed somewhere along the way that is out of sync.
I want to let my app to run sound while the playbook in standby mode, I put this statement in the start up
QNXSystem.system.inactivePowerMode = QNXSystemPowerMode.THROTTLED;
Now when I debug the app on the simulator (not desktop debugger) I got this error
VerifyError: Error #1079: Native methods are not allowed in loaded code.
And this error I got also when using AlertDialog.
Note: I am using Flash builder, and I have put the qnx SWC in the libraries path.
.... so to solve these problems?
To allow code compiled w/native extensions to run on the simulator, we had to put code that used native extensions in methods that would never get executed (when on the simulator).
It wasn't enough to just wrap the offending code in an if/else block. The if/else needs to call another method that either has the native version or the simulator version of the code.
For example:
private function showNativeOrFlexAlert(message:String):void
{
// we used the Capabilities class to determine this, might be a better way
if (isMobile)
showNativeAlert(message);
else
showFlexAlert(message);
}
// have to be careful here, this method signature CANNOT include
// any classes from native extension -- no errors on device, but fails on simulator
private function showNativeAlert(message:String):void
{
// use native API to show alert
}
private function showFlexAlert(message:String):void
{
// use the Flex Alert class
}
Set the qnx-air.swc linkage to "external".
I want to send data generated by a flash module into an external executable in windows. From what I've learnt about interprocess communication, I think it is appropriate to use pipes in this case. I am using Flash professional CS5 and when a 'trace' command is used in actionscript the ouput will be displayed in the output window in flash professional. I think Flash pipes the data into the output window and if so is it possible to obtain the handle to that pipe. Is there a way by which I can write the output from flash player itself when the trace commands are executed or the data generated on an event directly into the buffer of a pipe.
Please help me out.
Thanks in advance.
I did some tricks using a Flash Badge, AIR app. and C# console app..
We can send params to an AIR app. from BADGE and receive it using:
protected function onInit(event:FlexEvent):void{
NativeApplication.nativeApplication.addEventListener(BrowserInvokeEvent.BROWSER_INVOKE, onBrowserInvoke);}
protected function onBrowserInvoke(e:BrowserInvokeEvent):void{
//reading args
var a:String = e.arguments[0];
//Now we can run *.exe from windows using:
if(NativeProcess.isSupported)
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = File.applicationDirectory.resolvePath("ExecutableApp.exe");
nativeProcessStartupInfo.arguments.push(a);
var process:NativeProcess = new NativeProcess();
//dispatched when the process will be finished
process.addEventListener(NativeProcessExitEvent.EXIT,onProcessDone);
//run
process.start(nativeProcessStartupInfo);
}
else Alert.show("Native process are not supported\nPrinter settings may be wrong!");
}
It's a long way, but certainly works! At least for me it worked.