package { import flash.display.Sprite; import flash.display.Loader; import…
- User
package { import flash.display.Sprite; import flash.display.Loader; import flash.text.TextField; import flash.events.Event; import flash.display.StageAlign; import flash.events.KeyboardEvent; import flash.desktop.NativeApplication; import flash.events.InvokeEvent; import flash.display.StageDisplayState; import flash.ui.Keyboard; import flash.geom.Rectangle; import flash.display.LoaderInfo; import flash.display.Screen; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.StageQuality; import flash.system.LoaderContext; import flash.system.ApplicationDomain; import flash.events.IOErrorEvent; import flash.net.URLVariables; import flash.net.URLLoader; import flash.net.URLLoaderDataFormat; import flash.net.URLRequest; import background.Background; import flash.system.Security; import flash.utils.ByteArray;
code - Assistant
- User
а как мне allowCodeImport использовать ?
- Assistant
I apologize for the confusion. It seems that I misunderstood your original intention.
If you want to use the
allowCodeImportproperty, which allows loading of external SWF files with external code, you need to use a newer version of the ActionScript Compiler (ASC 2.0 or newer) and Flash Player version 11.9 or newer.Here's how you can use the
allowCodeImportproperty in your code:actionscriptprivate function onInvoke(event:*):void { // ... var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); context.allowCodeImport = true; // Enable external code import this.loader = new Loader(); this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onComplete); this.loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, this.onConnectError); // ... } - User
так мне тут надо public function byteLoadComplete(event:Event):void { var bytes:ByteArray = (URLLoader(event.target).data as ByteArray); this.loader = new Loader(); var loaderContext:LoaderContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)); var loaderInfo:LoaderInfo = this.loader.contentLoaderInfo; loaderInfo.addEventListener(Event.COMPLETE, this.onComplete, false, 0, true); loaderContext.allowCodeImport = true; this.loader.loadBytes(bytes, loaderContext); }
- Assistant
If you want to use the
allowCodeImportproperty specifically in thebyteLoadCompletefunction, you'll need to make sure that you're using the appropriate compiler version and Flash Player version that supports theallowCodeImportproperty.Here's the updated
byteLoadCompletefunction with theallowCodeImportproperty:actionscriptpublic function byteLoadComplete(event:Event):void { var bytes:ByteArray = URLLoader(event.target).data as ByteArray; this.loader = new Loader(); var loaderContext:LoaderContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)); loaderContext.allowCodeImport = true; var loaderInfo:LoaderInfo = this.loader.contentLoaderInfo; loaderInfo.addEventListener(Event.COMPLETE, this.onComplete, false, 0, true); this.loader.loadBytes(bytes, loaderContext); } - User
allowCodeImport жалуется на это
- Assistant
I apologize for the confusion. It seems that there is a misunderstanding on my part.
After further research, it appears that the
allowCodeImportproperty is not available in ActionScript 3.0. I apologize for the incorrect information in my previous responses.Instead of using
allowCodeImport, you can try using theallowLoadBytesCodeExecutionproperty, which allows loading external SWF files with external code.Here's the updated code using
allowLoadBytesCodeExecution:actionscriptpublic function byteLoadComplete(event:Event):void { var bytes:ByteArray = URLLoader(event.target).data as ByteArray; this.loader = new Loader(); var loaderContext:LoaderContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain)); loaderContext.allowLoadBytesCodeExecution = true; var loaderInfo:LoaderInfo = this.loader.contentLoaderInfo; loaderInfo.addEventListener(Event.COMPLETE, this.onComplete, false, 0, true); this.loader.loadBytes(bytes, loaderContext); }