Air.trace()

I've been disgruntled with the need to run my application in
the debugger in Flash CS3 to be able to see trace statements, and
the fact that doing so usually just outright crashes the debugger
over and over.
When looking at the livedocs which now include the AIR api:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html
I'm finding examples using "air.trace()", for instance in
bytesAvailable
I'm wondering, is this a way of invoking the trace() method
differently that might take care of this frustration for me, but
I'd like to understand it by reading about it in the API but I
cannot find it anywhere on the livedocs entity I included above or
in my local help interface in Flash CS3.
Is 'air' like 'stage', an instantiation of an 'Air' class
that I can reference? Moreover, why is the FileStream in this
example being instantiated as new air.FileStream instead of
flash.filesystem.FileStream as flash.filesystem is the base package
for this class?

Thank you.
The prefix is of course a nice shortcut, but if not
documented in such a way as to be easily found, I would argue that
it should not be included in examples. I reached the API from the
link in the 'For Flash' section of this page:
http://www.adobe.com/support/documentation/en/air/#flash
If it's documented elsewhere in an AJAX context, that's great, but
that's a perspective that I as a Flash developer would not share.
I've spent considerable time looking for documentation on
debugging via ADL (I assume it's the AIR Debug Launcher? I found
one place in the developers guide where it's spelled out but no
details on what it is, and how to invoke it. I currently test my
program using Control=>Delete ASO files and Test Movie. It gives
me the message "Exporting Flash Movie (progress bar), and then
about 80% of the time it gives me a message telling me that the
"Adobe AIR Debug Launcher" has crashed once it hits the first
function call using the AIR api. Am I already doing as you
suggested? I condition/commented out all of my trace back when AIR
was still BETA as this was what was suggested by the AIR Engineers
on the support boards then.

Similar Messages

  • Air.trace() not working

    Hi all,
    Someone had a similar problem here: http://forums.adobe.com/thread/750219?tstart=0  They managed to solve it, I started adding to post but thought it best to start a brand new post.
    I've tried what they've suggested and made a file called mm.cfg in my %HomeDrive%%HomePath% directory (c:\users\james) the contents of which are:
         ErrorReportingEnable=1
         TraceOutputFileEnable=1
         TraceOutputFileName=c:\logs\flashlogs.txt
         MaxWarnings=50
    but I still don't get a log file from air.trace().  Though in C:\Users\James\AppData\Roaming\Macromedia\Flash Player  there's a file flashlog.txt with:
         Warning: Not a known player download type, app:/HelloWorld.html
    I'm running Vista and I'm using AIRSDK 2.5.  I call my hello world  application from the command prompt with " adl HelloWorld-app.xml "  I  get a window of correct dimensions with " Hello World! " as expected, but  no console message.  What am I doing wrong please?  I've been looking  for about a day now at how to get the air.trace messages but neither  those nor the introspector statements work.
    Thank you!!
    James
    The  4 files are in:
    C:\AIRHelloWorld
    The 4 files are:
    HelloWorld-app.xml
    HelloWorld.html
    AIRAliases.js
    AIRIntrospector.js
    My  code for HelloWorld-app.xml and HelloWorld.html is below.   AIRAliases.js and AIRIntrospector.js  are copied straight from AIRSDK
    HelloWorld-app.xml
    <!-- Tutorial at: http://help.adobe.com/en_US/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc.html -->
    <application xmlns="http://ns.adobe.com/air/application/2.5">
        <id>examples.html.HelloWorld</id>   
        <versionNumber>0.1</versionNumber>   
        <filename>HelloWorld</filename>
        <initialWindow>
            <content>HelloWorld.html</content>
            <visible>true</visible>
            <width>240</width>
            <height>320</height>
        </initialWindow>
    </application>
    <!-- To RUN AND TEST the application get a console window (type cmd into search box of Windows vista)
    type:
    cd c:\AIRHelloWorld
    When you have it in the directory of "c:\AIRHelloWorld" then type:
    adl HelloWorld-app.xml
    You'll get a window showing the app and also apparently the console window displays the
    message resulting from the air.trace() call in the html, but I never see this -->
    HelloWorld.html
    <html>
    <head>
        <title>Hello World</title>
        <!-- In the <head> section of the HTML, import the AIRAliases.js file: -->
        <script src="AIRAliases.js" type="text/javascript"></script>
        <script type="text/javascript" src="AIRIntrospector.js"></script>
        <!-- JavaScript function to handle the onLoad event:  -->
        <script type="text/javascript">
        function appLoad(){
            air.trace("Hello World - debug comment");  /*The appLoad() function simply calls
               the air.trace() function. The trace message print to the command
               console when you run the application using ADL. Trace statements
               can be very useful for debugging.*/
            air.Introspector.Console.log("Hello World - Introspector debug comment");
        </script>
    </head>
    <body on load="appLoad()">
        <h1>Hello World!</h1>
    </body>
    </html>

    Hi Chris, on sdk 2.5, actually, also the Introspector doesn't seem to work. Tried:
    <html>
        <head>
            <title>Source Viewer Sample</title>
            <script type="text/javascript" src="js/AIRAliases.js"></script>
            <script type="text/javascript" src="js/AIRIntrospector.js"></script>
            <script type="text/javascript">
                function logBtn()
                    var button1 = document.getElementById("btn1");
                    air.Introspector.Console.log(button1);
            </script>
        </head>
        <body>
            <p>Click to view the button object in the Console.</p>
            <input type="button" id="btn1"
                onclick="logBtn()"
                value="Log" />
        </body>
    </html>
    UPDATE: I didn't realize it was a different window that appears behind. It works then!

  • How to get errors and/or air.trace() from installed air app?

    I'm trying to debug an installed air app that behaves
    differently once installed than when run with adl. However, i can't
    figure out any way to get errors or air.trace() information. I am
    on OS X (10.5.6). Any tips?
    I imagine this should be easy since debugging an installed
    app is pretty much a necessity for development.

    You can enable logging to a text file using settings in the
    mm.cfg file. See
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19323
    Note that ALL trace output will go to the log.
    Other things you can do are:
    1. Run the installed app with adl -- just pass the installed
    app descriptor to adl on the command line
    2. Supply a publisher id to adl. This removes one difference
    between installed/ not installed apps and may be enough if the
    behavior issue has to do with local connections or other matters
    involving the publisher id.
    3. Use the adl -nodebug flag. This removes another difference
    between installed/uninstalled apps. You won't see uncaught
    exceptions, but trace statements are still reported.

  • 2.5 SDK getting started: air.trace() not working

    I don't know where to turn. I´ve followed the steps on this tutorial and air.trace doesn't work.
    I'm using Windows Vista and the command prompt to run the debugger. It starts the app but air.trace sends nothing to the command window.
    I've tried running cmd with admin privileges with no results. If I make a javascript alert {{  alert(air.trace)  }} it correctly says it's a function and testing a basic send-something-to-clipboard snippet works fine.
    Here's my code:
    <html>
    <head>
        <title>Hello World</title>
        <script type="text/javascript" src="air/AIRAliases.js"></script>
        <script type="text/javascript">
            function init(){
              // this works
           var copy = "A string to copy to the system clipboard.";
           air.Clipboard.generalClipboard.clear();
           air.Clipboard.generalClipboard.setData(air.ClipboardFormats.TEXT_FORMAT, copy);
              // this doesn't
              air.trace("anybody there?");
        </script>
    </head>
    <body onLoad="init()">
        <h1>hello world?</h1>
    </body>
    </html>
    Any ideas?

    Hi all,
    I'm running Vista, and using the command prompt but don't get any messages from air.trace().  I'm using AIRSDK 2.5 and call my hello world application from the command prompt with " adl HelloWorld-app.xml "  I get a window of correct dimensions with " Hello World " as expected, but no console message.  What am I doing wrong please?  I've been looking for about 2 hours now at how to get the air.trace messages but neither those nor the introspector statements work.
    Thank you,
    James
    The 4 files are in:
    C:\AIRHelloWorld
    The 4 files are:
    HelloWorld-app.xml
    HelloWorld.html
    AIRAliases.js
    AIRIntrospector.js
    My code for HelloWorld-app.xml and HelloWorld.html is below.  AIRAliases.js and AIRIntrospector.js  are copied straight from AIRSDK
    HelloWorld-app.xml
    <!-- Tutorial at: http://help.adobe.com/en_US/air/build/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc.html -->
    <application xmlns="http://ns.adobe.com/air/application/2.5">
        <id>examples.html.HelloWorld</id>
        <versionNumber>0.1</versionNumber>   
        <filename>HelloWorld</filename>
        <initialWindow>
            <content>HelloWorld.html</content>
            <visible>true</visible>
            <width>240</width>
            <height>320</height>
        </initialWindow>
    </application>
    <!-- To RUN AND TEST the application get a console window (type cmd into search box of Windows vista)
    type:
    cd c:\AIRHelloWorld
    When you have it in the directory of "c:\AIRHelloWorld" then type:
    adl HelloWorld-app.xml
    You'll get a window showing the app and also apparently the console window displays the
    message resulting from the air.trace() call in the html, but I never see this -->
    HelloWorld.html
    <html>
    <head>
    <title>Hello World</title>
    <!-- In the <head> section of the HTML, import the AIRAliases.js file: -->
    <script src="AIRAliases.js" type="text/javascript"></script>
    <script type="text/javascript" src="AIRIntrospector.js"></script>
    <!-- JavaScript function to handle the onLoad event:  -->
    <script type="text/javascript">
    function appLoad(){
    air.trace("Hello World - debug comment");  /*The appLoad() function simply calls
        the air.trace() function. The trace message print to the command
        console when you run the application using ADL. Trace statements
        can be very useful for debugging.*/
    air.Introspector.Console.log("Hello World - Introspector debug comment");
    </script>
    </head>
    <body on load="appLoad()">
    <h1>Hello World</h1>
    </body>
    </html>

  • Air.trace not tracing anything (HTML/JS)?

    i am starting flash and learning from a tutorial. so i have my HTML like:
    <html>
    <head>
    <script src="AIRAliases.js" type="text/javascript"></script>
    <script type="text/javascript">
    function loadHandler() {
        air.trace("Message");
    </script>
    </head>
    <body onload="loadHandler()">
    <p>Hello World</p>
    </body>
    </html>
    the program runs but nothing is traced in the cmd. AIRAliases.js exists btw. i ran
    adl HelloWorld.xml
    my descriptor file

    It works in my end.
    What if you use window.runtime.trace directly, instead of air? Does it work?

  • Html App: air.trace() not outputting to console... are Adobe still supporting html apps in AIR?

    Hi
    Just getting up and running
    Mac OS X 10.9. Adoe AIR 3.9. All working fine except air.trace() not outputting anything to the console.
    Bit of googling meant I created a mm.config in ~ with the line:
    ErrorReportingEnable=1
    but still no joy.
    Any other tips for getting this to work or is it just now broken and/or unsupported?
    Are HTML apps wrapped in AIR now legacy technology?

    I have the same question... I've been trying to get an Adobe AIR HTML app going, but there appears to be no IDE that supports debugging an HTML/JS AIR App, and fdb, which is supposed to be able to debug HTML/JS AIR apps, does not.
    Is HTML/JS still a supported way of developing Adobe AIR apps?  If so, then why aren't issues like this getting some attention?
      -Josh

  • Trace not working in air / as3

    Hi, this may be something obvious but after installing adobe
    air, trace no longer works to my output window.
    I've checked the publish settings and 'omit traces' is
    unchecked.
    thanks

    Hi Trigon_15
    Same thing happend to me, suddenly trace stopt working, some sort of bug i believe
    how it occured i don't know, if added a new SDK, all worked perfect, 2 days later, it just
    stopped tracing.
    How i solved it?
    i've added the compiler argument (-compiler.debug=true) to the Compiler options of the project.
    In my case it's tracing again
    Hopes it will help you to!
    Regards,
    Marc
    ps. i'm using Flash Builder 4 with Flex SDK 4.1

  • How can I run a .bat file from an html/javascript adobe air installation package?

    I write an html/javascript code which works completely true
    but when I made the installation package by air-sdk
    it dosent work properly
    my code is:
    <html>
    <head>
        <title>Hello World</title>
              <script type="text/javascript">
            function appLoad() {
                air.trace("Hello World");
        </script>
    </head>
    <body onLoad="appLoad()">
        <h1>Hello World</h1>
              <br />
    <button onclick="window.open('file:///C:/Windows/notepad.exe')"> Launch notepad </button>
    <button onclick="window.open('file:///D:/opennotepad.bat')"> Launch batnote </button>
    </body>
    </html>
    Chapter 5: Creating your first HTML-based AIR application with the AIR SDK

    Seems to be security violation. You can't execute bat or cmd

  • Sqlite SELECT query in AIR

    Hi All,
    I have problem with the order in which i get the fetched
    data. I have a database with table "tblPersonalDetails" with
    fields: id, first name, last name, status(married/single), address,
    state. I am trying to fetch following fields: first name, last
    name, status, address, state using the query: "SELECT first name,
    last name, status, address, state FROM tblPersonalDetails"
    The Code snippet is as follows:
    function getPersonalDetails()
    // Create a File object that points to the test.db file
    var database =
    air.File.applicationDirectory.resolvePath("test.db");
    // Instantiate the Class
    var connection= new air.SQLConnection();
    // Create a File object that points to the contacts.db file
    connection.openAsync( database );
    alert("open");
    // Event Listener that will tell us when the DB is opened
    connection.addEventListener(air.SQLEvent.OPEN, openSuccess);
    // Event Listener that will tell us if an error occurs
    connection.addEventListener(air.SQLErrorEvent.ERROR,
    openFailure);
    // Create New Instance
    var query = new air.SQLStatement();
    // Add the Connection Reference
    query.sqlConnection = connection;
    // SQL Query
    query.text = "SELECT first name, last name, status, address,
    state FROM tblPersonalDetails;";
    air.trace(query.text);
    // Execute the Query
    query.execute();
    // Add Event Listeners
    query.addEventListener( air.SQLEvent.RESULT, onResult );
    query.addEventListener( air.SQLErrorEvent.ERROR, onError );
    //connection.clean();
    //connection.close();
    function openSuccess()
    air.trace("Success");
    function openFailure()
    air.trace("Failure");
    function onResult(event)
    var sqlStmt = event.target;
    var sFinalOutput = "";
    var result = sqlStmt.getResult();
    if( result.data == null ) {
    air.trace( "Query did not return results." );
    else{
    var numRows = result.data.length;
    var output = "";
    for ( colName in result.data[0] ) {
    output += colName + "|";
    output += "<br>";
    for ( i = 0; i < numRows; i++ ) {
    for ( colName in result.data
    output += result.data[colName] + "|";
    sFinalOutput = sFinalOutput + "<br>" + output;
    output = "";
    air.trace( sFinalOutput );
    document.getElementById("result").innerHTML=sFinalOutput; //
    result is id of div on my html page
    air.trace( numRows + " rows returned." );
    function onError(event)
    air.trace(event.error.message);
    Now I am getting the result as:
    last name|state|status|first name|address
    Jain|Delhi|Single|Ashish|Kalkaji
    Sharma|UP|Married|Vivek|Noida
    Means, the order in which I am writing in query, I should get
    the result in that order. But I am not getting so.
    Please help me.
    Thanks in advance.

    Hi gauravgr8,
    The SQLResult has a data property. The data is an array of
    rows in a specific order (if ORDER BY is used, etc.). Each row is
    an object. (
    http://livedocs.adobe.com/air/1/jslr/flash/data/SQLResult.html)
    Objects are name value pairs, but in ActionScript, order is
    not guaranteed. If you want a specific order of the object, you
    will need to enforce that yourself.
    for ( i = 0; i < numRows; i++ ) {
    output += result.data
    .firstname + "|";
    output += result.data.lastname + "|";
    output += result.data
    .status + "|";
    output += result.data.address + "|";
    output += result.data
    .date + "|";
    I hope that helps!
    -Erica

  • Adobe AIR installation questions

    Hi all,
    I'm looking into the possibility of distributing an application with Adobe AIR and I've a few questions about the Adobe AIR installation process. Just to give you some background on the situation I'm in - if a user wants to use the service I'm working on, they need to install a binary application on their computer. We've a web site which communicates with this binary application. As the user as to install the binary application to begin with, we're beginning to look at AIR as a possible alternative to distributing the web content through a browser.
    1. Adobe AIR installation requests that the user enters their computer password. Is there any way to retrieve this password from a separate installer? The binary application that we ask our users to install asks the user for their password and it would be nice to not ask the user to enter their password twice. Are there any possibilities for sharing this password between our binary application and the Adobe AIR installer?
    2. If I sign up as a re-distributer of AIR, is the Adobe EULA which is displayed at the start of installation still necessary? I'm already displaying one EULA (with the binary application) and I'd prefer not to have to display two.
    3. I'm assuming that there is no way to specify the directory into which I'd like the Adobe AIR runtime to be placed - can you confirm that Adobe AIR is always installed in the /Applications folder on mac and c:/Program Files on Windows?
    This question goes out to Adobe AIR developers - If you have distributed your application with Adobe AIR, have you ever stumbled across the situation where a user has uninstalled the Adobe AIR runtime (either intentionally or unintentionally) and you are now left in a situation where a user cannot access your services because Adobe AIR is not installed on their computer. If so, are you aware of any usable fallbacks other than to tell customers that they have to have Adobe AIR installed to run the application?
    Thanks
    Sean

    1:  We are working on a method to use a local socket to communicate with an installed c# application on the users machine.  The situation is very similar, however we store credentials encrypted and accessible to the installed binary.  If those credentials do not exist the AIR app requests the user to input them and they are sent to the binary.  These credentials are stored either per session, daily or forever per the user's preferences.  We use this method to let AIR be the front end it was designed to be and leave all the heavy lifting OS / processor wise to the binary.  Unsure if this would help but you can read a bit more on using local sockets here: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7caf. html
    2:  The EULA is still required as the End User has to accept it.  If there's a way around that, I'm not aware.
    3:  The installation directory can be changed by the user unless you are performing silent installs (available when you sign a redistribution agreement).  I don't recommend relying on the installation directory never changing.
    Try using nativePath to determine where your program location is: (javascript)
    //application directory
    var file = air.File.applicationDirectory.resolvePath("testfile.html");
    air.trace(file.nativePath);
    //application storage directory
    var file = air.File.applicationStorageDirectory.resolvePath("testfile.html");
    air.trace(file.nativePath);
    4:  I've faced the problem where the AIR runtime is not available, but we always fall back on the badge there.  For what it's worth it's pretty handy at detecting requirements and getting them to the user.
    hope that helps

  • Passing Variable to air app when launch using Badger

    Hi all,
    I am going to desperately to develop my application. Hope someone can help me........
    I am using badger for air which I get it here http://www.adobe.com/devnet/air/articles/badger_for_air_apps.html and it launch my app correctly, but I can't pass any variable into my app when launch.
    I have read the instruction and adding some code like this :
    on index.html(show my badge installer):
        var so = new SWFObject("AIRInstallBadge.swf", "", "215", "180", "9.0.115", "#000000");
            so.addVariable("airversion", "1.5");
            so.addVariable("appname", "Secure%205");
            so.addVariable("appurl", "http://localhost/testing/source/secure5.air");
            so.addVariable("appid", "examples.html.HelloWorld");
            so.addVariable("pubid", "B71ED76ECC937067D72BB9A0CDB516D1A8F43A9E.1");
            so.addVariable("arguments", "launch from browser");// this is my code
            so.addVariable("appversion", "0.1");
            so.write("flashcontent");
    on index.html(my initial content) :
    var urlMonitor;
    var urlReq;
    var invokeEvent;
    var applicationID = "myappid";
    var publisherID = "mypubid";
    var applauncarg;
    //var admin="admin";
    function doWindow()
    var options = new air.NativeWindowInitOptions();
    options.transparent = false;
    options.systemChrome = air.NativeWindowSystemChrome.STANDARD;
    options.minimizable = false;
    options.maximizable = false;
    options.resizable=false;
    var windowBounds = new air.Rectangle(0,0,air.Capabilities.screenResolutionX,air.Capabilities.screenResolutionY);
    var urlreq="http://www.example.com";
    var newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);
    newHTMLLoader.load(new air.URLRequest(applauncharg));
    newHTMLLoader.stage.nativeWindow.alwaysInFront = true;
    newHTMLLoader.stage.nativeWindow.addEventListener(air.NativeWindowBoundsEvent.MOVE,handlem ove);
    newHTMLLoader.stage.nativeWindow.addEventListener(air.Event.CLOSE,onCloseCommand);
    urlMonitor = new air.URLMonitor(new air.URLRequest("http://www.example.com"));
    urlMonitor.addEventListener(air.StatusEvent.STATUS, onStatusChange);
    urlMonitor.start();
    air.NativeApplication.nativeApplication.addEventListener(air.InvokeEvent.INVOKE, onInvoke);
    //urlReq=new air.URLRequestDefaults.manageCookies = true;
    function handlemove()
    newHTMLLoader.stage.nativeWindow.x=0;
    newHTMLLoader.stage.nativeWindow.y=0;
    function onCloseCommand(exitingEvent) {
    var winClosingEvent;
    for (var i = 0; i < air.NativeApplication.nativeApplication.openedWindows.length; i++) {
    var win = air.NativeApplication.nativeApplication.openedWindows[i];
    winClosingEvent = new air.Event(air.Event.CLOSING,false,true);
    win.dispatchEvent(winClosingEvent);
    if (!winClosingEvent.isDefaultPrevented()) {
    win.close();
    } else {
    exitingEvent.preventDefault();
    if (!exitingEvent.isDefaultPrevented()) {
    //perform cleanup
    function onInvoke(e)
    //apparg=event.applauncharg.toString();
    //alert ('oK'+apparg);
    applauncarg = event.arguments;
    air.trace("onInvoke : " + event.applauncharg);
    //air.Introspector.Console.log( applauncarg );
    alert (applauncarg);

    sory, there is mistake here......
    the question isn't finish yet.
    function onInvoke(e)
    //my code
    applauncarg = event.arguments;
    air.trace("onInvoke : " + event.applauncharg);
    alert (applauncarg);//just to make sure the variable had been sent correctly
    My application running smoothly but there is no alert that show applauncharg variable.
    then I am trying to know if invoke event run correctly or not by adding code
    alert ("OK");
    and it works, so there is no problem with the event listener.
    does any one know if I missing something or any thing wrong with my code?
    sory, there is mistake here......
    the question isn't finish yet.
    function onInvoke(e)
    //my code
    applauncarg = event.arguments;
    air.trace("onInvoke : " + event.applauncharg);
    alert (applauncarg);//just to make sure the variable had been sent correctly
    I have get the answer. If someone need the source code, just Pm me and I'll give you my Source to help you.
    The first is to make sure that your action scipt code can handle the argument that passed by javascript.
    Make attention between invoke event and browser invoke event! it is almost same but they are different.
    If you type browser invoke event, it seems browser invokeevent doesn't recognized, but it works.
    The second is my mistake on source code. onInvokeevent shold be like this :
    function onInvoke(e)
    //my code
    applauncarg = .arguments;
    alert (applauncarg);
    -closed-

  • TypeError :  air has no properties

    Hi guy!
    I tried to use trace function of air object
    My html file is :
    <html>
    <head>
    <title>Sandbox Bridge Test</title>
    <script type="text/javascript" src="AIRAliases.js"></script>
    <script type="text/javascript">           
                function doLoad() {
                try {             
                  air.trace("Coucou");
                 catch (e)
                 {alert(e)}
            </script>
    </head>
    <body onload="doLoad();">
    <h3>Application Sandbox Content</h3>
    <hr />
    </body>
    </html>
    But the eval function prints "TypeError :  air has no properties", what's wrong ?

    Have you included the AIRAliases.js file in the same directory as the HTML file? They should both be in the main application directory (or a subdirectory).

  • Microphone record, playback in AIR html js desktop app

    hi,
    I want to record, save and playback the microphone audio in an HTML/JS AIR desktop app.
    I can't find any examples so my code is based on AS3.
    But the app crashes almost right away when the SampleDataEvent handler function is called.
    Should it be in a while loop sames as AS3?
    $(function(){
        var mic;
        var soundBytes = new air.ByteArray();
        $("#btnRecord").click(function(){
            mic = air.Microphone.getMicrophone();
            mic.rate = 44;
            mic.addEventListener(air.SampleDataEvent.SAMPLE_DATA, sampleEvent);
        function sampleEvent(e){
            while (e.data.bytesAvailable) {
                var sample = e.data.readFloat();
                soundBytes.writeFloat(sample);
        $("#btnStop").click(function(){
            mic.removeEventListener(air.SampleDataEvent.SAMPLE_DATA, sampleEvent);
            $("#txtActivity").val("");
        $("#btnPlay").click(function(){;
            for (var i = 0; i < 8192 && soundBytes.bytesAvailable > 0; i++) {
                var sample = soundBytes.readFloat();
                e.data.writeFloat(sample);
                e.data.writeFloat(sample);
                //we write the data twice because there are 2 channels (stereo)
    thanks,
    Jeff.

    this works on my macbook. But on my Windows 8.1 machine the audio gets played back twice as slow as normal.
    Not a lower pitch, just twice as slow. Any idea why this is?
    $(function(){
        var s;
        var sc;
        var nowRecording = false;
        var nowPlaying = false;
        var recordedBytes = new air.ByteArray();
    //   air.SoundMixer.audioPlaybackMode = window.runtime.flash.media.AudioPlaybackMode.VOICE
        var mic = air.Microphone.getMicrophone();
        mic.rate = 44;
        mic.gain = 70;
        mic.setSilenceLevel(0);
        $("#btnRecord").click(function(){
            if (!nowRecording) {
                air.trace("recording");
                recordedBytes.clear();
                mic.addEventListener(air.SampleDataEvent.SAMPLE_DATA, getMicAudio);
                nowRecording = true;
                $(this).val("Click me to stop")
            else {
                air.trace("recording stopped");
                mic.removeEventListener(air.SampleDataEvent.SAMPLE_DATA, getMicAudio);
                nowRecording = false;
                $(this).val("Click me to record")
        function getMicAudio(e){
            recordedBytes.writeBytes(e.data);
        $("#btnPlay").click(function(){
            if (!nowPlaying) {
                air.trace("playing");
                recordedBytes.position = 0;
      s = new air.Sound();
                s.addEventListener(air.SampleDataEvent.SAMPLE_DATA, playAudio);
      sc = new air.SoundChannel
                s.play();
               sc.addEventListener(air.Event.SOUND_COMPLETE, stopPlayback, false, 0, true);
                nowPlaying = true;
              //  $(this).val("Click me to stop playing")
            else {
                sc.stop();
                stopPlayback();
        function stopPlayback(e){
            air.trace("playing stopped");
            s.removeEventListener(air.SampleDataEvent.SAMPLE_DATA, playAudio);
            nowPlaying = false;
        function playAudio(e){
      if(!recordedBytes.bytesAvailable > 0)
      return;
            for (var i = 0; i < 8192; i++) {
                var sample = 0;
      if(recordedBytes.bytesAvailable > 0) sample = recordedBytes.readFloat()
                e.data.writeFloat(sample);
                e.data.writeFloat(sample);

  • How to run commands like "ipconfig" and get the output in adobe AIR in windows?

    import flash.desktop.NativeProcess; 
    import flash.desktop.NativeProcessStartupInfo;   
    if (NativeProcess.isSupported) {     
         var npsi:NativeProcessStartupInfo = new NativeProcessStartupInfo();     
         var processpath:File = File.applicationDirectory.resolvePath("MyApplication.whatever");     
         var process:NativeProcess = new NativeProcess();       
         npsi.executable = processpath;     
         process.start(npsi); 
    The above can only run a sub-application, but how to run an independent  application(command) like ipconfig and get the result?

    Hi,
    here is an example of running a net Use command line from AIR, unig the new NativeProcess. Hope it will help !
    function launchProcess()
      var file = air.File.applicationDirectory;
      // set command path
      file = file.resolvePath("C:/Windows/system32/net.exe");
      var nativeProcessStartupInfo = new air.NativeProcessStartupInfo();
      nativeProcessStartupInfo.executable = file;
      // prepare command parameters
      var args = new runtime.Vector["<String>"]();
      args.push('USE');
      args.push('W:');
      args.push('/delete');
      args.push('/y');
      // set arguments
      nativeProcessStartupInfo.arguments = args;
      // add listeners to catch command outputs
      process.addEventListener(air.ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
      process.addEventListener(air.ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
      process.addEventListener(air.NativeProcessExitEvent.EXIT, onExit);
      // create and run Native process
      process = new air.NativeProcess();
      process.start(nativeProcessStartupInfo);
    function onOutputData(ProgressEvent)
      var processResults = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
      air.trace("Results: \n" + processResults);
    function onErrorData(ProgressEvent)
      var processResults = process.standardError.readUTFBytes(process.standardError.bytesAvailable);
      if(processResults.search('password') > -1){
        window.alert('Bad password');
      air.trace("Errors: \n" + processResults);
    function onExit(NativeProcessExitEvent)
      air.trace("Process ended with code: " + NativeProcessExitEvent.exitCode);

  • Desktop AIR 2.5 application with transparency and embedded Flash with wmode transparency error

    I'm working on a desktop AIR project using the 2.5 SDK (ADT) to create an application that combines html and flash content. My application is using systemChrome none and transparent true. I have an swf element in my html file that I have set to wmode transparent. Instead of the swf rendering with a transparent background and showing the desktop like the html content does, I'm seeing a black box that fills the area where the Flash element is embedded.
    Can someone please assist me in removing this black square so that my flash content is rendered within the html file with a transparent background instead of a black background?
    When the AIR application is set to transparent, the Flash content must have it's wmode set to either transparent or opaque. Opaque gives it a white background (the stage background color), but transparent seems to just give it a black background.
    Thanks!

    Ok fellas,
    It appears that I have indeed answered my own question. So thanks... uh, me As I've now figured out, the entire AIR application is basically still a Flash based Display Object, one that can render html using webkit. That means that even though my main application is written in HTML I can still load swf files into the display list of the root applications native window using the Loader class.
    I had mentioned earlier that this didn't work, but actually it did work I was just having an error. In my flash file I had a reference error because I was referencing stage.stageWidth in actionscript. This produces a typeError in the AIR runtime when I add this to the root display list. I was able to finally see this error by add the -nodebug command to my adl testing script (adl app.xml -nodebug). For whatever reason my AIR 2.5 adl would not produce air.trace calls to the cmd console without that -nodebug command, which is extremely ironic. So adding in the -nodebug command actually gave me my debug traces! Welcome to the world we live in folks... I also found out that my traces in the swf also trace out to the console when you add this command in there.
    In addition, the reason I was not able to get the Loader class to work from javascript was because I was not using the correct addEventListener call. If you are familiar with Actionscript 3.0 (which luckily I am) you will recall that you have to add the event listener to the "contentLoaderInfo" object of the Loader variable you instanciate.
    Here's a snippet of how I was able to do this as well as another link that is buried in the documentation that's useful:
    var loader;
    loader = new air.Loader();
    var file = air.File.applicationDirectory.resolvePath("test.swf");
    loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, swfLoaded);
    loader.load( new air.URLRequest(file.url) );
    function swfLoaded(evt) {
         air.trace(" SWF LOADED! Woohoo! ");
         air.trace( loader.numChildren );
         loader.width = 1000;
         loader.height = 800;
         loader.x = 0;
         loader.y = 0;
         window.nativeWindow.stage.addChild(loader);
    This is a very useful article on creating nativeWindows and other things, such as creating Flash based display objects and adding them to the stage:
    http://help.adobe.com/en_US/air/html/dev/WS5b3ccc516d4fbf351e63e3d118666ade46-7e0a.html
    Woohoo!

Maybe you are looking for

  • Posting to PartnerLink with No Exposed WSDL?

    I have a web service that I am posting to that hosts it directly on a url like this .... http://server:81/. There is no exposed ?WSDL address. When I put this URL with port in the location in my config file I get an error when I try to post to it. Fo

  • PDF file size limited to graphics memory in Reader?

    I've created a form (in LiveCycleDS) that allows for an unlimited number of photos to be loaded into it. I put an image into a subform that is duplicated every time a user clicks a button thus creating an unlimited number of images that can hold phot

  • Parameter mapping error in webdynpro java

    Hi All, I have a table and the columns of the table are created dynamically(assume I have Colum A & Column B). The table cell editor is input field. On hitting enter on the input field of the column, I want to get the column name. But I am getting co

  • SIMPLE APEX PRINTING IN 4.0

    Question: Using APEX 4.0 I am finding that I am having a world of hurt trying to get very BASIC printing setup. I am not using BI and do not need PDF or RFT formats. Essentially, I would like to be able to create Interactive reports that do three thi

  • Object Oriented vs Context Oriented Programming

    A few weeks ago, I submitted a Paradigm Shift: the WDP Model & the Power to Bind in which I tried to argue for a more object oriented approach to the structuring of WDP Components by using the javabean model as an abstraction layer for the WDP Contex