ActionScript 3.0 :: Toggling Visibility On Multiple Elements?
Dec 6, 2010
I'm working on a project that has multiple movie clips and I want to have three buttons, you press button1 and it displays mc1, then you press button2 and it displays mc2 and also hides mc1. same with others so if mc1 is on and you press button3 it will turn mc1 off and turn mc3 on. so any combination only turns on its respective mc.
how to do this without an extraneous amount of code. It will eventually have over 20 buttons, so I want to keep code clean if possible.
View 4 Replies
Similar Posts:
Dec 26, 2008
I've got several layers in the timeline and I'd like to know the most effecient method to toggle the visibility of any one of the layers when a user clicks a button I have on the form.
The layers are all simply graphics that have been imported and the only functino they have on the time line is that they each come in at different times during the playback of the movie. I'd like to have the ability to toggle the individual layer when a user clicks the button.
View 3 Replies
Jan 24, 2009
I have a question, but it needs a little backstory and explanation to make sense. I've searched a lot of places for an answer and have only come up short.I'm using Flash 8 and AS2.A few months ago I made a somewhat complex interactive doll.I came up with the idea to have the blouse have these massively poofy sleeves, and then have a jacket be tight fitting. So when I move the movieclip of the jacket over onto the blouse, the sleeves will disappear, kind of like real clothing, where you can bunch up fabric to fit.I did this by cutting the shirt into three separate movieclips and coding them to move together, so when the jacket moved onto the specified coordinates, and the shirt was established on the base, the sleeves movie clip would simply disappear.
Below is part of the action script connected to the jacket.[code]When you move the jacket away, the sleeves are still invisible. And if you have the shirt and jacket on, and you click on the underwear button to view the undergarment movieclips, the sleeves and sides are visible again, simply because that is the coding for the "drawer" buttons. Simply clicking on the jacket or the shirt creates the desired result, but it doesn't look very clean.I've tried using similar script to the above, to make the visibility true, but it's only served to make it visible all the time, even if the drawer buttons make it invisible.[code]
Is there a script I can use so the sleeves disappear once the jacket is on, but immediately after moving the jacket away, the sleeves reappear? And at this point, is there a way to keep the "undress" button from affecting this, but still keep the sleeves invisible when it reveals other garments and the shirt is on the doll?Should I be making the sleeveless shirt another frame inside the shirt movieclip, rather than a completely separate movieclip? And if so, I know how to go and stop to the next frame using a button, but not sure how to do it with a movieclip.So, I still couldn't get it to work with the shirt as 3 separate movieclips. Instead, I made it all one movieclip with different keyframes, each combination possible on its own frame. And when the jacket moves onto the shirt, it goes and stops to frame 2. When the jacket is not on the x coordinate, it goes and stops to frame 1 again.
View 2 Replies
Mar 26, 2012
I am using YouTube JS API to play videos on my site. Video is played on the dialog box. When user closes the dialog box, player is stopped - player.stopVideo(); But when user clicks again on video icon again, dialog box appears
In Chrome, the video starts playing at the previous position - OK Firefox, the video starts playing from the start irrespective of where user left it last time. - NOT OK
As per my requirements, I want the Chrome to behave as how firefox is behaving.
Here's a fiddle: [URL]
View 1 Replies
Oct 7, 2009
How do you deal with toggling multiple buttons? When one button clicks on the previous active button(s) turns off.
What is the standard practice for dealing with this? Have listeners on all the buttons checking if their name is in an activeButton variable (which seems process intensive with all those listeners going)
A FOR loop to go through all the buttons states and check the activeButton variable when any button is clicked?
That is two ways I have done it but I think there has to be other ways that might be more elegant.
View 3 Replies
Apr 3, 2011
What I am trying to do I think is pretty simple.
Consider this code:
ActionScript Code:
var imageContainter:String;
var fileName:String;
[Code]....
This code appears to be working. I'm dynamically creating a bunch of movieclips that each contain an image. The also code stacks each clip on top of each other.
I'd like to be able to now set the alpha or visibility of all of those movieclips to 0 or false, except for the first one. I have other code that will set specific movieclips to display based on mouseEvents.
How do I refer to all of them? And should I be using arrays as well?
View 7 Replies
Jul 12, 2010
I have created a timeline with visibility button against each column. The timeline.swf is loaded into two empty movieclips to create a two-screen operation. Everything works fine except, I cannot for the life of me get the visibility button on the first swf to affect the visibility for the column on the second swf.
[Code]...
View 5 Replies
Jun 21, 2009
I'm trying to detect multiple elements in an array. My countTicks:Array contains mostly numbers and below you can see I'm using "logical AND" to try and find them.
The problem is, once I have more than 2 "logical ANDs" (&&) the trace gets called. Which it shouldn't because the array wouldn't yet hold those numbers.
PHP Code:
countTicks = function(){
for (var i = 0; i < tickCount.length; i++){
if (tickCount[i] == 1&&2&&4&&5){
[Code].....
View 5 Replies
Jun 22, 2009
I am working on a booking/appointment program for a friend. The desired end result is this;A date picker is used to select the day.
A combo box is used to pick a service.Based on the service selected, a MC will load in various options/additions to that service.Another MC displays a schedule showing business hours (8:00 to 5:00) in 15 minute increments - based on both the date picker and the service selected and the option(s) selected (which determines length of time needed), available time slots are unshaded, requested but not yet approved time slots are shaded color 'a' (let's say medium gray), and booked time slots (after being approved) are shaded color 'b' (let's say red).I have the date picker working. I started a combobox which works, and controls the timeline of the options MC - where I am currently hard coding options as radio buttons and/or check boxes. I would much rather have this dynamically generated instead of picking a frame of a MC with hard coded choices. I haven't started on the scheduler yet.
View 1 Replies
Nov 19, 2011
I have a tile-based platformer game under work, and I'm stuck on a problem with hitTesting:
//check all character collisions with levelHolder
for(var i:int = 0; i < levelHolder.numChildren; i++)
{
[Code].....
The problem here is that hitBlock only hitTests one block at a time, and when I test this: If you lean on a wall (press right arrow key) and go downwards you can go through the floor.
I need to make it so that I can test on multiple blocks at a time.
And I did try to replace hitBlock with levelHolder[i], but it gave an error saying:
ReferenceError: Error #1069: Property 0 not found on flash.display.Sprite and there is no default value. at Main/enterFrame()
I'm guessing that comes from the level array where 0 = blank block / empty space.
View 7 Replies
Jun 20, 2011
My aim is to copy multiple row content from Flex datagrid, to a clipboard enabling users to take pieces of information and pasting them were they are necessary. I bumped into a problem that in Flex (as far as I know) its not possible to paste whole array of information in the clipboard. At the moment, I pass selected datagrid items to a textfield, and then run "System.setClipboard(text_area.text);" I was wonderng if there is a way to pass it to multiple Clipboard directories, without overwriting previous entry, similar as when you can copy multiple items from different location into a clipboard, pile them up and then paste all at once?
View 1 Replies
Nov 2, 2011
I'm trying to apply a Move-Effect on multiple elements. They are moving all together but I prefer it in seqeunce.
<s:Move id="thumbMover" target="{thumb}"/>
private function addItemThumbs ( ) : void {
for each ( var item : ItemVO in _items ) {
thumb = new Thumb;
[Code]....
View 1 Replies
Oct 8, 2009
I have several text fields (with different numbers written on them) each inside their own movie clip. There is a background underneath all of them. What I want to achieve is to cut the shape of each of the numbers into the background. They should still be able to behave as separate movie clips.
View 3 Replies
Mar 21, 2010
wonered if someone could help me wih this one. Currently making a facebook game all in flash, it uses multiple swfs to make up the game and its elements for optimisation.
My question really is down to flash cache issue so we can make updates to various swfs that are going to be, site wide for users so the game doesnt break. Currently some users get older versions which breaks things if other swfs have chnaged how they communicate as an example.
I am aware of adding a query string onto the end to force to get the latest version.....however doesnt this make the use of a cache redudant as its being simply overriden? Would jsut like it to work as it should:) If theres a new version of a swf use it..if not use current one.
View 5 Replies
Oct 28, 2009
Does one normally use some sort of wrapper object to do so?
For example, if I have an array with 10 elements (for example, images that are gonna be linked), I can loop through the array and add them to stage with:
myArray[i].x = i * myArrayElement.width;
What if I wanted to position all of the elements yet keep them in the same positions relative to each other.
Can you do so with an array, I gather the answer is no. So if that's right, do people throw an Array into another object and the use that objects x property?
View 1 Replies
Feb 26, 2010
I got some code to make a video loop indefinitely with the nsvid4_loop function, but i want it t be toggleable via a button I am trying to set up a function to do that (vid4loopwitch).. i'm getting stuck though on how exactly to incorporate the one nsvid4loop with its event listener into the function for repeating it is probably pretty straightforward i'm just still learning my way around AS. check the code to see what i have so far.. i just need to know what i need to add to the vid4loopswitch function to get it going. it is really hurtin my brain
var nsvid4:NetStream = new NetStream(nc);
nsvid4.client = this;
nsvid4.play("clips/video1.flv");
[code].....
View 4 Replies
Jul 14, 2011
how to do it but i'm not sure how to implement. I basically have one button that when i click with need to trigger a function. When I click it again it will trigger a second function and will keep this up back and forth.
View 3 Replies
May 5, 2009
I am new to AS, but not new to programming.I'm using Flash CS4.I have two button symbols, PlayBTN and PauseBTN. They are used to control the playback of a slideshow. When I use either one or the other to control the slideshow, it works. However, what I want to do is toggle between the two buttons, so that they work together like this:
1. If the slideshow is playing, PauseBTN is visible. If PauseBTN is clicked, the slideshow stops, and PlayBTN becomes visible.
2. If the slideshow is paused, PlayBTN is visible. If PlayBTN is clicked, the slideshow stops, and PauseBTN becomes visible.
In other words, clicking the button not only controls the slideshow, but changes which button is visible.I had this working using a two-frame movie clip and static bitmaps, but when I swap out the bitmaps for the buttons, the button rollovers stop working.
View 8 Replies
Aug 25, 2011
I have a button in action script with toggle="true". Now when I click the button its color changes and it looks as if it has been disabled (but its actually not). I need to know which property of this button has changed? For example if I need to know somewhere in my code the "toggled state" (if there is any such thing) of this button, which property of this button should I check?
View 1 Replies
Jan 26, 2010
Is it generally to position elements relative to other elements or in absolute values?
View 2 Replies
Feb 11, 2011
I have 4 buttons on the stage and each button is correlated to a seperate movieclip.
btn1 - mc1
btn2 - mc2
btn3 - mc3
btn4 - mc4
I want each mc to appear when it's corresponding btn is clicked but it has to be the only mc on the stage...meaning whatever mc was currently has to disappear. I've toyed with numerous was to get this to work but I know there's a more code efficient way to do this than the code I have below. And I don't want to use any timeline.
[Code]....
View 3 Replies
Mar 23, 2011
I have created a Pause and Play button that toggles between states. It controls a Timeline with synced Sound. When I use it the sound and animation go out of sync. Can anyone help me with this or perhaps have better code I could swap out to make this work?
Below is what I am currently using:On the first frame of an Action Script layer put this AS:
playBtn.onRelease = function() {
ns.pause(false);
playBtn._visible = false;
pauseBtn._visible = true;
[code]....
Put the Pause and Play buttons directly over each other on 2 layers for the duration of the timeline.Pause Button on top. (unless you have a STOP on the first line then maybe the Play button will start it.
View 3 Replies
Oct 1, 2009
does anyone know how to shift all the array elements by one or more without deleting the array itself?
Something like rotating the array:
1,2,3,4,5,6,7,8,9,10
10,1,2,3,4,5,6,7,8,9
9,10,1,2,3,4,5,6,7,8
8,9,10,1,2,3,4,5,6,7
7,8,9,10,1,2,3,4,5,6
View 4 Replies
Jul 21, 2010
This is a completely AS3 scripted, and dynamic project, meaning I cant use any assets from the library.
1 - This button is a mute. � Currently the loaded sound now fades in with a timer.� I want the button to over-ride any sound elements on the stage: the mp3 and later a flv movie as well.� In the below example the button only interferes with fade, and dosen't actually override it, after the fade - it dont do jack. � SoundMixer.stopAll(); will of course kill everything but I cant toggle this(can I?)
2 - The toggle button itself � I've loaded two png's into a sprite, and created a toggle button from them using an if statement. � Is this best practice? or would you recommend something else?� Perhaps SimpleButton?
ActionScript Code:
var btmUpURL:String = "a_icn-1.png";
var btnDwnURL:String = "a_icn-0.png";
var btnLoader1:Loader = new Loader();
var btnLoader0:Loader = new Loader();
[code].....
View 9 Replies
Oct 12, 2011
I've landed a project which is centered around building a custom video player with some special functionality (so I can't just use the default Flash video player, unfortunately). I have two small 'problems' in the sense that I could probably solve them myself, but I'd like some input on best practice for solving them:(The project is for Flash Player 10 and the video is intended to run inside a browser.)
Toggling between normal / fullscreen playback Ok, so my custom video player needs to be able to toggle between fullscreen and normal embedded-in-webpage player size. How does fullscreen toggling currently work in AS3 -is there a specific AS3 method for fullscreening a specified video object in the swf (without stretching the video player UI in the swf itself), and if so, does it automatically black out the background if the screen format doesn't match the video format? - or do I need to download a class for this?
Positioning video player UI when going fullscreen As opposed to YouTube, I want the player UI to still show up when the video is toggled to fullscreen mode - but as mentioned above, I don't want to stretch its size along with the video. So is there a best practice for repositioning the video player UI to the vertical bottom and horizontal center of the screen when the user clicks full screen? I'm not entirely familiar with what happens to the Flash stage when it goes full screen,. How to deal with not knowing the coordinates of the vertical bottom/horizontal center when screens have different ratios and resolutions?
View 3 Replies
Sep 11, 2010
This code is written in simple ActionScript, but I'm assuming this problem of mine would occur in all languages that have boolean datatypes. I'm simply clicking the stage so that my boolean variable reverses its value and than traces/prints/logs it's new value. However, it's always tracing true instead of switching between true and false for each mouse click.
var myBool:Boolean;
stage.addEventListener(MouseEvent.CLICK, mouseClickHandler);
function mouseClickHandler(evt:MouseEvent):void {
changeBoolean(myBool);
} function changeBoolean(boolean:Boolean):void {
boolean = !boolean;
trace(boolean);
}
View 2 Replies
Oct 12, 2011
I've landed a project which is centered around building a custom video player with some special functionality (so I can't just use the default Flash video player, unfortunately). I have two small 'problems' in the sense that I could probably solve them myself, but I'd like some input on best practice for solving them: (The project is for Flash Player 10 and the video is intended to run inside a browser.)
Problem 1: Toggling between normal / fullscreen playback Ok, so my custom video player needs to be able to toggle between fullscreen and normal embedded-in-webpage player size. How does fullscreen toggling currently work in AS3 -is there a specific AS3 method for fullscreening a specified video object in the swf (without stretching the video player UI overlay), and if so, does it automatically black out the background if the screen format doesn't match the video format? - or do I need to download a class for this?
Problem 2: Positioning video player UI when going fullscreen As opposed to YouTube, I want the player UI to still show up when the video is toggled to fullscreen mode - but as mentioned above, I don't want to stretch its size along with the video. So is there a best practice for repositioning the video player UI to the vertical bottom and horizontal center of the screen when the user clicks full screen? I'm not entirely familiar with what happens to the Flash stage when it goes full screen, How to deal with not knowing the coordinates of the vertical bottom/horizontal center when screens have different ratios and resolutions?
View 3 Replies
Jan 19, 2012
I'm trying to toggle 2 global Boolean variables inside of an ENTER FRAME loop. "Eating" and "WasEating". When these 2 objects hit each other "Eating" is set to true, and an animation plays to show that my character is eating. When the 2 objects DONT hit, I want to change my "WasEating" variable to true ONLY for that one frame (then setting it back to false), and to change back to the original animation when the Hero was NOT eating.
The issue I'm having is my variable is getting toggled true to false, false to true, every frame, not what I want. I want to have this happen ONLY ONCE, based on the hitTestObject function in the loop. For example:
ActionScript Code:
addEventListener(Event.ENTER_FRAME, loop);
function loop (e:Event):void {
[Code]...
View 2 Replies
Feb 15, 2012
I'm trying to create an image gallery by toggling between different sets of thumbnails and thus loading the appropriate images.I've set up the first 9 okay and they all load at first but when I toggle back and forth in the toggleThumbnails function using addChild I can no longer load these same movieclips.I'm loading the same movieclip with their associated instance names? How come it no longer interacts with the thumbnails?
ActionScript Code:
import flash.events.MouseEvent;
var thumbnailSet = "setOne";[code].....
View 2 Replies
Jul 21, 2010
This is a completely AS3 scripted, and dynamic project, meaning I cant use any assets from the library.
1 - This button is a mute.
� Currently the loaded sound now fades in with a timer.� I want the button to over-ride any sound elements on the stage: the mp3 and later a flv movie as well.� In the below example the button only interferes with fade, and dosen't actually override it, after the fade - it dont do jack. � SoundMixer.stopAll(); will of course kill everything but I cant toggle this(can I?)
2 - The toggle button itself� I've loaded two png's into a sprite, and created a toggle button from them using an if statement. � Is this best practice? or would you recommend something else?� Perhaps SimpleButton?
[code]....
View 1 Replies