Skip to content
Browse files

Reading for live push with photo uploading.

  • Loading branch information...
1 parent f659ad6 commit 5e4d4e42aed1ac2fabd2aef7c44616a188b7b79a @jubishop committed Oct 8, 2009
Showing with 43 additions and 25 deletions.
  1. +1 −1 app.xml
  2. +40 −22 fbair/composer/Composer.mxml
  3. +1 −1 fbair/composer/DroppedPhotosRenderer.mxml
  4. +1 −1 fbair/util/FBUpdater.as
View
2 app.xml
@@ -24,7 +24,7 @@
<name>Facebook for Adobe AIR</name>
<!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. -->
- <version>0.9</version>
+ <version>0.91</version>
<!-- Description, displayed in the AIR application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
View
62 fbair/composer/Composer.mxml
@@ -202,7 +202,7 @@
// a successful album creation.
private function uploadDroppedPhotos(event:FBEvent):void {
if (!event.data.hasOwnProperty('aid')) {
- Output.bug("We didn't get back the album ID");
+ Output.error("We didn't get back the album ID");
return;
}
@@ -254,7 +254,7 @@
resetFields();
if (!event.data.hasOwnProperty("link")) {
- Output.bug("link to photo not returned by server");
+ Output.error("Link to photo not returned by server");
return;
}
@@ -282,7 +282,7 @@
// Direct users to album edit screen
if (!event.data.hasOwnProperty("aid"))
- Output.bug("Album ID was not returned by server");
+ Output.error("Album ID was not returned by server");
else
navigateToURL(new URLRequest(URL_EDIT_ALBUM +
StringUtil.lowOrder64(event.data.aid)));
@@ -304,26 +304,12 @@
var files:Array = event.clipboard.getData(
ClipboardFormats.FILE_LIST_FORMAT) as Array;
- // Inline functions are hot.
- var hasPhoto:Function = function(url:String):Boolean {
- for (var i:int = 0; i < droppedPhotos.length; i++)
- if (droppedPhotos.getItemAt(i).source == url) return true;
- return false;
- }
-
+ // Mark how many photos we have right now
var previousNumberOfPhotos:int = droppedPhotos.length;
-
- for each (var photo:File in files) {
- // Don't add dupes or invalid file types
- if (hasPhoto(photo.url)) continue;
- if (ValidPhotoTypes.indexOf(photo.extension) == -1) continue;
-
- photo.load();
- droppedPhotos.addItem(new ObjectProxy({
- file: photo,
- source: photo.url
- }));
- }
+
+ // Add all the photos to preview, recursively diving into dirs.
+ for each (var file:File in files)
+ addPhotoOrFolder(file);
// If we didn't add any photos, then fuck it.
if (droppedPhotos.length == previousNumberOfPhotos) return;
@@ -337,6 +323,38 @@
}
}
+ // Called to add a photo or folder of photos to droppedPhotos
+ private function addPhotoOrFolder(file:File):void {
+ // If this is a directory, then recurse
+ if (file.isDirectory) {
+ var files:Array = file.getDirectoryListing();
+ for each (var subFile:File in files)
+ addPhotoOrFolder(subFile);
+ return;
+ }
+
+ // Don't add if not a valid and new photo file.
+ if (!isValidNewPhoto(file)) return;
+
+ file.load();
+ droppedPhotos.addItem(new ObjectProxy({
+ file: file,
+ source: file.url
+ }));
+ }
+
+ // Called to ask if we already have a given photo, or it's valid
+ private function isValidNewPhoto(file:File):Boolean {
+ // Must be a valid photo type
+ if (ValidPhotoTypes.indexOf(file.extension) == -1) return false;
+
+ // Must not already exist in the list
+ for (var i:int = 0; i < droppedPhotos.length; i++)
+ if (droppedPhotos.getItemAt(i).source == file.url) return false;
+
+ return true;
+ }
+
// Called when the delete button is pressed on a photo
private function deletePhoto(event:FBEvent):void {
droppedPhotos.removeItemAt(droppedPhotos.getItemIndex(event.target.data));
View
2 fbair/composer/DroppedPhotosRenderer.mxml
@@ -19,7 +19,7 @@
<mx:Button id="photoFrame"
styleName="photoFrame"
- buttonMode="false"
+ enabled="false"
x="{photo.x - 2}"
y="{photo.y - 2}"
width="{photo.width + 4}"
View
2 fbair/util/FBUpdater.as
@@ -33,7 +33,7 @@ package fbair.util {
import flash.utils.ByteArray;
public class FBUpdater {
- private static const version:Number = 0.9;
+ private static const version:Number = 0.91;
private static const InfoURL:String = FBDialog.FacebookURL +
"/fbair/fbair_version.php";

0 comments on commit 5e4d4e4

Please sign in to comment.
Something went wrong with that request. Please try again.