Sorry, but previous sample was incorrect. Below you could find the correct one:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
        horizontalAlign="center"
        verticalAlign="middle"
        creationComplete="onCreationComplete()">
        
        <mx:Script>
                <![CDATA[

                        import mx.controls.Image;
                
                        public static const IMAGE_SOURCE : String =
"http://static.flickr.com/65/211995400_eb1579ffed.jpg";;
                        
                        [Bindable]
                        private var imageContextMenu : ContextMenu;
                        
                        private function onCreationComplete() : void {
                                var item : ContextMenuItem = new 
ContextMenuItem("Save Image As...");
                                
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
onSaveAsContextMenuItemSelect);
                                imageContextMenu = new ContextMenu();
                                imageContextMenu.customItems.push(item);
                        }
                        
                        private function onSaveAsContextMenuItemSelect(event :
ContextMenuEvent) : void {
                                var image : Image = 
Image(event.contextMenuOwner);
                                var downloadURL : URLRequest = new URLRequest();
                                downloadURL.url = image.source.toString();
                                var fileReference : FileReference = new 
FileReference();
                                fileReference.download(downloadURL);
                        }
                        
                ]]>
        </mx:Script>
        
        <mx:Image source="{IMAGE_SOURCE}" contextMenu="{imageContextMenu}" />
        
</mx:Application>

On 8/11/06, Sergey Kovalyov <[EMAIL PROTECTED]> wrote:
> Hi All!
>
> Probably, somebody already implemented this, but still it could be
> interested. I have just created an example of application that
> demonstrates how to implement "Save Image As..." functionality native
> for browsers but not available in Flash applications usually.
>
> Sure, it's only to show the concept, so "hardcoded". I want to create
> component inherited from mx.controls.Image later. Any ideas and
> suggestions are welcome! :)
>
> Regards, Sergey.


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to