Entries tagged with “Adobe AIR” from Geek Life
Just a quick tip here:
var username:String = File.userDirectory.name;
So far I know it works on Mac/Windows but I haven't tested Linux.
Hope it helps.
Ok...this isn't a "spoof" post or anything like that. AIR literally deleted everything on my desktop as well as screwed something up on my OS (Vista). How did this happen? I'm glad you asked.
First off...I didn't tell it to delete ANYTHING. I'm adding features to an app and one of the features is to save a file to a network share so I was testing it against my desktop directory. Since this is AIR I figured a simple file copy was sufficient.
Do you remember that old joke where someone sent you a spam email and opening the attachment showed your My Computer window deleting every file on your system? That's how I felt watching my desktop directory contents leave.
I'm on Windows...just right click on Recyle Bin and restore, right? NOPE. AIR DELETED ALL OF MY FILES PERMANENTLY!!!!! Every file...gone. I open Computer and and it tells me "C:\Users\John C. Bland II\Desktop refers to a location that is unavailable. ..." which is great because now I literally do not have a desktop (beyond a background image).
So, again...how did this happen? Ok...don't get testy. I had to vent through sidebars real quick.
//Copy JSON file to web server
var file:File = File.createTempFile();
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTF("some content");
stream.close();
var jsonFile:File = new File(_filePath);
jsonFile.resolvePath("live" + _Index + ".json");
file.copyTo(jsonFile, true);
So, this all works up to the last line. Odd right? I don't have any delete lines. copyTo(...) is the culprit. Yep, copy really should be: copyAndDeleteAllContentsInTheDirectoryThenMoveFile(....). :-(
What's worse is the desktop directory is gone so I have NO idea if it even worked. Now I have to try it again. :-( This time I'm setting filePath to _File.desktopDirectory.nativePath+"/myapp" so it will only delete that directory vs everything.
copyTo(...)'s overwrite explanation:
"If false, the copy will fail if the file specified by the target parameter already exists. If true, the operation will first delete any existing file or directory of the same name (however, you cannot copy a file or folder to its original path). (Note: If you set this parameter to true and the source and destination File objects point to the same path, calling this method deletes the file or directory.) "
So...whatever it was...AIR DELETED MY DESKTOP! :-( Boo FLIPPIN' hoo! :-(
UPDATE:
The bug is in my resolvePath. It should be jsonFile = jsonFile.resolvePath("live" + _Index + ".json");. So, AIR tried to copy a file to a directory which caused the directory to get nixed since it was an overwrite. The time you want Vista's UAC to kick in...it is MIA! :-)
I'm researching OpenAIM for an upcoming article and thought I'd share a few quick tidbits about connecting to OpenAIM. Let me first say...I didn't do anything special here. AOL has provided a pretty quality developer center and they have written the ActionScript 3 code necessary for connecting to the AIM service. As a test I thought I'd try to grab my buddy list and show it in an mx:Tree component.
Disclaimer: This is purely a sample app so the code does not use any best practices or anything...just showing how to use the OpenAIM code.
Sample AIR app:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:wim="com.aol.api.wim.*"
layout="absolute"
applicationComplete="init()">
<mx:Script>
<![CDATA[
import com.aol.api.wim.data.types.SessionState;
import com.aol.api.wim.data.User;
import com.aol.api.wim.data.Group;
import com.aol.api.wim.Session;
import com.aol.api.wim.data.BuddyList;
import com.aol.api.wim.events.BuddyListEvent;
import com.aol.api.wim.events.SessionEvent;
private var aolSession:Session = new Session(stage, "your developer key", "Your Test Client", ".1");
private var aolBuddyList:BuddyList;
private function init():void{
aolSession.addEventListener(SessionEvent.SESSION_STARTING, handleSessionStarting);
aolSession.addEventListener(BuddyListEvent.LIST_RECEIVED, handleBuddyListLoad);
aolSession.signOn("your username", "your password");
}
private function handleSessionStarting(event:SessionEvent):void{
aolSession.requestBuddyList();
}
private function handleBuddyListLoad(event:BuddyListEvent):void{
aolBuddyList = event.buddyList;
updateBuddyList();
}
private function updateBuddyList():void{
var buddyList:XML = <node label="AOL Buddy List" />
var group:XML;
var user:XML;
for each(var item:Group in aolBuddyList.groups){
group = <node />
group.@label = item.label;
for each(var userItem:User in item.users){
if(userItem.state == SessionState.OFFLINE) continue;
user = <node />
user.@label = userItem.aimId;
group.appendChild(user);
}
buddyList.appendChild(group);
}
buddies.dataProvider = buddyList;
}
]]>
</mx:Script>
<mx:Tree id="buddies" width="100%" height="100%" showRoot="false" labelField="@label" />
</mx:WindowedApplication>
So, briefly I'll cover the code (gotta cook dinner in a sec; lol). On Line 4, above, we set the applicationComplete event to call our init() function, lines 19 to 23. In there we add a couple event listeners then call the signOn(..) function of the WIM api. Before we can successfully do this the aolSession variable must be created, which we do on line 15.
Note: You HAVE to get a developer key from AOL in order to test this code.
Once the sign on request is complete we call requestBuddyList(), line 26. When the buddy list is returned we set the aolBuddlyList variable then call updateBuddyList(), line 32. The updateBuddyList() function merely loops over the groups (your buddy groups) and users in each group, updates the buddyList XML local variable, then assigns it to the dataProvider of the buddies Tree component.
For the UI we merely create an instance of mx:Tree and set the labelField to @label, which is what we created in the updateBuddyList() function.
That's it. Run the app and you'll see your buddy list in a window like below:
They have some work to do on the source code but I went from from 0 knowledge to this sample app in 20 or so minutes. Grab the code and check it out.
Ok, I've been working on an article regarding LCDS + AIR and offline sync. I had everything pretty much done EXCEPT saving offline data back to the server (which I haven't tested with 2.6 B2 yet but will). Yesterday I installed LCDS 2.DS ES 2.6 and today I decided to toy with it. I jumped into the Dev Guide and looked at what they said was needed to do online/offline.
So I'm a skeptic at times when I see a little bit of code doing a lot but DANG! This time I was proved wrong.
airfds.swc, I'm assuming, handles creating a sqlite database and updating it. I won't spill the beans on all of the goods (my article will cover it more) but peep how flippin' simple this is:
contactsDS.saveCache(contacts);
Yep, that's it. contactsDS is my DataService and contacts is an ArrayCollection loaded from LCDS. There are other things to do for loading data from the cache and your LCDS implementation, as well as saving data back, but for the most part...WOW!
I'm loving it and keep rockin' Adobe/LCDS/Flex team!!
More to come...
That's right. It has been a long road but we have finally made it to the end. Mike Potter has a good post about the release so I won't go on and on but this is an AMAZING RELEASE for the Flex community and AIR is a great release for the world, IMO. We are on the brink of a new age, potentially. Let's see where we go from here. :-)
ENJOY!
I found another SQLite admin tool called SQLite Administrator. This is much more robust (at least it has more icons; lol) than the last one I chose to use.
If you're doing AIR dev', this could be very useful to you. At least it is for me. ;-)
That's right, check it out and get your Flex on while you grab some AIR! Ok...cliche...I know, or is it? :-)
Anyways..."grab the beta versions on Adobe Labs":http://labs.adobe.com/.
I can tell you...this is very important release. Check the release notes to see all of the new stuff.
Terrence Ryan has a proof of concept app (CF AIR Compiler) which takes CF sites and compiles them into AIR apps. His approach simply makes since and CF is probably the easiest language to accomplish this since CFHTTP and CFFILE are so freaking simple to use.
Although this is done with CF, for CF, and by CF (I only...with and by are the same thing but i had to complete the phrase; hehe) you could essentially point this to almost any site and pull the files (html content, js, and css) but it is cool to see this proof of concept in the wild.
Yep...that's right. Intel is helping bring Adobe AIR to the mobile phone.
While in a meeting (at work with Adobe FMS guys there) I read an email from Intel. I was blown away at Intel sending the email and not Adobe...that's HUGE, IMO. Intel is "backing" the AIR "movement" and in a big way. I love it!
So, what can you do with AIR and mobile? Well, nothing now. Intel has a lot of information on Mobile Internet Devices and, from what I can tell, they have fully embraced and are even pushing Adobe AIR.
I tried to find an online link but I couldn't so I took the email from Intel and put it online. I DID NOT CHANGE ANY TEXT OR INFO (other than deleting my unsubscribe link).
Grant, and the guys at gSkinner, has done it again. If you have a need to use Spell Checking and have a pretty penny to spend on it, this is probably your best/fastest solution.
My boys over at Elevate had me thinking for a bit about a solid way to upload large files for their clients. I know...FTP, right? Nope. You guys know clients! Some clients know how to FTP but not everyone.
I toyed around with the PHP settings in the CMS but I couldn't open it up to the large file sizes their clients sometimes use. Also, with HTTP you always run the risk of the client hitting refresh or closing the browser.
The thought came up to use Flash. Well, for all of those nay-sayers who claim Flash breaks the browser paradigm...I agree here. The upload happening on top of HTTP in a small side widget may be confusing since they would still be able to do other things on the page (ie - which opens them up to (again...) refreshing or closing the browser.
So, while I was at MAX I thought of a clean way to do it.
Well, maybe it isn't love (yet) but I have, as of 45 minutes ago, accepted a job with Limelight Networks. So, I am officially off the market. :-)
"Limelight Networks is a leading provider of high-performance content delivery network services. Limelight digitally delivers content for traditional and emerging media companies, or content providers, including businesses operating in the television, music, radio, newspaper, magazine, movie, videogame and software industries. Using Limelight's content delivery network (CDN), content providers are able to give their end-users a high-quality experience for rich media content, including video, music, games, software and social media."
- source
I've pondered this decision for a little bit now (interviewed over two weeks ago or so) and it seems to be the right fit. I'll be working with the Flash Platform (yummy...FMS here I come) on the day to day but also working with PHP, Ajax, and I'll even get to do some Silverlight, maybe/hopefully. They just went IPO in June 2007 and a lot of people are enthusiastic about this stock. It is low right now (9 bucks) so I can get a lot of stocks for a lil' bit right now. LLNW being newly public is exciting. I have several sweet ideas for apps that could help boost revenue or at least popularity and possibly boost stock. We'll see how things go and I'll keep everyone posted (for that not under NDA, etc).
Anyways...that's the news!
...and will be joining someone's team here soon.To clearly explain the why, what, and when I'll break this down into a few sections.
(full explanation on the next page; kinda long)
Multidmedia wrote an article in April of this year titled Zinc Vs Apollo: The Good, The Bad and The Desktop. It is written with a bit of a defensive tone, understandably. Their whole business is Zinc. I mean, they have other products but Zinc is definitely the big one and Adobe AIR is SERIOUSLY going to cut into profits for them. It is free compared to several hundred for Zinc. Anyways...I wanted to clarify a few things from their article.
They did write this in April of this year so the info was current as of them but it isn't now. For instance, the table at the bottom compares Zinc and AIR. This is the biggest "gripe" I have with the article.
(see the article first then the rest of this post will make sense)
Ok, this is my first impression and, as with all things, I'm sure I'll find something wrong with it but right now...NOPE...IT ROCKS!
You can build HTML+Javascript AIR applications! I love it, again...at first glance. The more I play with it I'll expand my thoughts but at this point this is about all I can say. lol. :-)
Oh, it is also useful for normal Javascript, Apple iPhone development, and more. Last note...it is free! :-D

