खोज…


टिप्पणियों

ऐसे कुछ मामले हैं, जहां आपका एप्लिकेशन बाहरी संसाधन से लोड की गई संपत्तियों की सामग्री में फेरबदल नहीं कर सकता है (उदाहरण छवियों को बदलना)। मुझे कुछ याद नहीं है कि वे क्या हैं, लेकिन मुझे पूरा यकीन है कि यह क्रॉस कंटेंट लोडिंग से संबंधित है।

लोडर के साथ बाहरी चित्र / SWF लोड हो रहा है

  1. लोडर ऑब्जेक्ट बनाएँ:

    var loader:Loader = new Loader();   //import 
    
  2. लोडर पर श्रोताओं को जोड़ें। मानक पूर्ण और io / सुरक्षा त्रुटियां हैं

    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete); //when the loader is done loading, call this function
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loadIOError); //if the file isn't found
    loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, loadSecurityError); //if the file isn't allowed to be loaded
    
  3. वांछित फ़ाइल लोड करें:

     loader.load(new URLRequest("image.png"));
    
  4. अपना ईवेंट हैंडलर बनाएं:

     function loadComplete(e:Event):void {
         //load complete
         //the loader is actually a display object itself, so you can just add it to the display list
         addChild(loader) 
         //or addChild(loader.content) to add the root content of what was loaded;
     }
         
     function loadIOError(e:IOErrorEvent):void {
         //the file failed to load, 
     }
        
     function loadSecurityError(e:SecurityError):void {
         //the file wasn't allowed to load
     }
    

लोडर वर्ग के साथ लोड करना अतुल्यकालिक है। इसका मतलब है कि जब आप loader.load को कॉल करते हैं। फ़ाइल लोड होने के दौरान एप्लिकेशन चालू रहेगा। जब तक लोडर Event.COMPLETE ईवेंट को भेजता है, तब तक आपकी लोडर सामग्री उपलब्ध नहीं होती है।


आयात की आवश्यकता:

import flash.display.Loader;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;

FileStream (AIR रनटाइम केवल) के साथ एक पाठ फ़ाइल लोड हो रही है

एक साधारण उदाहरण के लिए कैसे एक UTF पाठ फ़ाइल तुल्यकालिक पढ़ने के लिए।

import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;

//First, get a reference to the file you want to load
var myFile:File = File.documentsDirectory.resolvePath("lifestory.txt");

//Create a FileStream object
fileStream = new FileStream(); 

//open the file
fileStream.open(myFile, FileMode.READ);

//read the data and assign it to a local variable
var fileText:String = fileStream.readUTF();

//close the current filestream
fileStream.close();


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow