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 3695600
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:38:15+00:00 2026-05-19T04:38:15+00:00

following is my code for loading one video using FileReference class and it works

  • 0

following is my code for loading one video using FileReference class and it works fine

[Event(name="complete",type="flash.events.Event")]  
[Event(name="status",type="flash.events.StatusEvent")]  
public class LocalFileLoader extends EventDispatcher  
{  
    public function LocalFileLoader()  
    {}      
    private var file:FileReference;// = FileReference(event.target);  
    private var list:FileReferenceList; 
    public var p2pSharedObject:P2PSharedObject = new P2PSharedObject();  
    public function browseFileSystem():void {  
        file = new FileReference();  
        list = new FileReferenceList();  
        list.addEventListener(Event.SELECT, selectHandler);  
        list.browse();  
    }  
    protected function selectHandler(event:Event):void {  
        for each ( file in list.fileList ){  
            file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);    
            file.addEventListener(ProgressEvent.PROGRESS, progressHandler);  
            file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);         
            file.addEventListener(Event.COMPLETE, completeHandler);  
            writeText(file.name+" | "+file.size);  
            file.load();      
        }   
    }   
    protected function securityErrorHandler(event:SecurityErrorEvent):void {  
        writeText("securityError: " + event);  
    }  
    protected function completeHandler(event:Event):void {  
        writeText("completeHandler");  
        p2pSharedObject = new P2PSharedObject();  
        p2pSharedObject.size = file.size;  
        p2pSharedObject.packetLength = Math.floor(file.size/32000)+1;  
        p2pSharedObject.data = file.data;  
        p2pSharedObject.chunks = new Object();  
        var desc:Object = new Object();  
        desc.totalChunks = p2pSharedObject.packetLength+1;  
        desc.name = file.name;  
        p2pSharedObject.chunks[0] = desc;  
        for(var i:int = 1;i<p2pSharedObject.packetLength;i++){  
            p2pSharedObject.chunks[i] = new ByteArray();  
            p2pSharedObject.data.readBytes(p2pSharedObject.chunks[i],0,32000);  
        }  
        // +1 last packet  
        p2pSharedObject.chunks[p2pSharedObject.packetLength] = new ByteArray();  
        p2pSharedObject.data.readBytes(p2pSharedObject.chunks[i],0,p2pSharedObject.data.bytesAvailable);  
        p2pSharedObject.packetLength+=1;  
        writeText("----- p2pSharedObject -----");  
        writeText("packetLenght: "+(p2pSharedObject.packetLength));  
        dispatchEvent(new Event(Event.COMPLETE));  
    }  
    protected function writeText(str:String):void{  
        var e:StatusEvent = new StatusEvent(StatusEvent.STATUS,false,false,"status",str);  
        dispatchEvent(e);  
    }  
}  

the sender.mxml code is following which plays the video on the stage

private function init() : void {  
    fileLoader = new LocalFileLoader();  
    fileLoader.addEventListener(Event.COMPLETE, fileLoaded);  
    fileShare = new P2PFileShare();  
    fileShare.addEventListener(StatusEvent.STATUS,
            function(event:StatusEvent):void {  
                writeText(event.level);  
            });    
    fileShare.connect();  
}    

private function fileLoaded ( event:Event ) : void {  
    writeText("fileLoaded");  
    if (fileShare.connected) {  
        fileShare.p2pSharedObject = fileLoader.p2pSharedObject;  
        fileShare.p2pSharedObject.lastIndexBegin = 0;  
        fileShare.p2pSharedObject.lastIndexEnd = fileShare.p2pSharedObject.packetLength-1;  
        fileShare.updateHaveObjects();  
    }  
    setupVideo();  
    // PLAY  
    ns.play(null);  

    ns.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);               
    ns.appendBytes(fileLoader.p2pSharedObject.data);  
    video.attachNetStream(ns);  
}  

private function setupVideo():void{  
    var nc:NetConnection = new NetConnection();  
    nc.connect(null);  
    ns = new NetStream(nc);  
    ns.client = this;  
    ns.addEventListener(NetStatusEvent.NET_STATUS, 
            function(event:NetStatusEvent):void{  
                writeText("stream: "+event.info.code);  
            });  
    video = new Video();  
    videoComp = new UIComponent();  
    videoComp.addChild(video);  
    this.addElement(videoComp);  
}  

then after this, the file.name and file.size goes to mxml page and the video is displayed on stage with name and file size
but the samething i want to do with FileReferenceList class, i am solving this problem from last 2 weeks but cant ,,, plz guide me ,,, i google so many times but no specific answer
Regards
Ammad Khan

  • 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-05-19T04:38:15+00:00Added an answer on May 19, 2026 at 4:38 am

    You can use the fileList property of the FileReferenceList class to access the files that where selected. Then load() each FileReference in the list separately:

    private var list:FileReferenceList;
    
    public function browseFileSystem():void {
    
        list = new FileReferenceList();  
        list.addEventListener(Event.SELECT, selectHandler);  
        list.browse();  
    } 
    
    protected function selectHandler(event:Event):void {  
    
        for each ( var file:FileReference in list.fileList) {
            file.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);  
            file.addEventListener(ProgressEvent.PROGRESS, progressHandler);  
            file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);  
            file.addEventListener(Event.COMPLETE, completeHandler);  
            writeText(file.name+" | "+file.size);           
            file.load(); 
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was loading an image resource with the following code and it works fine
I'using the following code to create thumbnails using ffmpeg but it was working fine
I'm loading jQuery via Google's CDN using the following code. My main question is
I'm currently using the following code: AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => { var name
So the following code is Lee's implementation of a preloader which works fine first
The following code works great in IE, but not in FF or Safari. I
I have the following code in one of our projects webpages: XmlDocument xDoc =
Now, I run the following code in Flash to get the raw binary data
I'm using the following code to grab images from the web. It uses Gridview
I used the following code in one of my controller; if (Request.IsAjaxRequest()) { return

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.