How read only part of local file? So that not to load the whole file into memory.
If you are using AIR you can use the readBytes() method of the FileStream API to specify an offset of the file where you want to start reading.
For a SWF that is running in the browser, the only method in the Flash Player 10 is the load() method of the FileReference class and that one doesn't allow you to specify an offset.
Related
Is it possible to list all channels initiated by LocalConnections from other SWF files?
I have an embed SWF file that creates a LocalConnection using a random number for the channel, and I would like to get connected to that channel, using another SWF I am building. However, I see no way I can connect to it, unless I know the channel's name.
Thank you.
No, unfortunately, it's not possible.
If your embed swf is AS3 based you can pass LC name to it when swf is loaded (or listen for the name in event from it, not difference), if it's AS2 the only way to pass variables is to load it with Loader by URL (not as embed bytes) and pass param via query, like "as2file.swf?lcname=_mylcname"
I want to know how to load external class files(.as files) in actionscript but don't have to know the class file's name. Think of it like loading mods in minecraft with forge mod loader, it doesn't know the main class of the mod's file name, yet it successfully loads the mod. I want to know if something like this is possible in actionscript 3.0 because I feel like making a tower defense game that isn't like the others out there but have it so it can be modded and have mods loaded but of course I have to load the class file without knowing the class file's name.
Note: I don't got access to Adobe Air so I can't use anything that requires Adobe Air.
You want to load a particular .as file AFTER or BEFORE compilation? After the compilation it is hardly possible - the file would not be compiled and therefore it would be useless. Why don't you use a swf or some kind of XML/JSON with settings in that case? Before the compilation you would still need to identify it by it's package name/name.
Basically, you want a plugin management system.
In AS3, it is not possible to "load" a .as file on execution, because it is a (uncompiled) source file. But, it is possible to load another swf and to use the classes within it.
Your process should probably be something like this :
Get a list of the plugins/addons. If you were using AIR, it would have been possible by browsing the content of a folder. Since you're not, you'll probably need to use a listing file (basically, a file that say "Here's the list&path of the plugins you need to load".
Load each swf file
(possibly) call a initialization method for each plugin.
You may wish to look into the way OSMF manages plugins, for example : http://osmf.org/dev/osmf/OtherPDFs/osmf_plugin_dev_guide.pdf
I have a 'Shell' swf as the main swf to protect other things in the project.
Shell swf's procedure is:
check stage property, so it can't be loaded as a child.
check Capabilities.isDebugger, so it can't be run in a debugger.
load a decoder lib. the decoder lib is built by flascc, quite difficult to decompile.
use decoder to validate self. if failed or skipped, decoder won't do any decoding job.
load encoded main entry of the project, decode it & add it to stage.
The problem is step 4, I want to do binary checksum of Shell swf.
Questiones are:
How can i get the original binary content of the Shell swf file on startup ?
if not, is Shell swf's LoaderInfo.bytes consistent in different versions of flash player ?
if not, is there any good way to do the validation job in step 4 ?
If you create an AIR app you can temporarily load original file ("Shell.swf") in application bundle using standard URLLoader or File and FileStream.
If your app will work in browser then you can get self-file-name and URL from loaderInfo and load it using URLLoader.
Anyway after your verification process complete you need unload it.
Is it possible to write to a local file 'example.txt' from a Flex swf? FileStream class is available in Adobe AIR, not in Flex. I want to write to from a swf,not AIR application.
I am developing a kiosk type application which has to log user interaction data to a text file on the machine.
Is there a code example for doing this?
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf6167e-7fff.html#WS2db454920e96a9e51e63e3d11c0bf6167e-7ff9
You can use FileReference to save a file with user confirmation. You can also use FileReference to load a file specified by the user. Or, you can use a SharedObject to save information without a dialog.
I am coding an AIR application.
I've got directly a path of a swf file (because it was stored in a xml file).
Do yo know if it is possible to get the ByteArray from this file ?
I know that FileReference do that very well, but this class need a select event. But it isn't my case because I've allready got my path.
Thanks a lot for your answers !
In AIR, you can read/write files directly using flash.filesystem.File and flash.filesystem.FileStream.
See, for example, this article.
however you can load it with URLStream and get a ByteArray with URLStream.readBytes()