Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-09-2008, 07:06 AM
Junior Member
 
Join Date: Oct 2008
Posts: 1
Default Saving causes Flash to Timeout

Hello SWFKit!

I have been having some troubles with saving using Flash CS3 + SWFKit Pro 3.4. When i try and save an object to a text file, it takes an incredibly long time to save, causes Flash to hang, and eventually brings up (after the allotted 60 seconds script time out) a time out window. If i press no, do not abort script - it immediately saves, and the program begins working normally.

Any ideas?
This is roughly the code that i use...
Code:
function save(){
	didItSave = false;
	objV = {details:details, Settings:settings, training:training, individual:individual};
	swfKitSave(objV);	
}

function swfKitSave(obj,fileType,fileTypeShort){	
	var filename = Dialogs.fileSave(fileType);
	if(filename){
		strace("save, filename = " + filename);
		if (filename.substr(-fileTypeShort.length,fileTypeShort.length)!=fileTypeShort && filename.substr(-fileTypeShort.length,fileTypeShort.length)!=fileTypeShort) {
			filename = filename + fileTypeShort;
		}
		SDWriter.write(filename, obj);
	}
}
This is the SDWriter.as
Code:
import SWFKit.*;
class SDWriter {	
	// primary types 
	public static var BOOLEAN_TYPE = 0;
	public static var NULL_TYPE = 1;
	public static var NUMBER_TYPE = 2;
	public static var OBJECT_TYPE = 3;
	public static var STRING_TYPE = 4;
	public static var UNDEFINED_TYPE = 5;
	public static var ARRAY_TYPE = 6;
	public static var UNKNOWN_TYPE = 7;
	
	public static function write(filename, value) {
		var fileStream = new FileStream(filename, "w");
		if (fileStream == null) return false;
		
		writeValue(fileStream, value);		
		
		fileStream.Release();
		return true;
	}
	
	private static function writeString(fileStream, value) {
		fileStream.write(value);
		fileStream.put(0);
	}
	
	private static function writeValue(fileStream, value) {
		var type = typeof(value);
		
		if (type == 'string') {
			fileStream.put(STRING_TYPE);
			writeString(fileStream, value);
		} else if (type == 'undefined') {
			fileStream.put(UNDEFINED_TYPE);
		} else if (type == 'number') {
			fileStream.put(NUMBER_TYPE);
			// the value can be either an integer or a double, so convert it to string
			writeString(fileStream, value.toString());
		} else if (type == "null") {
			fileStream.put(NULL_TYPE);
		} else if (type == "boolean") {
			fileStream.put(BOOLEAN_TYPE);
			fileStream.put(value ? 1 : 0);
		} else if (value instanceof Array) {
			fileStream.put(ARRAY_TYPE);
			fileStream.write(value.length);
			for (var i = 0; i < value.length; i++) {
				var v = value[i];
				writeValue(fileStream, v);
			}
		} else if (type == "object") {
			fileStream.put(OBJECT_TYPE);
			for (var i in value) {
				writeValue(fileStream, i);
				writeValue(fileStream, value[i]);
			}
			// end of object
			writeValue(fileStream, false);
		} else {
			fileStream.put(UNKNOWN_TYPE);
		}
	}
}
Cheers,
dmb
Reply With Quote
  #2 (permalink)  
Old 10-10-2008, 08:34 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: Saving causes Flash to Timeout

We cannot make your code work, can you send us a .fla file to support@swfkit.com? Thank you very much.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:23 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.