Posted by yankeedoodle in SWF Studio V3 on Feb 21 2008, 04:16 am

Hello,
I have tried to use the specialFolder to get the folder for both desktop and mydocuments.
i have a dynamic textfield called page_text and when clicked, i get an "undefined" for the r.result
Please help me my code is below :

var r :Object = ssCore.FileSys.specialFolder({folderID: 'MyDocuments '});
nextbtn.onRelease = function() {
temploc= r.result+"\\"+_root.holder_mc._currentframe;
page_text.text=r.result;
}
Managed to solve this by adding the items in bold

ok my next question is taht if i have an object of datatype byteArray can i write it to a file? if yes, what is the command i should use?

thank you
murtaza


Posted by yankeedoodle in SWF Studio V3 on Feb 21 2008, 05:34 am

both of the below give me null again.
why does it work erratically?
please tell me if i am doing something wrong

var r = ssCore.FileSys.specialFolder({folderID:'Desktop'});
ssDebug.trace(r.result);
var desktop:String =r.result;
trace(desktop);

var r:Object = ssCore.FileSys.specialFolder({folderID:'desktop'});
ssDebug.trace(r.result);
var desktop:String =r.result;
trace(desktop);


Posted by mbd in SWF Studio V3 on Feb 21 2008, 09:50 am

Are you using SWF Studio 3.4 or 3.5? You mentioned ByteArray, which is AS3-only. 3.4 includes Flash Player 9 but does not support AS3. The 3.5 beta does support AS3.

In either case are you enabling synchronous commands? Check my signature for the FAQ.


Posted by mbd in SWF Studio V3 on Feb 21 2008, 09:56 am

Sorry, forgot your other question. In 3.5 there is a new command that will let you write a binary file. To do it you need to use our conversion function to convert the ByteArray to a hex string that you pass. The conversion functions are currently available in the thread for downloading the 3.5 beta as two AS files (one for AS1/AS2 and one for AS3). In the release the conversion functions will be part of SWCs that will be installed along with SWF Studio, and you'll need to import the new classes.

The conversion from ByteArray is necessary since Flash doesn't have a way to directly pass an instance of the class to the container (SWF Studio player in this case).


Posted by yankeedoodle in SWF Studio V3 on Feb 22 2008, 10:27 pm

Hello,
yes I have that synchronous command thing turned on...and even the debug mode option is turned on..also what i did was i placed a text field to get the value..but to no avail...
if you can, i would appreciate it if you could send me a fla or just include a full working code as text so i can copy and paste and see if it works and determine what i did wrong with the imports and all....
i have downloaded 3.5 beta and am using that for now.

as for the byte array thing, im not sure if it will work..cos i read northcode's post of the AS files for as2 and as3 to convert Byte to Hex...i think it works..i am not sure though...will have to check that again.

thanks
murtaza


Posted by mbd in SWF Studio V3 on Feb 23 2008, 12:59 am

Here's an example. If you haven't used an SPX file before, it's a SWF Studio version of a ZIP file. In this case the SPX contains the SPF (SWF Studio project file), the FLA, and the SWF.

If SWF Studio is installed and you double-click an SPX file, SWF Studio will open, create a folder with the same name as the SPX file in the same parent folder as the SPX file, then extract the contents of the SPX into that folder. It will then open the SPF file, ready for you to build your EXE.

1. Download the attached SPX.
2. Double-click the SPX.
3. Once SWF Studio opens, press Ctrl+Enter. That will build and then launch your EXE and display the Trace tab all from that one key combo.

You'll need the 3.5 download in order to use AS3.

You mentioned ByteArray so I assumed you were using AS3. The attached example contains a Flash CS3 FLA and publishes the SWF for AS3.

As for the ByteArray to hex string conversions, are you saying it might not work for your case, or that you're not sure if they work? I can only assure you that they work.

