Adobe AIR AS3: Are there limitations for "browseForOpenMultiple"? - actionscript-3

I want the user to select several (image) files, that after the selection will be loaded asynchronously and somehow processed.
I expected I could use the standard function "browseForOpenMultiple".
But once I select more than ~ 130 files, AIR crashes with
"Process finished with exit code -1.073.740.940"
This is my test app:
<?xml version="1.0"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
creationComplete="onCreationComplete(event)"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script><![CDATA[
private function onCreationComplete(event:Event):void {
}
private function handleButtonClick(event:MouseEvent):void {
var imageFilter:FileFilter = new FileFilter("images", "*.jpg; *.png; *.bmp; *.swf");
var actualFilter:FileFilter;
var pdfBaseFile:File = new File("C:\\Users\\(userName)\\Documents\\jpgImagesDemoFolder");
actualFilter = imageFilter;
pdfBaseFile.addEventListener(FileListEvent.SELECT_MULTIPLE, handleFilesSelected);
pdfBaseFile.browseForOpenMultiple("Select a file: ", [actualFilter]);
}
private function handleFilesSelected(event:FileListEvent):void {
var fileList:Array = event.files;
tiResult.text = fileList.length + " files read";
}
]]></fx:Script>
<s:VGroup width="100%"
height="100%"
horizontalAlign="center"
>
<s:Button id="btBrowse"
label="Browse"
click="handleButtonClick(event)"/>
<s:TextInput id="tiResult"
text = "nothing read yet" />
</s:VGroup>
</s:WindowedApplication>`
I assume that a memory limit is hit due to that many "files to load"; although I don't need to load the files but at that moment I am only interested in the list of files.
I guess I have to read the directory programmatically (after e.g. asking the user for the directory path) and then present the result (array of file paths) to the user for selection.
Anyhow, I'd like to know if my assumption is correct and there indeed is a limit in the number of files; or a limitation in the cummulative size of the selected files.
Thanks for any clarification!
UPDATE:
Funnily a drag&drop of 270 files works without any problems!

Related

Problem with authentication from actionscript to siteminder SSO

I am migrating an adobe flex application from web version (running in flash player) to adobe air desktop application.
My application communicate with a "blazeDS service" via remote object (a way pair adobe flex with java backend) at URL: http://myhost.example.com/mycontext/messagebroker/amf
The above URL is protected with CA site minder, if user has not logged in, the system redirect to siteminder log in page at: http://myhost.example.com/sso/*...
I tried send post request to siteMinder service via post man to login success.(Post user name, password, pin, etc..) Then siteminder responsed with the cookies.
My task is try to send http request via action script to login from my air application.
I wrote a simple air application send request when initialize as bellow:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.net.*;
function init(){
var req : URLRequest= new URLRequest("http://myhost.example.com/sso/");//The Siteminder service URL.
var formData : URLVariables = new URLVariables("email=test&uname=1002102571&pass=test&gender=male"); //Post data
req.data = formData;
req.contentType = "application/x-www-form-urlencoded";
req.method = "POST";
var urlLoader : URLLoader = new URLLoader(req);
urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onResponse);
urlLoader.addEventListener(Event.COMPLETE, onComplete);
urlLoader.load(req);
}
function onResponse(event){
Alert.show("aaa" + event.target);
}
function onComplete(event){
Alert.show("bbb");
}
function response(event){
Alert.show("รข0");
}
function fault(event){
Alert.show("nb");
}
]]>
</mx:Script>
</mx:WindowedApplication>
Then siteminder response cookies too.
But when I intergrate my code to the real system, site minder respond log in fail. I don't know what is differrent between two application. Please share your advice.

Is there a way to get a file that's dropped onto the application icon on Mac and Windows?

On Mac it's possible to drop a file onto the application icon in the application dock. Is it possible to get that information and is it possible to do the same on Windows?
I've been reading up on the InvokeEvent but I haven't seen it say it's possible to get a file dropped on it's icon. It also doesn't say if that feature is supported on Windows.
Bonus points:
How to test this since Flash Builder the application is not installed (launches through debug).
I have got it work on Mac and should work on Windows.
When you register for different file types then you can drop files on the icon and the application opens and an invoke event is dispatched after you add an event listener for it (problem 1 solved). Registering file types also allows you to use "Open with..." on both Mac and Windows (problem 2 solved).
If you are using Flash Builder or another IDE to test if your invoke function works you can add a path to the file in your Run/Debug launch arguments (bonus points). Put quotes around it and separate it by a space to add additional arguments.
You have to add an event listener to the application and then after that any and all invokes will be dispatched. Until then they are only queued.
When you drop multiple files onto the application icon on Mac there will be a single invoke event with multiple arguments. On Windows and Linux this event will be dispatched multiple times with a single argument. Each argument is the full path to the file.
If you open an application normally and listen for the invoke event it is dispatched even if no files were dropped on the application. This is a standard invoke type and contains no arguments.
The example below listens for the invoke event and handles different cases.
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
invoke="windowedapplication1_invokeHandler(event)"
>
<fx:Script>
<![CDATA[
protected function windowedapplication1_invokeHandler(event:InvokeEvent):void {
var invokeArguments:Array = event.arguments;
var filePath:String;
var stream:FileStream;
var file:File;
var testing:Boolean = false;
// application icon had a file dropped on it or an associated file was double clicked while app was open
if (event.reason == InvokeEventReason.STANDARD && invokeArguments.length) {
invokeWithFile(event.currentDirectory, invokeArguments);
}
// application opened normally
if (event.reason == InvokeEventReason.STANDARD &&
(invokeArguments.length == 0 || testing)) {
if (testing) {
invokeArguments = ["/Users/me/Desktop/test.jpg"];
}
invokeWithFile(event.currentDirectory, invokeArguments);
return;
}
// application opened at login
if (event.reason == InvokeEventReason.LOGIN) {
return;
}
// application opened from URL
if (event.reason == InvokeEventReason.OPEN_URL) {
return;
}
// application opened from notification such as iOS APN
if (event.reason == InvokeEventReason.NOTIFICATION) {
return;
}
}
public var invokedFile:File;
/**
* Invoked file.
* */
public function invokeWithFile(currentDirectory:File, invokedArguments:Array):void {
var filePath:String = invokedArguments && invokedArguments.length ? invokedArguments[0] : null;
var fileData:String;
var fileStream:FileStream;
var file:File;
if (filePath) {
try {
file = new File(filePath);
}
catch (errorEvent:*) {
trace("Error: " + errorEvent.toString());
return;
}
if (file &&
file.exists &&
file.isDirectory==false &&
file.extension &&
file.extension.toLowerCase()=="mxml") {
fileStream = new FileStream();
try {
fileStream.open(file, FileMode.READ);
if (fileStream.bytesAvailable) {
fileData = fileStream.readUTFBytes(fileStream.bytesAvailable);
}
}
catch (error:*) {
}
}
}
}
]]>
</fx:Script>
</s:WindowedApplication>
Here is the application descriptor file. File types are strict. I've included notes inline:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/20.0">
<fileTypes>
<fileType>
<!-- name cannot contain a space -->
<name>MXML.File</name>
<!-- extension cannot be * -->
<extension>mxml</extension>
<description>MXML file</description>
<!-- content type is required -->
<contentType>text/plain</contentType>
</fileType>
<fileType>
<name>Photoshop.Image</name>
<extension>psd</extension>
<description>Adobe Photoshop Image</description>
<contentType>application/octet-stream</contentType>
</fileType>
<fileType>
<name>JPEG.Image</name>
<extension>jpg</extension>
<description>JPEG Image</description>
<contentType>image/jpeg</contentType>
</fileType>
<fileType>
<name>JPEG.Image</name>
<extension>jpeg</extension>
<description>JPEG Image</description>
<contentType>image/jpeg</contentType>
</fileType>
<fileType>
<name>PNG.Image</name>
<extension>png</extension>
<description>PNG Image</description>
<contentType>image/png</contentType>
</fileType>
<fileType>
<name>GIF.Image</name>
<extension>gif</extension>
<description>GIF Image</description>
<contentType>image/gif</contentType>
</fileType>
</fileTypes>
</application>
File type errors:
Error 104: application.fileTypes.fileType.contentType is required.
Solution: You must include the content type. Other places online mentioned it was optional but it may now be required.
Error 104: application.fileTypes.fileType.extension is required.
Solution: You must include the extension.
Error 105: application.fileTypes.fileType.extension contains an invalid value.
Solution: Extension cannot be empty or *.
Error 105: application.fileTypes.fileType.name contains an invalid value.
Solution: The name cannot contain a space character.

Adobe AIR 3.3 Update Framework

I am building an application in AIR (v3.3) using Flash (NOT Flex), and I am having trouble with the update framework. All the resources I have found are for older versions of AIR and / or refer to a Flex build.
It's the first time I have done this, and would really appreciate some guidance...
I have a simple test app - an image (which changes v1 to v2) and a text field.
This is what I have tried (following http://goo.gl/uvycg):
...
var appUpdater:ApplicationUpdaterUI = new ApplicationUpdaterUI();
...
public function checkForUpdate():void
{
...
appUpdater.updateURL = "http://mysite.com/updates/update-descriptor.xml";
appUpdater.isCheckForUpdateVisible = false;
appUpdater.addEventListener(UpdateEvent.INITIALIZED, onUpdate);
appUpdater.addEventListener(ErrorEvent.ERROR, onError);
appUpdater.initialize();
}
private function onUpdate(event:UpdateEvent):void
{
txt.text = 'onUpdate()';
appUpdater.checkNow();
}
private function onError(event:ErrorEvent):void {
txt.text = 'onError() ' + event.toString();
}
This is my updateDescriptor.2.5.xml:
<?xml version="1.0" encoding="utf-8"?>
<update xmlns="http://ns.adobe.com/air/framework/update/description/2.5">
<versionNumber>2.0</versionNumber>
<versionLabel>Beta 2</versionLabel>
<url>http://mysite.com/updates/UpdateTest.air</url>
<description>
<![CDATA[ update of bees. geometric growth. ]]>
</description>
So, the update descriptor with v2 of the app is on the server, I install and run v1 of the app, and all that happens is I see the onUpdate() message in my text field, and no update happens.
Where am I going wrong? Thanks!
Based on the documentation, it would appear that you need to make sure the current state of the ApplicationUpdaterUI is "ready," otherwise "checkNow()" will do nothing.
The most recent information on Adobe AIR updating can be found HERE. It applies across the board.

actionscript rss embedded in html

I'm new to actionscript and have some question:
i've written an rss reader using AS 3.0 in CS 5.5
when i press ctrl+Enter it reads my rss fead,
but when i publish it in html it just stucks on the picture(shown on the stage) and does nothing + shows the error of sandbox violation
i've spend all the day reading the documentation and understood that it's something with the domain restrictions or something like that, but still can't understand what to do exactly, can you please help me
this is the code of my swf file
russian.swf
var news_title:Array = new Array ();
var news_descr:Array = new Array ();
var news_pubdate:Array = new Array ();
var rus = "http://news.yandex.ua/index.rss";
test (rus,txt_descr,txt_title);
function test (link,txt_descr,txt_title)
{
var rssLoad:URLLoader = new URLLoader(new URLRequest(link));
rssLoad.addEventListener(Event.COMPLETE, end_rssLoad);
function end_rssLoad(rss_data:Event)
{
var rss_file:XML = new XML(rss_data.target.data);
for each (var item:XML in rss_file.channel.item)
{
news_title.push(item.title);
news_descr.push(item.description);
news_pubdate.push(item.pubDate);
}
show_rss();
}
function show_rss()
{
//number of news in rss field
var i:Number = 0;
//number of loops before update the field
var n:Number = 0;
function assign_rss_textBox()
{
txt_title.htmlText = news_title[i];
var blank_height = txt_descr.height;
txt_descr.htmlText = news_descr[i];
txt_descr.autoSize = "center";
txt_descr.y = txt_descr.y + (blank_height - txt_descr.height) / 2;
i+=1;
if (i >= news_title.length)
{
i=0;
n+=1;
if (n > 2)
{
clearInterval(delay_assign_rss_textBox);
}
}
}
assign_rss_textBox();
var delay_assign_rss_textBox = setInterval(assign_rss_textBox,500);
}
}
and this is the code of html page
<html>
<body>
<object width="600" height="125">
<param name="movie" value="russian.swf">
<param name="quality" value="high">
<embed src="russian.swf" quality=high width="600" height="125" ">
</embed>
</object>
</body>
</html>
As you've correctly identified, this is a cross-domain security issue caused by the fact that you are trying to load data from another domain into your Flash file. If you look at the crossdomain.xml on the domain on which the feed is stored, you will see that it only allows requests from the domain itself.
If you don't have any control over that cross domain policy, which I presume you don't, the usual solution would be to create a server-side proxy on your own domain to read the data and expose it to your SWF. This article explains the process quite nicely and includes an example script.
There's also a solution explained here which involves mirroring the feed in Feedburner and consuming it from there (presumably its cross domain policy is more lenient) rather than directly from the source feed.

Can we use static initializers in a Flex Library?

We are using as3Crypto library in my project. We have downloaded the code, modified a bit and started using it. Initially we have included the complete code as the part of the project. Now we are trying to compile it as Separate Library file(.swc). When we compile the code, we didn't get any errors, but we got one warning saying
Severity and Description Path Resource Location Creation Time Id
flex2.compiler.as3.SignatureExtension.SignatureGenerationFailed[level='warning', column='23', node='ForStatement', line='214', cause='flex2.compiler.as3.SignatureAssertionRuntimeException: Unreachable Codepath
at flex2.compiler.as3.SignatureEvaluator.ASSERT(SignatureEvaluator.java:369)
at flex2.compiler.as3.SignatureEvaluator.UNREACHABLE_CODEPATH(SignatureEvaluator.java:357)
at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1560)
at macromedia.asc.parser.ForStatementNode.evaluate(ForStatementNode.java:50)
at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1795)
at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:530)
at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:1795)
at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
at flex2.compiler.as3.SignatureEvaluator.evaluate(SignatureEvaluator.java:454)
at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
at flex2.compiler.as3.SignatureExtension.generateSignature(SignatureExtension.java:270)
at flex2.compiler.as3.SignatureExtension.doSignatureGeneration(SignatureExtension.java:174)
at flex2.compiler.as3.SignatureExtension.parse1(SignatureExtension.java:137)
at flex2.compiler.as3.Compiler.parse1(Compiler.java:369)
', path='C:\MyData\Flex WorkSpaces\Separate\HurlantCryptoLib\src\com\hurlant\crypto\symmetric\AESKey.as'] HurlantCryptoLib/src/com/hurlant/crypto/symmetric AESKey.as line 214 1312947481229 27
When we check the code, we traced it to a code file AESKey.as, especially from a Static initializers code block. I can't simply ignore the warning as it is the critical part of my applications security.
If Anybody come across this problem, please help me to fix this issue.
To answer the question in the title, it looks like, yes, you can use static initializers in a Flex library project. Here is a class in a library project:
package test
{
public class StaticInitializerTest
{
public static var VALUE:String = "fail";
{
VALUE = "pass";
}
}
}
And here is a Flex application that uses it:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="onCreationComplete()">
<mx:Script>
<![CDATA[
import test.StaticInitializerTest;
private function onCreationComplete ():void
{
trace("Static initializers in a Flex library project: " + StaticInitializerTest.VALUE);
}
]]>
</mx:Script>
</mx:WindowedApplication>
This produces the following output:
Static initializers in a Flex library project: pass