Many times, your C/C++ code may rely on external files to work, such as texture files/model files for a 3D engine. One way to supply those file to the CModule in CrossBrige is to use the memory API, which is fast, but need more wrapper codes. Sometimes, use the standard C/C++ I/O API, such as "FILE" and "ifstream", is more convenient for porting existing C/C++ libraries.
CrossBridge needs to process the external files using "genfs" before you can use them. That's why I tried the URLLoaderVFS, a class by twistedjoe from http://forums.adobe.com/thread/1147910. And for different kinds of methods of loading files - Embed, use http/URLLoader and use local shared objects, you need to genfs the external files differently and link with different .as class, which is detailed documented at http://www.adobe.com/devnet-docs/flascc/docs/Reference.html#section_vfs.
However, these are for compilng a swf directly from C/C++ source files. If you compile C/C++ to a swc first, and then compile the swf from your swc and a main.as file, things can be greatly simplified.
I always thought the FlasCC/CrossBridge's file system is more
complicated than Alchemy, before I realized that there is a similar way
for supplying external files to the C module.
In Alchemy, we only need to use the function "supplyFile(fileName:String, fileData:ByteArray)", and handle the different methods of loading the data file in AS3, use the "Embed" tag, URLLoader or local shared objects.
In CrossBridge, actually we have an alternative function - CModule.vfs.addFile(fileName:String, fileData:ByteArray).
You only need to call the function to supply the data file needed before the line "CModule.startAsync(this);".
And for the data file itself, you can use AS3 code to load. No matter using which ways, treat them as ByteArrays. Once they are loaded or ready, call the function "addFile".
You can check the source code for details:
https://flaswf.googlecode.com/svn/trunk/flaswfblog/Tutorials/CrossBridgesupplyFile/
Sunday, November 3, 2013
Migrating from Alchemy to FlasCC/CrossBridge - Simplify the File System Using CrossBridge's "addFile" as an Alternative to "supplyFile" in Alchemy
Labels:
CrossBridge,
FlasCC,
source,
tutorial
Subscribe to:
Post Comments (Atom)
Oh, I am sure that I will use this function. I think that it is very helpful. If you need a help with writing, use the http://proofreading-services.org/proofreader.php. Best wishes for you.
ReplyDeleteAh, I never understood programming – that is why I went for business studies – and now I am almost done with that too. I have just ordered my dissertation from an MBA Dissertation Service – and as soon as I receive it, I will submit, and be done with my studies. Anyway, I do have a friend who is a programmer. I will share this post with him - I am sure he will find it useful.
ReplyDelete