Xml :: Saving And Loading File With Flex?

Aug 25, 2009

I want to have a xml file for my configuration and so i have to load it from the same directory the swf file lies in and save it afterwards. I saw articles about filestreams in flex but my compiler didn't allow me to use the filestream. I use the open source flex sdk

View 3 Replies


Similar Posts:


Flex :: Saving And Loading Image To Local SQLite BLOB ?

Sep 8, 2011

I need to be able to save and load images into an SQLite database using Flex 4.5 for a mobile application. The use case is this:

Inside the view there is a spark Image object with a URL as a source

When user clicks button, the Image is saved to an SQLite db inside a BLOB field.

In a separate Image, the source is set to the ByteArray stored in the db.

The biggest question so far is this: where do I get the ByteArray for a loaded Image? I've tried debugging and inspecting Image, BitmapImage, and BitMapData but there's no sign of the byte array.... perhaps it's inside the ContentLoader? But that's null unless I enable caching.

I've done some research and there are no complete examples for how to handle this. I've written a simple View that anyone can copy and paste into a new project. It will compile without errors and can be used for testing. I will update this code as I get the answers I need so that anyone can have a fully working example of this workflow.The only caveat: I used a synchronous connection to the DB to avoid complicating the code with event handlers, I wanted to keep it as simple as possible.I will only mark this question as answered once it is fully functioning both ways.

UPDATE SEPT. 09 2011: The code below is now fully functioning in both directions (save and load). Here are some of the things I've learned: It turns out that the ByteArray of a spark Image can be found inside the LoaderInfo of the image itself. Like this:

image.loaderInfo.bytes

However, trying to set this ByteArray as the source of another image ( image2.source = image1.loaderInfo.bytes) results in this security error: Error #3226: Cannot import a SWF file when LoaderContext.allowCodeImport is false.Which is too bad because it would save so much time and processing power.the workaround is to encode the ByteArray using either a JPEGEncoder or a PNGEncoder. I used the JPEGEncoder which produces much smaller files. Here's how:

var encoder:JPEGEncoder = new JPEGEncoder(75);
var imageByteArray:ByteArray = encoder.encode(imageToSave.bitmapData);

Now the problem is saving these bytes to the DB. Saving them as they are now will not work once we read them out, I'm not sure why. So the solution is to encode them into a base64 string like this:

var baseEncoder:Base64Encoder = new Base64Encoder();
baseEncoder.encodeBytes(imageByteArray);
var encodedBytes:String = baseEncoder.toString();

So now just save that string into the BLOB field and later read it out. However, you have to decode it from a base64 string to a ByteArray like this:

var encodedBytes:String = result.data[0].imagedata;
var baseDecoder:Base64Decoder = new Base64Decoder();
baseDecoder.decode(encodedBytes);
var byteArray:ByteArray = baseDecoder.toByteArray();

Now assign the bytearray as the source of your image and you're done. Simple right?if you find any optimizations or alternative ways to do this.I will respond and keep this code updated if need be.

View 2 Replies

Flex :: File - Saving A Bytearray With Php Received From Air App?

Apr 5, 2011

I have an Air application with remote service in codeigniter.I'm trying to save a bytearray that I received from the Air app but when I save the data I get empty files with the correct filename.So there must be something wrong with my bytearray or the way I save the data.Does anyone have an idea what I'm doing wrong?I've debugged the Arraycollection I sent and the bytearray is definitely in there.

