| Ultrashock Forums
• AIR in Flash CS3 save text input to file |
|||
![]() |
||||
| Search this Thread | Thread Tools | Display Modes |
|
|
|||||||||||||||||||||||||
![]() |
Ultrashock Member Comments:
17 Creative Assets
|
2008-06-06
#2 |
||
|
Here is an example of how to write a simple text file... ActionScript 3.0 Code:
|
|
|
|
2008-06-08
#3 |
||
|
Hey Nutrox, alright there. Thanks for the code. Will have a crack at it later today. Cheers |
|
|
|
2008-06-09
#4 |
||
|
Hi Nutrox, Just tried the code. I'm sure it's right having looked at the file api but I'm getting a 1046 error (type was not found or was not a compile-time constant). Is this down to how the file stuff is imported at the top? Cheers |
|
17 Creative Assets
|
2008-06-09
#5 |
||
|
I think that is probably the cause of it. Flash doesn't automatically import the flash.filesystem.* classes, so you need to do that manually.
|
|
|
|
2008-06-09
#6 |
||
|
Thanks for the quick response. I've added the path to the classes manually from the publish settings but that's giving the same error. Is it added in a different way? Thanks |
|
|
|
2008-06-09
#7 |
||
|
I've tried different import rules and gone to the publish setting and changed the path and made sure that it points to the right classes folder. Still no luck I keep getting the 1046 error. I'd appreciate any help on this. Cheers |
|
17 Creative Assets
|
2008-06-09
#8 |
||
|
Have you managed to publish any AIR SWF files before? It sounds strange that Flash should be moaning about those classes if you are importing them. Are you sure the problem isn't somewhere else in your code?
|
|
|
|
2008-06-09
#9 |
||
|
Yeah I've managed to publish air files before, based on tutorials and sample apps from adobe's website. I know it is a bit wierd no one seems to be having this problem. I wonder if it needs to use the package { and then inside, Code:
package {
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
public class Main {
public var file:File = File.desktopDirectory.resolvePath( "my-new-file.txt" );
public var stream:FileStream = new FileStream();
public function Main(){
stream.open( file, FileMode.WRITE );
stream.writeUTFBytes( "Hello. This is some text in a file." );
stream.close();
file = null;
stream = null;
}
}
}
|
|
17 Creative Assets
|
2008-06-09
#10 |
||
|
Ok, keep that class because that is the way you should be doing things. You have forgot to extend Sprite or MovieClip that is all, document/main classes need to extend one of those. Code:
import flash.display.Sprite;
public class Main extends Sprite {
|
|
|
|
2008-06-09
#11 |
||
|
Yeay thanks, I've got no errors now and it's all working. Much appreciated and good learning experience. Cheers |
|
|
2008-07-29
#12 |
||
|
this overwrites whatever text is in my text file..how can i add to the file each time it is written to instead?
|
|
17 Creative Assets
|
2008-07-29
#13 |
||
|
Change the file mode to "append" Code:
stream.open( file, FileMode.APPEND ); |
|
|
2008-07-29
#14 |
||
|
thanks for the quick reply. now i just need to figure out how to get the values of my username and email forms to save to the file rather than static text. i tried: var Email=Email; stream.writeUTFBytes(Email); |
|
|
2009-02-28
#15 |
||
|
Hi, Could you please tell us how to import the flash.filesystem.* classes manually in flash cs3. I am eagerly waiting for your reply Chand |
|
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|


14 comments
| 8794 views

17 Creative Assets

Linear Mode