How to save a button's position and settings? - actionscript-3

I am trying to create an options menu for a game, where there are 2 buttons. One button is to disable all music, and the other is to disable all sound effects. When the button is clicked, it disappears with the .visible = false; code. The new button underneath is shown. When a person exits the game, I want the game to remember the settings, and which button is hidden.
Example: A person plays the game, but goes to options menu to disable sound. Sound is disabled, and the off button underneath is shown. The player exits the options menu, then exits the game. The player opens the game back up. The sound should still be disabled, and if the player goes to the options menu, the on button should still be invisible and the off button should be visible.
Could you please help me on how I can create this sort of system?

You should use 'SharedObject' class to store your data locally, then read it again on Startup.
See these examples as a start: example1, example2

Related

vimeo js api seekTo leaves the play/pause button visible

I have a pro account and I have stripped everything off the player. the play/pause button is of course fine but I want it to fade out after a second or so...
I built a little test player, to illustrate the issue. HERE
You can press play from the video or the external control. Once playing if you click the progress bar, that triggers a few calculations then seekTo the point in the video. This all works great.
The issue is that once you "seek" / click the progress bar, the pause button won't fade out.
I know I can't hide the play/pause button in favor of my own but this is pretty detrimental to the video having a huge button in the middle if the user seeks the middle...
I appreciate any help in advance.
You can capture the seek event (you already does in line 53 of your index.html player.addEvent('seek', onPlayProgress);) and place the following code to force the control to fadeOut after 2 seconds (you can play with it)
setTimeout(function(){
$('#player1').contents().find('#player > div.controls-wrapper').fadeOut()
}, 2000);

Why do I have to click the movie for my character to respond?

My movie has 3 frames, first one is the welcome screen with the play button, and after I press it and jumped to frame2 I have to click the movie for my character/player to respond and move by arrows. Same happens if I go back to frame2 from my game-over screen placed on frame3.
I use gotoAndPlay(); to navigate frames, naturally.
if it's something having to do with my code from frame2 i will post what it is required. I'd like to know why is that happening and how to fix it. THANKS!
Clicking your character gives it focus.
Only* what has focus receives keyboard events.
If you register the listener for the keyboard event on your character object, you have to click it first, before it receives those events.
However, the KeyboardEvents bubble up the display list and eventually reach the top most container which is the stage. This gives you two options:
Handle the focus yourself by assigning the object that should have focus to the stage.focus property. This is basically doing what the clicking does in your current situation.http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#focus
register your listeners at the stage
The user simply needs to click anywhere on the flash stage to add keyboard focus. Normally, a good way of achieving this is by using a start button, or something similar, for that first bit of mouse/keyboard focus.

Draggable menu containing non-draggable buttons with AIR

First off, I'm pretty novice when it comes to Flash and AS3.
I am trying to create a displayObject that contains 12 buttons for a mobile app. Since there are twelve buttons that will all open up into seperate menus they obviously all won't fit on a mobile devices screen. This is why I want to have all of the buttons on one display object that can be dragged up and down to show the buttons not currently displayed on the screen.
I am running into numerous problems while attempting this.
1) If I make the object containing the buttons draggable, which is behind the buttons, I can't click it through the buttons in order to drag it(unless I hit a sweet spot where there aren't any buttons but this isn't efficient for the user).
2) If I make the object containing the buttons draggable and put it in front of the buttons then I can't click the buttons in order to open the menus and access what is contained within them.
3) For some reason all of the buttons are seperately draggable when I don't want them to be. For example, I click anywhere on the screen (whether the touchID point is on a button or not) to move the entire list of buttons and if I happen to be clicking a button then, instead of moving the entire list, it moves that one button.
So the main question here is "How can I create a list of buttons and scroll through the list using a drag method (such as the settings menu on your phone) without dragging the buttons apart from each other." So the containing display object is draggable, and the buttons are clickable.
Some guy named Glenn does a good job with his example: http://rabidgadfly.com/2010/03/as3-clickable-button-inside-a-draggable-movie-clip/
However, if you click the yellow button in his example you can drag it out of the gray box. I want my button to remain stationary relative to the gray box. So you can move the gray box but the yellow button remains in the same location within the box but you cant drag the button around within the box.
I am not familiar with accelerometer events for the smartphones, but I do have an idea on how to fix this with regular actionscript 3 listeners. (You can just convert these to whatever is used by smartphone listeners)
A solution that comes to mind is to have a mouse down listener and a mouse up listener on the whole drag-able box. And when a mouse down event fires, you start a timer to go off in about a quarter of a second, and when it does you then set up a enter frame (or a timer based) function that fires every frame. This will update the whole box's position every frame corresponding to the current mouse location (your dragging box effect) and when the mouse up listener fires, it stops the dragging (and at this points, if the mouse is up, then the user is not touching the screen at all).
Also add a mouse click listener to every button. This way, with the quarter of a second timer, you KNOW that if the user simply wants to click a button, then they will click, leaving less that a quarter of a second between the mouse down and mouse up events (so that the dragging never starts) and the button is only clicked. And if the user holds the mouse down for more than a quarter of a second, then you KNOW that they must be trying to drag the whole thing.
This seams like the only way to differentiate between a user wanting to drag the box, and the user wanting to click a button inside it.
Obviously it does not have to be a quarter of a second, it can be any length of time that you want, it could even be no time at all, but then this might mess up things when people only want to click the button and accidentally slides it when clicking.
If you have any questions or problems, please comment and i'll try to help.

How to reactivate sounds from youtube after using SoundMixer.stopAll()?

I have an youtube video playing in a specific frame. After researching a lot and not being able to properly destroy the player when exiting the frame, I decided to put a SoundMixer.stopAll() in all frames that can be used to get out from the youtube one. That makes things right in most of cases, because to access the video again I must click a button that reloads the player and everything gets back to the start. But I have some thumbs on the right side of the page that when clicked open a large image, occupying most of the page and not showing the video button, but they have a close button themselves. When I click the close button that movieclip becomes invisible and the one with the youtube video becomes visible again (what's great in all other cases). The point is: the player kept playing in the background and when I close the image you can see it playing again, but without sound. The only way to make the sound audible again is clicking on the seek bar (because it isn't a flash component itself, differently of the play/pause button) or going to another frame (that not one from the thumbs/images) and coming back. How could I make the sound play again automatically when entering the frame? Help to destroy the player when exiting the frame is also welcome.

Flash buttons flicker continuously when compiled

I am looking for some help with Flash (CS5 version). I have a situation where if try to put a button on the stage with visible differences in the up/over/down/hit states, when I compile the document into a .swf, the button will continuously flicker through each state in order very quickly. Also, if I break the AS3 code in the Main class file, hidden parts of a slider bar component will flicker between visible and not. I'm talking Japanese-style, seizure-inducing flicker here. I've searched my code for recursive function calls and tried deleting and re-adding components and buttons, but to no avail. Any ideas on what could be up?
Well, it seems to me you aren't using stop() to stop the button at the frame you want.
If it isn't this, then there is some error with your ActionScript, which will show up in the output panel, so check that.
When you say 'button' is it an instance of the Button Class and have you set the instance type to Button?
i.e.
Select the button in your library panel, right click and choose 'Properties'. Then set the Type to Button.
Next, select the instance of the button on the stage, open the Properties panel and just underneath where you type the instance name you should see a drop down menu containing MovieClip, Button and Graphic. Set it to Button.