Saving object state in flash application - actionscript-3

i want to write an online application with adobe flash CS6 and Actionscript-3, which is like an online puzzle, but i need to save position of every moving object, for example user moves an object to a new position and i want to save that object state and next time that user loads the page, this object will stay at last state that user placed into
I've tried everything in my mind and still no clue!
thanks

Related

Save picture of current screen to disk AS3

I want to add a button to my flash game (AS3) and on click it saves a picture of the current users whole screen and saves it to pictures/disk automatically, but I don't know how to do that, I know how to add the button to the UI and add a click event and all that, just need to know how to make it save a picture of the current screen to disk (doesn't have to be just the flash screen, can be the WHOLE screen of the users pc, either way works!)
I was on my way writing you the answer but I found this post have a better explaination: Is it possible to capture the screen and save the image in actionscript 3?
"Yes, it's possible.
Draw some display object to a BitmapData (the stage, for example) and crop it if neccesary (the second param of BitmapData::draw will help you out here).
Then, convert the raw pixel data to JPEG or PNG using some encoder. I'm sure up to this point, this is what those tutorials will explain you how to do.
Now, the third step is different but simple enough. Instead of sending the image data to a server side script, use a FileReference object. Since Flash Player 10, it has a method called save, that prompts the user to save a file locally.
Since this is a desktop app, you could also make it an AIR app. This will give more direct access to the file system and other features, in case you need them."

cocos2d-x pause game on background with pause screen

I am trying to figure out how to implement a pause screen on background. In my game scene I have a method called pauseGame. I set this up so that the user can click on pause button while playing and menu comes up asking them if they want to resume or go to main menu. Now when the phone goes into the background I want to also call this same function in my game scene so that it will show that menu so that when the user comes back to the app they will be able to resume instead of it automatically starting. I have googled for hours now and tried a few things but the only thing I am able to come up with is to call the directors pause() method from the app delegate. Which is what is happening any way but I need to call the pauseGame method of my game scene. Is there an event that I can listen for in the game scene or is there a way to call my pause from the appdelegate. I just cant seem to find an answer for this one.
App Delegate has this function, void AppDelegate::applicationDidEnterBackground(), which gets called every time app enters background.
You can access current scene by using this,
Director::getInstance()->getRunningScene(); cocos2d-x 3.0
CCDirector::sharedInstance()->getRunningScene(); cocos2d-x 2.x //Not entirely sure of the syntax, pls to check
After right typecasting and importing the appropriate header file, you can call required function from here.
Also,
AppDelegate also has, void AppDelegate::applicationWillEnterForeground(), which gets called every time app enters foreground.

addFrameScript does not work correctly with Air 2.6

I have coded two programs using flash cs5.5. Both of them use addFrameScript to organize the code on each frame.
The first one I exported on Air For Android and had no problem with it.
The second one I exported on Air 2.6 and a problem occurred.
If I go from frame to frame in order (using gotoAndStop()) then frame script loads perfectly.
But when I use the same method (gotoAndStop()) to go back to a previous frame, all of the stage instances on my lower layers are not loaded properly so I get ERROR 1009: Cannot access a property or method of a null object reference
Funny thing, when I move them up to the first two layers, things start working again.
But I still want to keep them in their own layers. Some help please?
Thanks in advance
EDIT 1:
I just found out that if move them up to a new layer then the older elements in that layer will not be loaded properly. It's like only the first few children of the display list are loaded.
EDIT 2:
If I change it to Air For Android, the problem disappears !! my mind is blowing right now

Why would a keyframe in Flash fail to update an object's position as defined in the keyframe when the play head is sent to that frame?

I have a background MovieClip in a custom button class, which moves the play head to a different frame (via gotoAndStop("framename")) depending on which mouse events it receives.
When the mouse up event is received, it sends the play head back to the "release" frame, where the background should shift back to its original location, but instead nothing happens and the background remains where it was. It's as though Flash is not honoring the background's position defined by the key frame it enters.
The only workaround is to add a frame script to each frame which manually sets the x and y position to what it should be, but this defeats the purpose of using keyframes for the position.
What is going on?
Try calling event.updateAfterEvent(), it's supposed to
Instructs Flash Player or Adobe AIR to render after processing of this event completes, if the display list has been modified.
from here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#updateAfterEvent%28%29
This appears to have been a bug in the Flash IDE, specifically some kind of corruption in a timeline layer.
The corruption originated in Flash CS4, but persisted when opened and compiled in Flash CS5, which is why I suspect it was some kind of content-generation bug, rather than something specific to either IDE version. The IDE probably gets confused when you construct the timeline out of order or drag things around, rename things, copy things in from other files, etc. I think, specifically... it was the fact that I copied this particular object in from another file. And it wasn't even a complex object, it was just a MovieClip that contained a rounded rectangle and had a drop shadow applied, seriously.
Steps I took to resolve the issue were to remove any classes associated with the library item, reverting it back to a standard MovieClip. I then completely removed the problematic layer. I then reassigned the class to the library object and exported it for ActionScript. Finally, I rebuilt the layer from the first frame, adding subsequent keyframes as necessary. I reapplied filters, and adjusted the clips location on each frame.
Now, everything is functioning as expected. The clip's position, filters, etc. are all updated as expected when the playhead moves to any frame. It's working now as expected, so I wasn't doing anything wrong or not possible. It simply must have been some kind of incrementally constructed key framing confusion within the data structures of the IDE. Glad it's working now.

AS3 - how to start all over again a flash movie

This may be very simple, but I have no idea how to do this.
I created a photo gallery in AS3, everything is on one keyframe. In this photo gallery I have a link to home. My goal is, when someone clicks the "home" link I want everything to start over. Any ideas on how to do this in AS3?
Appreaciate it.
L.
call flash player container
usually the HTML page and use JavaScript to reload the flash player
flash.external.ExternalInterface.call(jsFuncRestart);
jsFuncRestart is a JavaScript function in the HTML file
and now in the js function just create a new object and replace the current flash object
with the new one
You probably animate everything with as3, right? Then just make a reset function that puts all the images back to their original place and start the animation all over.