Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8574421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:28:15+00:00 2026-06-11T19:28:15+00:00

newbie on AS3 here! :) basically I’m trying to write an application that let

  • 0

newbie on AS3 here! 🙂

basically I’m trying to write an application that let the user choose an image file and display it (then I will manipulate pixels, so i don’t want the application to store the image in a new file, just managing the ByteArray).

So far I wrote in Flash Develop some working code that show a window to choose the image and then display it. but when I upload to a server the generated files (myapplication.swf, expressinstall.swf, index.html, and the js folder) the window shows no more.

I’m using FileReference.browse() method.

What’s wrong?

(edit: as pointed out from The_asMan here we miss some code, here it is – improved with the suggestion of The_asMan)

my package:

package searchfiles 
{
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.net.FileReference;
    import flash.net.FileReferenceList;
    import flash.net.FileFilter;
    import flash.events.*;
    import flash.net.FileFilter; 
    import flash.net.FileReference; 
    import flash.net.URLRequest; 
    import flash.utils.ByteArray; 
    import flash.display.DisplayObject;

    /**
     * ...
     * @author ddd
     */
    public class searchForFiles extends EventDispatcher
    {
        public var newfile:FileReference;
        public var loader:Loader
        public var bitmapimg:BitmapData;            

        public function searchForFiles() {
            newfile = new FileReference();
            newfile.addEventListener(Event.SELECT, onFileSelected); 
            newfile.addEventListener(Event.CANCEL, onCancel); 
            newfile.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 
            newfile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError); 

            trace("abbiamo instanziato un searchForFiles");
            var textTypeFilter:FileFilter = new FileFilter("Image files (*.png, *.jpg, *tif)", 
                        "*.png; *.jpg; *tif"); 
            newfile.browse([textTypeFilter]);   

        }       

        public function onFileSelected(evt:Event):void 
        { 
            newfile.addEventListener(ProgressEvent.PROGRESS, onProgress); 
            newfile.addEventListener(Event.COMPLETE, onComplete); 
            newfile.load(); 
        } 

        public function onProgress(evt:ProgressEvent):void 
        { 
            trace("Loaded " + evt.bytesLoaded + " of " + evt.bytesTotal + " bytes."); 

        } 

        public function onComplete(evt:Event):void 
        { 
            trace("File was successfully loaded."); 
            loader = new Loader();              
            loader.loadBytes(newfile.data);         
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);           
        } 

        private function erroremanip(evt:IOErrorEvent):void {
            trace("errore " + evt);
        }
        private var bitmapData:BitmapData

        public function getBitmapData(e:Event):void {
            var content:* = loader.content;
            bitmapData = new BitmapData(content.width,content.height,true,0x00000000);
            trace("loader.width = " +loader.width);
            dispatchEvent( new Event(Event.COMPLETE));
            //trace("get bitmap data called");
        }

        public function onCancel(evt:Event):void 
        { 
            trace("The browse request was canceled by the user."); 
        } 

        public function onIOError(evt:IOErrorEvent):void 
        { 
            trace("There was an IO Error."); 
        } 
        public function onSecurityError(evt:Event):void 
        { 
            trace("There was a security error."); 
        }                       
    }    
}

and here’s the main()