public function uploadImage($image)
{
foreach($image as $img)

[code].....

View 1 Replies

Flex :: Sqlite - Saving A File In Flex Air?

Aug 15, 2010

I'm trying to copy my SQLite file that is used in my Air app to user's selected directory using

var fileSaveDest:FileReference = new FileReference();
fileSaveDest.save(dbWorkedFile,'Inventory.DB');
dbWorkedFile is a File
dbWorkedFile = File.documentsDirectory.resolvePath("Inventory.db");

I tried this but the saved file isn't a valid SQLite file. Also, I was wondering whether it's possible to embed SQLite to Air? If so how can I import and export the database?

View 2 Replies

Flex :: FlashBuilder 4.5 Scroll Top While Saving Mxml File?

Oct 18, 2011

I have strange problem, when i try to save mxml file - flash builder scrolling to the top of editors page ? why ?it is the same problem like this

[URL]

View 1 Replies

Flex :: Upload Image Then Share Without Saving The File Using SharedObject Or Anything?

Jun 10, 2011

I'm currently working on a chat with uploading an image and sharing it. The problem is I can upload and display the image but I can't share it to the other side. Here is some code:

[Code]...

View 1 Replies

ActionScript 2.0 :: Saving Data And Loading Data From A .txt File?

Sep 24, 2006

I have read through Shared Objects but i couldn't get it work...

I just have to save my data, maybe array into .txt file and later on
retrieve from the same .txt file...

Anyone here have an example or some source code so i can have reference on it?

View 6 Replies

Flex :: Downloading A File From A Server And Saving It In A Specific Location Without User Intraction

Jun 23, 2010

I want to download a file from the server and save it in a particular location of the disk without user interaction. All this I want to do it in Flex.

View 1 Replies

ActionScript 3.0 :: Wait For The User To Save A File (xml / Datagrid / File Saving)

Dec 11, 2009

step1- I got an xml that is locally loaded(works fine)
step2- the content goes into a datagrid that is displayed (works fine)
step3- In AS3 I dynamically add some lines to this xml file(works fine)
step4- I save it locally (works fine)
step5-and want the datagrid to be updated..(works not-so-well)

So, in step 4, the data is saved into the xml file, but in order to finish the save, the user has to click on the "Save as" windows in order to have the file updated of course.. and that's where's my problem, how can i tell flash to wait till the user actually saves the file, before reload the xml file in the datagrid ? here's the code :

[Code]....

View 3 Replies

Flex :: Extract A Zip File From A Zip Archive Without Loading The Whole File Into Memory

Mar 10, 2011

Is there a way to extract a single file from a zip file in Adobe AIR?

I'm using NoChumps zip library to extract files from a zip. In this library the entire IDataStream is loaded into memory and after that you can extract file entries easily. In cases where the zip is 5 to 10MB there are no problems. But when the zip is 80MB, which many are, 80MB is loaded into memory. This causes the app to crash and run slow on mobile devices. According to the zip specification,

"A ZIP file is identified by the presence of a central directory located at the end of the file, this allows appending of new files. The directory stores a list of the names of the entries (files or directories) stored in the ZIP file, along with other metadata about the entry, and an offset into the ZIP file, pointing to the actual entry data."

Also, I do not have control of the size of zip files but most average is 60 to 100MB. Files inside are ~4MB.

View 2 Replies

Professional :: Saving And Loading Data To/from SWF?

Jul 23, 2010

I have created a simple flash animation for my employer. I basically have a square that changes color depending on which of three buttons are clicked. This is replicated about 30 times on the page. There is also about 15 circles that have a toggle button created so that when you click on the circle, they change between two colors. As I said, a very simple application.

Now, I need to save the data so that whenever someone new opens the swf, the current color combination is displayed. My way of thinking, with my limited AS3 experience, is that each button click, in addition to changing the color of a movie clip, should also send the data to a server. Then when someone opens the application fresh, I can use the URLLoader to load the most current data.

Am I on the right track, or am I missing it completely? I think I can figure out the URLLoader, but what code would I use to create the text file or xml file?Here is a snippet of my code:

var rtmColor:ColorTransform = f13335.transform.colorTransform;
var okColor:ColorTransform = f13335.transform.colorTransform;
var usColor:ColorTransform = f13335.transform.colorTransform;

[code].....

By clicking on either the rtm_13335, ok_13335, or us_13335 buttons, they will change the f13335 movie clip to the appropriate color (blue, green, or red). The default color is green.

What I would like to do is make the movie clip red, for example, then another person opens the swf, and the movie clip is red as opposed to the default green because I saved the current state to a text or xml file.

View 3 Replies

ActionScript 2.0 :: Saving And Loading Drawings?

Feb 17, 2009

i am working on a flash project, not ment for the web, i am creating an interactive map app.here is a section that involves the user to draw custom shapes ,lines and text over the maps.the problem is gettting the user to save this drawings so that the next time the application is started he/she can load the previously saved drawings.

View 1 Replies

ActionScript 3.0 :: Saving And Loading To A Database?

Jan 12, 2010

hey people wondering if there is a way to use AS3 to save and load to a database.

Specifically I have created a flash program for a teacher that runs tests for her students. When a student loads up the .swf they are prompted for their name. Ideally we would like to be able to save the progress of a student after he/she has completed a test and then use that data later. Is there a way to save data like this and call upon it at a later time?

View 8 Replies

Actionscript 3.0 :: Saving And Re-loading Data?

May 9, 2009

I've made a small application in Flash CS4 that I use when I'm teaching. Part of the application allows me to 'write' on draggable 'post-it' notes (using a draw function) and another part allows me to type text onto similar 'post-it' notes. how I could save the data that is written or typed in and then re-load it on another occasion? Am I out of my depth?My AS3 is probably intermediate level, I have some experience with SWF Studio and I'm beginner level with php/mySQL.

View 3 Replies

ActionScript 2.0 :: Saving And Loading Data

Jun 14, 2004

I've searched load of threads for info on this because for what I'm doing I need to save data to the local disk and then load it back up again as required. I'm using a local shared object to save data to and this works fine. Getting it back out again seems less straightforward.[code]Nothing appears to happen at all. The program continues with no traced output at all.

View 3 Replies

ActionScript 2.0 :: Saving/Loading Variables With PHP?

Jan 26, 2005

I'm trying to save a change to a text document (In this case a variable "Title" just to test) and then view the changes from another swf movie... In the end I'm hoping to build a client updatable flash site. In particular menu items... feature items & prices.

A Recap: a client types in the items, php/flash saves the changes to the text document, and site visitors can views those changes.

Something in my code isn't clicking:

My PHP is:

Code:
<?php
$Title = $_POST['Title'];
$toSave = "Title=".$Title;

[code]....

View 1 Replies

ActionScript 2.0 :: Saving And Loading Locally?

Aug 22, 2006

Is it possible that, when I publish my flash program to the internet that the user can save and load text to a text file somewhere on his computer?

View 2 Replies

ActionScript 2.0 :: Saving And Loading Bitmaps?

Jun 5, 2007

Ok I wrote an application where I have panels that the user can draw on, kind of like paint, but they can create panels. Now I want them to be able to save and load their work. Using Quasimondo's bitmap exporter, I was able to save a bitmap (200x200), and the application prompts the user where they were to save the image file. However, my problem is that the user will probably have 6-12 panels to save, and so I want the program to save all those panels so they can be loaded later.

Now in order to load, I don't want the user to manually select each panel to load. I want the user to select one file and it will load all the images into the panels. I was thinking about maybe loading a zip file and flash would extract the images and load them, but I don't know if that's possible. I think the user would need to select an XML file,which would direct Flash to what files to load and in what order. For this, and I'm assuming when it saves the flash application/php, it would need to write a new xml file.So I guess what I need to know how to do is:- How do I get flash to save several images to the server or the users hard drive- flash to generate an xml file- is there any way to make flash combine all the files into one file so that the user doesn't have to deal with several files?

View 3 Replies

ActionScript 3.0 :: Saving And Re-loading Data

May 9, 2009

I've made a small application in Flash CS4 that I use when I'm teaching. Part of the application allows me to 'write' on draggable �post-it� notes (using a draw function) and another part allows me to type text onto similar �post-it� notes. Does anyone know how I could save the data that is written or typed in and then re-load it on another occasion? Am I out of my depth? My AS3 is probably intermediate level, I have some experience with SWF Studio and I�m beginner level with php/mySQL.

View 3 Replies

ActionScript 2.0 :: Saving And Loading A Dynamic Text Box?

Aug 19, 2009

I was wondering if there is a way to save and then load a message of a Dynamic text box.

View 4 Replies

ActionScript 3.0 :: Loading In An Image At 300 Dpi Manipulating It And Saving It As A 300 Dpi Png

Feb 27, 2012

I have a project where the user uploads a large 300dpi image, then manipulates it (drag it, rotate it, position it). And the user can reuse this 300 dpi image, basically to make something like a t-shirt pattern. Then when the user is ready, they save this t-shirt pattern, and the save format is a large 300dpi png. This saved png file is for printing.  Now I figure I can have PHP take bitmap data (as binary I assume) and the php can create the png. Is it a good idea to use Flash for this?  I will have to scale down the users loaded 300dpi image so they can position. Then I assume scale it back up when it comes time to save Does anyone think Flash can't handle this?

View 4 Replies

Flash :: Saving Dynamic Drawing, Then Re-loading?

Jan 30, 2010

the short version of what i need to do - via AS3 and PHP - is a user can come to this project and draw something. drawing's no problem, that's done. my issue is figuring out how to take that drawing data, converting it into something i can save to my database ... then reload said data and recreate it on the stage when the user "loads" it.

i guess i'm just searching for a way to take drawn data (just using typical as3 drawing methods) and breaking it down to a string, then bringing that string back in and recreating it. i'm not super versed in ByteArrays - which i suspect is where my answer lies.

user doesn't need to adjust any of this after it's loaded, fwiw. i'd just like to send this drawing data out - then bring it back in and place it back on the stage.

View 2 Replies

Flash Cs5.5 :: Saving/Loading To A Mobile Device?

Feb 6, 2012

I am pretty fresh into working with mobile at all here but i am having no luck finding solid info on the basic principles of file saving/loading locally on a mobile device (specifically android).

View 1 Replies

ActionScript 2.0 :: Saving And Loading Variables Using Buttons

Jun 21, 2011

So I want to do saving and loading for variables. I.E. I want to save a variable by pressing the save button. When you use the "load" button, the variable is what it was when it was saved. I've tried this but it didn't work...

Code:
//Code on the frame
var saveState = SharedObject.getLocal("Cookie");

//Code on the save button
on (release) {
_root.save.gotoAndPlay(2);
savefile.data.blah = _root.blah;
savefile.flush();
}

//Code on the load button
on (release) {
gotoAndStop(3);
_root.blah = savefile.data.blah;
}

View 3 Replies

ActionScript 2.0 :: Saving / Loading Files From / To Flash

Dec 16, 2002

I know this can be done, but not sure how. I have seen a program that basically has its own fscommands and must compile them itself. Does anyone know how you would do this. The program i refer to is [URL] flash studio pro. There are other programs out there like this but these all cost money for commercial use.

View 1 Replies

ActionScript 2.0 :: Saving An XML File With A Certain Passed File Name To PHP

Sep 18, 2006

i used a kirupa tutorial to save an xml file.

[Code]...

at the end of this... on my server must appear 2 files: ex1.xml and ex2.xml. PS: when I run the first script, a blank IE page with the name of the php file appears... how can I get rid of it?

View 1 Replies

ActionScript 3.0 :: Saving And Loading Data To Local Machine?

Feb 1, 2012

I am new to Flash/ActionScript, and I am having a lot of fun creating a project in Flash. am working on a character tracker (yes I am totaly geeking out) an I was wondering how to save the data I have entered into the project (hit points etc...) and load it back next time I opened it. The data would be saved on my local machine. How can I get Flash/ActionScript to do this?

View 11 Replies

ActionScript 2.0 :: Saving / Loading External Text Files

May 27, 2004

i know you can load them in as variables... but is there anyway SAVE a variable as a text file (overwriting old one as well)

View 1 Replies

ActionScript 3.0 :: Flash CS5 / CS4 Game Saving / Loading Tutorial

Apr 8, 2011

Somebody give me some tutorials sites for saving and loading game.

View 1 Replies

ActionScript 2.0 :: Saving/loading External Text Files?

May 27, 2004

i know you can load them in as variables... but is there anyway SAVE a variable as a text file (overwriting old one as well)

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved