I have this flash game that I've been working on that works out of the browser, and I'm looking to get it to save it's progress.
I've seen multiple flash games that have accomplished this, and It appears as though they've done this client-side, and I'd like to do the same.
My game consists of 1 mxml file and a number of .as files and I compile it from the command line using flex sdk.
What do I have to do to be able to save save my game's data?
As others have mentioned, SharedObject is the tool you'll use for this.
The basics of this are to initialize a reference to a SharedObject using its static method .getLocal() first:
var mySaveData:SharedObject = SharedObject.getLocal("SomeSaveName");
The String given to this method should not contain spaces.
Once you've done this, you'll be able to use mySaveData.data, which is basically a simple object that you can attach properties to on the fly (it's dynamic):
mySaveData.data.levelsComplete = 2;
Once you've done this, you'll be able to reference that value later on using the same process:
trace( mySaveData.data.levelsComplete );
For simple stuff you can use SharedObject
One way is to use flash's SharedObject to save values in to a 'flash cookie' on the client. Example can be found here: Actionscript 3 saving currentframe location to local hard drive?
Related
I would like some assistance with batch image processing - I need to save an vector ai image to fla+html+swf file formats using a script - What I have done is to open the software and open a folder with these image's in. Please advise how i can write a script to assist with this process as I have alot of images I have to save.
I need to save it in actionscript 3 and actionscript 2, so if there is a script that convert it from actionscript 3 to actionscipt 2 that can be usefull aswell.
Please help :)
If I understand you correctly, you want to be able to put an image found inside an .AI-file (Adobe Illustrator) and automatically place that image into two newly created .FLA-files (one with AS3 set as default programming language and one set with AS2 as the default programming language)?
There is no quick and easy solution for this, it would require a combination of a "main app (python, c#, java or similar)" combined with "JSFL" to do what you want. And in the end that app would probably become very complex.
If you can skip the requirement of each ai-file becoming a unique fla-file you can just import all the images into a newly created FLA-file. But if that's not an option, then you're most definitely out of luck :\
If one creates an ActionScript only project in Flash builder, one can set things like stage size and framerate as metadata like this
[SWF(width='400', height='300', backgroundColor='#ffffff', frameRate='30')]
as described here: http://www.adrianparr.com/?p=36
I wanted to ask what other settings i can set using such metadata? is there somewhere a complete list?
See Adobe's documentation:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html
I'm programming an AS3 application which loads an external SWF file to a movie clip in my stage. I need to read a variable inside the embedded SWF. I think I can, probably, do this through the bgURL, but I can't figure out how.
How can I read a variable inside the embedded SWF?
var bgLoader:Loader = new Loader();
var bgURL:URLRequest = new URLRequest("file.swf");
bgLoader.load(bgURL);
addChild(bgLoader);
That would be something like trace(MovieClip(bgLoader.content).Player.played);, but make sure you access the content in the Event.COMPLETE handler:
bgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,bgLoaded);
function bgLoaded(event:Event):void{ trace(MovieClip(bgLoader.content).Player.played) }
bgLoader.content returns a DisplayObject, but you need to access you content as a MovieClip. To do so you use casting.
This is presuming your external swf is also AS3 (good point Teo.sk !)
This bit: _root.Player.played looks like AS2. Unfortunately you can't access
variables form a loaded AS2 movie directly.
Still, you can use Local Connection class to send variables back and forth betwen
AS2 and AS3. Luckily Grant Skinner wrote a nice little utility called SWFBridge
to make this easier
Not sure if this is possible but I would like to reflect a swf or swc file selected by the user at runtime to find any classes that implement a certain interface. Can this be done or do you actually need a reference to the class you want to reflect using describeType();
Note - this would be done in actionscript.
Thanks,
You can inspect a swf for the classnames (Source) and then use describeType on them to find the ones which implement the interface(s). But this is probably slow. You can try to extend the getDefinitionNames code to get around the describeType and extract the needed info from the bytes...
Hello is it possible to write new id3v2 tags to a mp3-file through actionscript?
Normally you can read/write tags like artist,album,genre...
But I would like to add for example the tag "atmosphere = smooth".
Thanks
Unfortunately, there is no working library to write/edit ID3 tags in ActionScript, or at least I wouldn't know of one.
But you can access and edit the file as ByteArray. Check the ID3v2.3 specification to find out which bytes to read and write.
There is a c/c++ project called id3lib on sourceforge. Should you consider porting this to ActionScript using Alchemy, I would be very much interested in the resulting product ;)