package 
{
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.errors.IOError;
    import flash.events.*;
    import flash.events.MouseEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import searchfiles.searchForFiles;

    /**
     * ...
     * @author ddd
     */
    [SWF(width = "550", height = "600")]

    public class Main extends MovieClip 
    {
        public var file:searchForFiles;
        public var mybtn:Loader = new Loader();

        public function Main():void 
        {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);

        }

        private function init(e:Event = null):void 
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            // entry point          
            mybtn.addEventListener(MouseEvent.CLICK, mouseclicked);
            mybtn.addEventListener(IOErrorEvent.IO_ERROR, erroremanip);
            var urlqst:URLRequest = new URLRequest("preview_true.png");
            mybtn.load(urlqst);
            addChild(mybtn);

        }

        public function mouseclicked(e:MouseEvent):void {
            trace("clicked");
            file = new searchForFiles();
            file.addEventListener(Event.COMPLETE, puttheimage);     
        }
        private function erroremanip(e:IOError):void {
            trace("ciao erroreio");
        }
        private function puttheimage(e:Event) :void {
            addChild(file.loader);

        }
    }   
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:28:16+00:00Added an answer on June 11, 2026 at 7:28 pm

    FileReference.browse()
    When outside local sandbox needs to be triggered via user interaction IE: mouseclick.
    Basically, the click event needs to be in the stack somewhere.
    You can verify this with.

        file = new FileReference();
        file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    
        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }
    

    However, you posted no code and it is very hard to determine exactly what you did wrong.

    [EDIT]

    package searchfiles 
    {
        import flash.display.BitmapData;
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.net.FileReference;
        import flash.net.FileReferenceList;
        import flash.net.FileFilter;
        import flash.events.*;
        import flash.net.FileFilter; 
        import flash.net.FileReference; 
        import flash.net.URLRequest; 
        import flash.utils.ByteArray; 
        import flash.display.DisplayObject;
    
        /**
         * ...
         * @author ddd
         */
        public class searchForFiles extends EventDispatcher
        {
            public var newfile:FileReference;
            public var loader:Loader
            public var bitmapimg:BitmapData;            
    
            public function searchForFiles() {
                newfile = new FileReference();
                newfile.addEventListener(Event.SELECT, onFileSelected); 
                newfile.addEventListener(Event.CANCEL, onCancel); 
                newfile.addEventListener(IOErrorEvent.IO_ERROR, onIOError); 
                newfile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);   
            }
    
    
                 // new function
            public function browse(event:Event):void{
                var textTypeFilter:FileFilter = new FileFilter("Image files (*.png, *.jpg, *tif)", "*.png; *.jpg; *tif");   
                newfile.browse([textTypeFilter]);
            }
    
    
    
    
            public function onFileSelected(evt:Event):void 
            { 
                        newfile.addEventListener(ProgressEvent.PROGRESS, onProgress); 
                        newfile.addEventListener(Event.COMPLETE, onComplete); 
                        newfile.load(); 
            } 
    
            public function onProgress(evt:ProgressEvent):void 
            { 
                trace("Loaded " + evt.bytesLoaded + " of " + evt.bytesTotal + " bytes."); 
    
            } 
    
            public function onComplete(evt:Event):void 
            { 
                trace("File was successfully loaded."); 
                loader = new Loader();              
                loader.loadBytes(newfile.data);         
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);           
            } 
    
            private function erroremanip(evt:IOErrorEvent):void {
                trace("errore " + evt);
            }
            private var bitmapData:BitmapData
    
            public function getBitmapData(e:Event):void {
                var content:* = loader.content;
                bitmapData = new BitmapData(content.width,content.height,true,0x00000000);
                trace("loader.width = " +loader.width);
                dispatchEvent( new Event(Event.COMPLETE));
                //trace("get bitmap data called");
            }
    
            public function onCancel(evt:Event):void 
            { 
                trace("The browse request was canceled by the user."); 
            } 
    
            public function onIOError(evt:IOErrorEvent):void 
            { 
                trace("There was an IO Error."); 
            } 
            public function onSecurityError(evt:Event):void 
            { 
                trace("There was a security error."); 
            }                       
        }    
    }
    

    and here’s the main()

    package 
    {
        import flash.display.Loader;
        import flash.display.MovieClip;
        import flash.display.Sprite;
        import flash.errors.IOError;
        import flash.events.*;
        import flash.events.MouseEvent;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import searchfiles.searchForFiles;
    
        /**
         * ...
         * @author ddd
         */
        [SWF(width = "550", height = "600")]
    
        public class Main extends MovieClip 
        {
            public var file:searchForFiles;
            public var mybtn:Loader = new Loader();
    
            public function Main():void 
            {
                if (stage) init();
                else addEventListener(Event.ADDED_TO_STAGE, init);
    
            }
    
            private function init(e:Event = null):void 
            {
                removeEventListener(Event.ADDED_TO_STAGE, init);
                // entry point
    
    
                         // moved to init
                file = new searchForFiles();
                file.addEventListener(Event.COMPLETE, puttheimage);
    
    
    
                mybtn.addEventListener(MouseEvent.CLICK, mouseclicked);
                mybtn.addEventListener(IOErrorEvent.IO_ERROR, erroremanip);
                var urlqst:URLRequest = new URLRequest("preview_true.png");
                mybtn.load(urlqst);
                addChild(mybtn);
    
    
            }
    
            public function mouseclicked(e:MouseEvent):void {
                trace("clicked");
                        // events need to be set before any active code is run in the object
                        // that is why we moved listeners or else you risk the listener
                        // not getting triggered
                        file.browse()
            }
            private function erroremanip(e:IOError):void {
                trace("ciao erroreio");
            }
            private function puttheimage(e:Event) :void {
                addChild(file.loader);
    
            }
        }   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie C++ programmer here. I'm trying to write a command line application that takes
Newbie question here! I'm building a simple application that allows users to create and
First of all, Flash/AS3 newbie here. I create a small animation with ActionScript (basically
Newbie question here... I need to select an JDBC driver to connect an application
Newbie here. I am looking at company code. It appears that there are NO
Newbie question here. I am trying to use the django-extjs library in my django
Newbie here, I am trying to use Bioperl module in the perl environment. My
I am developing a Paint Application is AS3. What I am trying is to
newbie here! I have source data that contains both simplified and traditional Chinese in
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.