If you need to read a file into AS3 I recommend using URLLoader rather than FileSys.readFileBinary. The readFileBinary function is fast by itself, but it has to get the data into Flash, which can be a little slow, plus you need to convert the hex string into a ByteArray to manipulate data more easily. The conversion adds another slow down. Because the Flash Player uses URLLoader natively they don't have the intermediate steps that we have when getting data into Flash and into a usable format. URLLoader will load the data into a ByteArray very quickly.

When writing data out you have no choice but to use the conversion function and then pass the data through to the SWF Studio player. For smaller files (less than 1MB) you probably won't notice it being slow. With larger files you'll begin to notice the lag.

If you're reading and/or writing binary with AS2, I recommend keeping with smaller files. AS3 is highly optimized when compared to AS2, and you'll notice it with the conversions. We tried to optimize as much as we could, but AVM1 just doesn't stack up to AVM2 in performance.

attachments: specialFolder.spx  


Posted by yankeedoodle in SWF Studio V3 on Feb 27 2008, 08:49 pm

Ok I got it to work but the thing is a simple pdf file with 3 jpg images of file size 20kb each takes forever to write to my disk. The conversion process was taking too long i think and then finally i saw the pdf on my desktop.

Thanks for helping me make it work. but is there a faster way?

thanks again


Posted by mbd in SWF Studio V3 on Feb 27 2008, 09:45 pm

In AS3 20KB should take very little time - you _might_ notice a pause.

Take a look at the example I've attached. It reads in a 30KB SWF and converts it into a ByteArray. Then it stores the time, converts the ByteArray into a hex string and executes writeToFileBinary, and displays the elapsed time upon completion. When you run this test what time do you see in the SWF Studio Trace window?

I saw a time of 50 milliseconds. If you're not seeing that kind of speed in your application, I'm guessing there's something else causing the slowdown.

attachments: BinaryAS3_write_timing.spx  


Posted by @st@l@vist@ in SWF Studio V3 on Feb 28 2008, 09:40 am

mbd, Quick question: Why for some variables in BinaryAS3.as you use type Number instead type Integer?

p.s.: Northcode written the best ByteArray to HEX converter for AS3!!! :)


Posted by mbd in SWF Studio V3 on Feb 28 2008, 10:09 am

Thanks :) I optimized the code, but Dan really brought byteArrayToHexString to another level.

Check out this post from Sho Kuwamoto (Macromedia/Adobe):
http://kuwamoto.org/2006/06/15/avoid-ints-in-actionscript/

Plus converting code from AS2 to AS3 and back (something I do a bit of) is easier if I stick with types that are common to both.


Posted by @st@l@vist@ in SWF Studio V3 on Feb 28 2008, 11:58 am

Another level it's low level? It's possible? :confused:
...
Sho are cunning man :)
The following code are not equal:

var i:int = 100;
i /= 7;var n:Number = 100;
n /= 7;
Replace the second code to this:
var n:Number = 100;
n /= 7;
n = int(n);
And I think that [FONT=Courier New]int.MAX_VALUE[/FONT] is very big for any loop :)


Posted by mbd in SWF Studio V3 on Feb 28 2008, 12:26 pm

I was just using an expression, meaning that Dan's solution didn't just shave off a few milliseconds, but actually doubled performance.


Posted by @st@l@vist@ in SWF Studio V3 on Feb 28 2008, 12:31 pm

Ok, I now understand :) Anyway it's good news! :clap:

If I want to save the very large byteArray, I can make a few steps and progressbar.


Posted by northcode in SWF Studio V3 on Feb 28 2008, 12:34 pm

We added FileSys.appendToFileBinary to the most recent development build to let you add data to a binary file. This means you can chunk up your ByteArray and save it out in manageable chunks and display progess info as you save it. This will be part of the V3.5 release.


Posted by mbd in SWF Studio V3 on Feb 28 2008, 12:48 pm

And since we're on the subject, if you are using AS3 and need to read in a binary file I suggest you look at URLLoader. URLLoader can read a file as binary and provide a ByteArray MANY times faster than we can. Adobe built it right in the Flash Player, so there's no trying to get data into Flash and no conversion necessary.

Unfortunately, AS1/AS2 doesn't have URLLoader AND is slower than AS3 :(