[Event(name="enlarge",type="com.adobe.flickr.events.EnlargeEvent")]
0 ) currentState = "hasPhotos";
}
public function get photos() : ArrayCollection
{
return ac;
}
private var _selectedItem:actionscript_application_flickr_Thumbnail = null;
public function get selectedItem() : actionscript_application_flickr_Thumbnail
{
return _selectedItem;
}
public function set selectedItem( item:actionscript_application_flickr_Thumbnail ) : void
{
if( _selectedItem != null ) _selectedItem.selected = false;
_selectedItem = item;
if( _selectedItem != null ) _selectedItem.selected = true;
}
public function set selectedIndex( index:int ) : void
{
selectedItem = imageTiles.getChildAt(index) as actionscript_application_flickr_Thumbnail;
selectedPhoto = ac.getItemAt(index);
}
private function handleDragEnter( event:mx.events.DragEvent ) : void
{
if( event.dragSource.hasFormat("thumbnail") ) {
var dropTarget:Canvas = event.currentTarget as Canvas;
mx.managers.DragManager.acceptDragDrop(dropTarget);
}
}
private function handleDragDrop( event:mx.events.DragEvent ) : void
{
var photo:Object = event.dragSource.dataForFormat('thumbnail');
ac.addItem(photo);
__userData.saveFavorites(ac);
if( ac.length > 0 ) currentState = "hasPhotos";
}
public function deleteItems( event:TrashcanEvent ) : void
{
for(var i:int=0; i < ac.length; i++) {
var item:* = ac.getItemAt(i);
if( event.items[0].id == item.id ) {
ac.removeItemAt(i);
break;
}
}
__userData.saveFavorites(ac);
if( ac.length == 0 ) currentState = '';
}
public function nextPhoto() : void
{
if( selectedItem == null ) return;
var index:int = selectedItem.index;
if( ++index >= ac.length ) index = 0;
selectedItem = imageTiles.getChildAt(index) as actionscript_application_flickr_Thumbnail;
selectedPhoto = ac.getItemAt(index);
dispatchEvent( new EnlargeEvent(this,selectedPhoto) );
}
public function prevPhoto() : void
{
if( selectedItem == null ) return;
var index:int = selectedItem.index;
if( --index < 0 ) index = ac.length - 1;
selectedItem = imageTiles.getChildAt(index) as actionscript_application_flickr_Thumbnail;
selectedPhoto = ac.getItemAt(index);
dispatchEvent( new EnlargeEvent(this,selectedPhoto) );
}
public function addPhoto( event:FavoriteEvent ) : void
{
var photo:* = event.photo;
ac.addItem(photo);
__userData.saveFavorites(ac);
if( ac.length > 0 ) currentState = "hasPhotos";
}
private function showLargeView( event:flash.events.MouseEvent ) : void
{
selectedItem = event.currentTarget as actionscript_application_flickr_Thumbnail;
selectedPhoto = event.currentTarget.data;
dispatchEvent( new EnlargeEvent(this,selectedPhoto) );
}
]]>