Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 13th, 2011, 08:10 PM
SquareCrow SquareCrow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 7 SquareCrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 26 sec
Reputation Power: 0
Question ActionScript 3 - Flash saves file on Windows, not Linux: FileReference.save()

The code below compiles fine on the Flex 4 SDK on Fedora 15. Mouse-click opens the dialog box, I click okay, and a file is saved, but the file is empty. I run the same SWF file (that was compiled on the Linux machine) on a Windows machine, and the created file contains the expected data.

I was thinking there was a permissions problem, but if that were so, why should Linux even let me save the file?

It is going to slow things down immensely if I cannot code something and test it on the same machine...

Code:
/*
    WriteTheFile.as
    Original code by Brian Hodge (brian@hodgedev.com)
    Test to see if ActionScript/Flash can write files
    */
    package{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.utils.ByteArray;
    import flash.net.FileReference;

	public class WriteTheFile extends Sprite 
	{
		private var _xml:String;

		public function WriteTheFile():void 
		{
				if (stage) init();
				else addEventListener(Event.ADDED_TO_STAGE, init);
		}

		private function init(e:Event = null):void 
		{
				removeEventListener(Event.ADDED_TO_STAGE, init);
				//Calling the save method requires user interaction and Flash Player 10
				stage.addEventListener(MouseEvent.MOUSE_DOWN, _onMouseDown);
		}
		private function _onMouseDown(e:MouseEvent):void
		{
				var fr:FileReference = new FileReference();
				fr.save("<xml><test>data</test></xml>", "filename.txt");
		}
	}
    }


Edit: Added missing line, var fr:FileReference = new FileReference();

Reply With Quote
  #2  
Old August 14th, 2011, 07:41 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 11 m 52 sec
Reputation Power: 3163
Facebook MySpace
Hi, are you using any form of debugging? There's a good chance that it may be producing an error you are not seeing without it. Out of curiosity, try this:

fr.save(<xml><test>data</test></xml>, "filename.txt");

I removed the quotes from the data argument so it would be seen as an actual XML object instead of a string. The reason I'm curious is because the docs for the save function say that Flash actually looks at what it's saving and can distinguish XML from a string. Seeing if that makes any difference.
__________________
Quis custodiet ipsos custodes?

Reply With Quote
  #3  
Old August 14th, 2011, 08:56 PM
SquareCrow SquareCrow is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2011
Posts: 7 SquareCrow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 26 sec
Reputation Power: 0
A browser problem instead

Quote:
Originally Posted by Tann San
Hi, are you using any form of debugging? There's a good chance that it may be producing an error you are not seeing without it. Out of curiosity, try this:

fr.save(<xml><test>data</test></xml>, "filename.txt");


I can invoke the Flex SDK debugger with the 'fdb' command, but it is quite crashy. The Flash Debugger Player on its own seems fine.

I understand that save() understands several datatypes. I had tried several with the same results. Flash's ability to parse datatypes was not the issue, see below:

I ran the unchanged SWF from the Flash Debugger Player, without the benefit of the browser, and it worked. That means my problem is the browser, possibly owing to a shady procedure I performed to install the 64bit Flash plugin. Speaking honestly, I did not completely understand the directions I was following.

My workflow is fixed, but folks who installed plugins in this way may be excluded from enjoying my work. Is it wrong to dismiss this as an edge case?

Reply With Quote
  #4  
Old August 15th, 2011, 05:04 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 6,663 Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)Tann San User rank is General 33rd Grade (Above 100000 Reputation Level)  Folding Points: 14767 Folding Title: Novice Folder
Time spent in forums: 1 Month 1 Week 3 Days 20 h 11 m 52 sec
Reputation Power: 3163
Facebook MySpace
Well, personally I think it's alright if it only affects those that followed the same process. Definitely needs testing in other browers or at least with a non beta version of the Flash plugin. I'd be wary of saying "yes, it's definitely the plugin" but it could well be ^_^

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > ActionScript 3 - Flash saves file on Windows, not Linux: FileReference.save()

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap