How To Make A Selected Button When You Click?
I have several items on my menu. Let's say:
Button0
Button1
Button2
How to make a selected button when you click, initialize to "Button0" and when the user click to another button (ex: Button1 or Button2), the color will be switched to this new selected button??
thanks in advance,
KirupaForum > Flash > ActionScript 3.0
Posted on: 01-16-2008, 03:03 PM
View Complete Forum Thread with Replies
Sponsored Links:
[F8] Update Combobox Selected Item On A Button Click
I am working on a pagination module.
In the top of the page there is a list of items where I have to show only ten items and if there are more than ten items then a combo box will display 1 of 2, 1 of 3 etc., depending upon the number of items in the list. I have done it using XML and arrays and it is working fine.
But there is also a next and previous button which is also working but now what I want is suppose if we are in # 2 of 3 page and click on the previous button then the selected item of combo box should also change from 2 of 3 to 1 of 3.
Please let me know how should I do this.
Please let me know if I could not express myself clearly.
View Replies !
View Related
How To Make A Current Button Selected?
Hi all,
does anyone know how to make a current button selected?
Let's say I have 3 buttons in an array
current code:
Code:
package
{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import caurina.transitions.Tweener;
public class selectedButton extends Sprite
{
private var current_selected:MovieClip=null;
private var last_selected:MovieClip;
private var tabBtn:Array;
private var button:buttonMC = new buttonMC();
public function selectedButton()
{
tabBtn = new Array(button, button, button);
initButton();
}
private function initButton():void
{
var xPos:uint = 0;
for(var i=0;i<tabBtn.length;i++)
{
var button:buttonMC = new buttonMC();
button.buttonMode = true;
button.x = xPos;
xPos += button.width+5;
button.addEventListener(MouseEvent.MOUSE_DOWN, handleButton);
button.addEventListener(MouseEvent.MOUSE_OUT, handleButton);
button.addEventListener(MouseEvent.MOUSE_OVER, handleButton);
addChild(button);
}
}
private function handleButton(eventType:MouseEvent):void
{
switch(eventType.type)
{
case MouseEvent.MOUSE_DOWN :
Tweener.addTween(mc, {_color:0x0000ff});
return;
case MouseEvent.MOUSE_OUT :
Tweener.addTween(eventType.target, {_color:null, time:0.5, transition:"easeOutQuad"});
return;
case MouseEvent.MOUSE_OVER :
Tweener.addTween(eventType.target, {_color:0xcccccc, time:0.5, transition:"easeOutQuad"});
return;
}
}
}
}
View Replies !
View Related
How Can I Make The Button Ignore An Event If No Radiobutton Is Selected?
I have a group of 5 radiobuttons and a "SUBMIT" button on the stage. A "SUBMIT" button listens to the radiobutton group and when clicked it gets data from the radiobuttons and traces the results.
ActionScript Code:
//CREATES A GROUP OF RADIOBUTTONS
this.createEmptyMovieClip("rb_container", this.getNextHighestDepth());
for (i=0; i<5; i++) {
rb_container.attachMovie("RadioButton", "rb_"+i, rb_container.getNextHighestDepth(), {label:"RadioButton "+i, data:"RadioButton "+i, _x:100, _y:20*i, groupName:"groupOptions"});
}
//CREATES SUBMIT BUTTON
createObject("Button", "abutton", this.getNextHighestDepth(), {label:"SUBMIT", _x:100, _y:120});
//CREATES A SUBMIT BUTTON LISTERNER
var submitListener:Object = new Object();
submitListener.click = function(oEvent:Object) {
trace("You selected "+rb_container.groupOptions.selection.data);
abutton._visible = false;
rb_container._visible = false;
};
abutton.addEventListener("click", submitListener);
Problem: The "SUBMIT" button responds to any click event, and returns "UNDEFINED" if no radiobutton is selected.
Question: How can I make the "SUBMIT" button ignore the click event if no radiobutton is selected, instead of returning "UNDEFINED"?
View Replies !
View Related
How To Make Button Stay Selected When Clicked (link To Webpage(
Hello. I have made a basic flash movie with several buttons. I have it currently to where each button, when you roll the mouse over the button, changes color. When you click on the button, it takes you to a webpage (the complete page is in an html frame, with the top frame being the flash movie, and the bottom frame, called "bottom" containing the linked webpage.
What I cannot figure out how to do keep the button in its selected state after it has been clicked (and the mouse leaves the button). I want each button to maintain it's "over" state when it has been clicked (its webpage is in the bottom frame) to show what page is currently loaded below. How can I do this? As is now, after clicking the button, the webpage loads below, but as soon as the mouse stops hovering over the button, the selected state goes away.
This is the code I have for each button for the link:
on (release) {
getURL("page.html","bottom");
}
Thank you very much for your help.
mhedges
View Replies !
View Related
How To Make A Movie Clip Button I.e. Make It Click-able
i followed the tutorial for making animated buttons by using movie clips instead of button symbols. now i don't know how to make them click-able. this is probably pretty basic, but i'm new to flash and i'm getting pretty frustrated trying figure things out by myself (no programming experience here, although i did buy the flash bible). i'm using flash mx 2004.
any pointers on how to do this would awesome. thanx a ton.
--V
View Replies !
View Related
How To Make Something Visible On Click Of Button
Hi,
I am trying to make a menu appear within my movie. The menu in question is in the library of the same movie. I simply want the user to be able to click a button and then the menu appears. Here is the code I have came up with but it does not work, I am new to actionscript so probably got it all wrong.
if (menu_btn.onPress)
{menu._visible = true;}
else if
(menu._visible = false
I would appreciate any help.
View Replies !
View Related
Cant Make Symbol Visible With Button Click
this is so simple its embarresing, but it dosn't work.
I am trying to create an effect where I press a button, a symbol become visible.
So, i created two buttons called blue and green.
on the blue button i placed this code.
on(release){
blu=1
grn=0
}
on the green button I placed this code.
on(release){
blu=1
grn=0
}
I inserted a layer called lyr_blue and inserted this code.
setProperty("_root.blue", _visible, "0");
if (blu==1) {
setProperty("_root.blue", _visible, "1");
}
I inserted a layer called lyr_green and iserted this code.
setProperty("_root.green", _visible, "0");
if (grn==1) {
setProperty("_root.grn", _visible, "1");
}
but it doesn't work for some reason.
I have read SAMS teach yourself Macromedia MX in 24 hours and I am currently reading friends of Ed's Foundation Action Script for Macromedia Flash MX.
So far none of the books have helped.
Please can someone help
Tricia
View Replies !
View Related
Cant Make Symbol Visible With Button Click
this is so simple its embarresing, but it dosn't work.
I am trying to create an effect where I press a button, a symbol become visible.
So, i created two buttons called blue and green.
on the blue button i placed this code.
on(release){
blu=1
grn=0
}
on the green button I placed this code.
on(release){
blu=1
grn=0
}
I inserted a layer called lyr_blue and inserted this code.
setProperty("_root.blue", _visible, "0");
if (blu==1) {
setProperty("_root.blue", _visible, "1");
}
I inserted a layer called lyr_green and iserted this code.
setProperty("_root.green", _visible, "0");
if (grn==1) {
setProperty("_root.grn", _visible, "1");
}
but it doesn't work for some reason.
I have read SAMS teach yourself Macromedia MX in 24 hours and I am currently reading friends of Ed's Foundation Action Script for Macromedia Flash MX.
So far none of the books have helped.
Please can someone help
Tricia
View Replies !
View Related
Make Array Items Appear On Button Click
Hi I have items stored in an array in a txt file.
word1= Italy&word2= Napoleon&word3= Garibaldi
AT the moment when the screen loads all the text appears in different dynamic text boxes.
I would like to change it so that I can have a button and when you press it it will make the words appear one at a time in just one text box.( to play jeopardy)
E.g. on 1st press it would make word1 appear, then if you continue pressing it the word2 and then word3 will appear in turn.
At the moment I load it like this
loadText = new LoadVars();
loadText.load("Jeopardy words.txt");
loadText.onLoad = function() {
topic1.text = this.word1;
topic2.text = this.word2;
topic3.text = this.word3;
};
I've looked through tutorials on this and other sites but I can't find one which does exactly what I am wanting.
Cheers
Lesley
View Replies !
View Related
Make Array Items Appear On Button Click
Hi I have items stored in an array in a txt file.
word1= Italy&word2= Napoleon&word3= Garibaldi
AT the moment when the screen loads all the text appears in different dynamic text boxes.
I would like to change it so that I can have a button and when you press it it will make the words appear one at a time in just one text box.( to play jeopardy)
E.g. on 1st press it would make word1 appear, then if you continue pressing it the word2 and then word3 will appear in turn.
At the moment I load it like this
loadText = new LoadVars();
loadText.load("Jeopardy words.txt");
loadText.onLoad = function() {
topic1.text = this.word1;
topic2.text = this.word2;
topic3.text = this.word3;
};
I've looked through tutorials on this and other sites but I can't find one which does exactly what I am wanting.
Cheers
Lesley
View Replies !
View Related
HELP - Make Button Click On Keyboard Enter
I need to make my search form run when a user hits the enter key
I thought this would do it, but apparently not
(this is on the txtKeywords instance)
//launch search on enter keystroke
on(enter){
_root.btnSearch.click();
//trace("Enter");
}
Any idea what I am doing wrong here ?
Thanks,
J.
View Replies !
View Related
Trying To Make A Movieclip Stop When Click On A Button
The problem im having is in the main screen im having text play and pictures pop up. but on the right hand side of my screen i have three buttons and when i click thoses buttons the tabs scroles out and then plays whats in the tab. but i can figure out how to stop the main timeline because it keeps playing whats in the back ground. this is the code i have when you click on the tabs..
on (rollOver) {
gotoAndPlay("s1");
}
on (releaseOutside, rollOut) {
gotoAndPlay("s2");
}
on (press) {
if (_roo.m<>1 and _parent.pos == 1) {
if (_root.gal<>0) {
_root["gal"+_root.gal].gotoAndPlay("s2");
}
_parent.gotoAndPlay("s1");
_root.gal = 2;
}
if (_roo.m<>1 and _parent.pos == 2) {
_root.gal = 0;
_parent.gotoAndPlay("s2");
}
}
View Replies !
View Related
How To Make Playout Movieclip When Mouse Click On The Button.
this is example website :: http://www.template-download.net/previews/t498/
You'll see the button below,
When you click on button it play movieclip and then when you click on another button it going to play roll out movie and then start to play the new movie clip.
I think the principle is ... I have 2 button one is DOG button second is BIRD button. I click on dog button it run dog walk in and stop!
Then I click at bird button dog movieclip play next after thay stop to the end is dog run away and then load bird movie clip is bird come down and stop. and then i click on the dog button again bird flyaway and load god movieclip.
I think I know that mean but I don't know How to do that ?
I can't make the movie clip play out ....
View Replies !
View Related
HOw Do I Make This OnClip Event (load) Work When You Click A Button?
I want to alter this code so that the thing scales and moves when the user clicks a button.
How do I do this?
Thanks.
onClipEvent (load)
{
_x = 0;
_y = 0;
xsEND = 200;
ysEND = 200;
xEND = -455;
yEND = -577;
speed = .2 //(0-1) speed of transition
tolerance = 1 //(0-1) precision of final placement...one is usually good enough
}
onClipEvent(enterFrame)
{
//if difference between END and CURRENT is still > tolerance (can use ANY variable...)
if(Math.abs(xEND - _x) > tolerance)
{
//find the distance between the current location and the END location, and go a percentage
//of that //distance (30% here, or speed = .3)
_x += (xEND - _x)*speed
_y += (yEND - _y)*speed
_xscale += (xsEND - _xscale)*speed
_yscale += (ysEND - _yscale)*speed
}
}
View Replies !
View Related
Make Button Not Play Sound On Click, Only On Rollover, With Out Screwing Up Anything
okay, here is my problem, and no one has been able to give me a solution that really works,
I can't figure this out. The home button works perfectly, the other buttons arn't working the same way. I don't want to use stopallsounds, because I am going to be adding in sounds on click and I don't want stopallsounds to be interfering. When I had the other buttons the exact same way as the home button the other buttons would play the sound continuously. I changed them and now the best I can do is that they play once on roll over, but will play once when I click as well, which I of course do not want. I want to get rid of the sound playing on click.
Can anyone help me with this with out either making the animation not play on click, or rearanging resetsubbuttons so that the buttons are reset after or during the animation taking place. Thank you.
View Replies !
View Related
HOw Do I Make This OnClip Event (load) Work When You Click A Button?
I want to alter this code so that the thing scales and moves when the user clicks a button.
How do I do this?
Thanks.
onClipEvent (load)
{
_x = 0;
_y = 0;
xsEND = 200;
ysEND = 200;
xEND = -455;
yEND = -577;
speed = .2 //(0-1) speed of transition
tolerance = 1 //(0-1) precision of final placement...one is usually good enough
}
onClipEvent(enterFrame)
{
//if difference between END and CURRENT is still > tolerance (can use ANY variable...)
if(Math.abs(xEND - _x) > tolerance)
{
//find the distance between the current location and the END location, and go a percentage
//of that //distance (30% here, or speed = .3)
_x += (xEND - _x)*speed
_y += (yEND - _y)*speed
_xscale += (xsEND - _xscale)*speed
_yscale += (ysEND - _yscale)*speed
}
}
View Replies !
View Related
Text In Field Selected On Click
Hey guys, I did a quick search on here and didn't find what I was looking for (maybe I missed it)
What I want to do is set up a text field with "enter email here"
Then I want to set it up so that when the end user clicks inside the box it selects all of the text. This way all they have to do is click in the text box once and start typing. I know the html equivilent is:
Code:
onClick = "this.select();";
in the text field... how can I do this?
View Replies !
View Related
[as 2][help] Make TextField Selected...?
like when you click on a textfield (say in an HTML form or whatever) and all the text is selected as you do so, so that you can click, then just type to replace what's there. can I do this with actionScript? I looked through the documentation and couldn't find anything that looked like it was setting the text to selected..
I know I can delete all the text on SetFocus, but I don't want to do that. This is for a crossword puzzle, and I don't want peeps to be deleting their entries just by clicking them.
TIA
View Replies !
View Related
How Do I Make A Combo Box That Goes To A Frame When Selected?
I have a combo box in MX that has the selections
"Red Ball"
"Blue Box"
on them and I would like to know how to make it so that when one of those options is clicked it will go to that frame where I have created the Red Ball or Blue Box
For example
I have a Red Ball drawn on Frame 15 if the combo box item "Red Ball" is selected how does it go to that frame?
any help would be greatly appreciated thank you
View Replies !
View Related
Can't Make Working GetBeginIndex To Get Selected Text
Hi.
i've a texte box and a button.
I highlight (select) text in my box.
then when i press the button, i want to get the position of selected string with getBeginIndex.
i try this :
myvar = Selection.getBeginIndex();
but when i print myvar, it's -1, which says that no text box is selected and no selection is made.
and if i try :
myvar = Selection.getFocus();
there nothing, also !!
i made working correctly SetSelection and Getfocus after it, then i'm sure my syntax is correct.
but i can't make it working when i select with my mouse the text in the box.
i'm fed up with it.
an idea ? ICQ is recommended for long explication, if needeed
View Replies !
View Related
Can't Make A Right-click Menu? Make A Middle-click Menu
Since so many people are always wanting to make a context menu that appears at the mouse position, and because it's such a pain to get rid of the flash right-click menu (and the methods i've seen are not cross browser) I decided to go about finding a way to make a middle-click menu. Most mice these days have a mousewheel and the vast majority of those mousewheels also act as a 3rd button if you push down on them. So here is the result of my labor. A way to detect the middle mouse up and down actions in Flash.
Code:
Mouse.toggle = false;
setInterval(TestMidMouse, 40);
function TestMidMouse() {
if (asNative(800, 2)(4) == true && Mouse.toggle == false) {
Mouse.broadcastMessage("onMidMouseDown");
Mouse.toggle = true;
} else if (asNative(800, 2)(4) == false && Mouse.toggle == true) {
Mouse.toggle = false;
Mouse.broadcastMessage("onMidMouseUp");
}
}
myListener = new Object();
myListener.onMidMouseDown = function() {
trace("middle button down");
};
myListener.onMidMouseUp = function() {
trace("middle button up");
};
Mouse.addListener(myListener);
In case you're wondering, asNative is an undocumented feature of flash. It refers to the native function table that resides in the flash player. asNative(800, 2)(4) returns true or false depending on weather the middle mouse is down or up respectively. FYI, replacing the 4 with other numbers activates for other buttons (including keyboard keys). 1 is left click, 2 is right click, 3 doesn't seam to do anything, 4 is the middle mouse button, 5 is a 4th mouse button if mouse has one. Here is the most extensive reference for the asNative function that I have found. I suppose you could do the same thing with Key.isDown(), but messing with undocumented stuff is so much cooler .
If anybody does know a way to get rid of flashes right-click menu, reliably and across multiple browsers please post it here because this method could easily be converted into right-click detection.
View Replies !
View Related
How Can A Button Be Selected?
Hi All,
I have to provide 5 buttons to the user to select the options. The buttons are working fine.
But I would like to remember the selected button when the next time i display all 5 buttons with the last selected one should remain pressed or selected.
Any idea how to sort out this issue? Time is ticking....
View Replies !
View Related
See If A Button Is Selected
I have a gray Oval shape that I have create a button and have done so when someone push the button or hover it change text color.
But have anyone any idea how I can change the Oval shape from gray to red?
Do I have to have two button above each other??
I like when someone have push the button it change to red until he push another button and that get red and the other change to gray again.
View Replies !
View Related
See If A Button Is Selected
I have a gray Oval shape that I have create a button and have done so when someone push the button or hover it change text color.
But have anyone any idea how I can change the Oval shape from gray to red?
Do I have to have two button above each other??
I like when someone have push the button it change to red until he push another button and that get red and the other change to gray again.
View Replies !
View Related
How To Use Button.selected?
I'm trying
Code:
import fl.controls.Button;
var b1:Button = new Button();
this.addChild(b1);
b1.selected = true;
And it doesn't work.
Should the Button be supposed to 'select'.. ?
Where is the error?
Tanks in advance.
View Replies !
View Related
Selected Button In AS 3
greetings all
hopefully a short question
i have a batch of buttons.
now in the past (as 2) i had this very simple check to see if the button was clicked, meanwhile the other buttons got back to its original state, via this simple code
Code:
var selectedM:MovieClip;
BUTTON.onRelease = function() {
if (selectedM != this) {
selectedM.enabled = true;
}
//if an item is selected we make sure the item can't be triggered again.
selectedM = this;
selectedM.enabled = false;
now in AS 3. it seems to be a different story
i tried:
Code:
var selectedM:MovieClip;
function clicker(e:Event){
if (selectedM != e.target)
{
selectedM.enabled = true;
}
selectedM = e.target;
e.target.enabled = false;
}
//for loop has BUTTON.addEventListener(MouseEvent.CLICK,clicker)
or where e.target is i tried to replace it with "this" but all to no avail
i am probally looking over something but if anyone could give me a go, i'd be very thankfull
cheers
View Replies !
View Related
Button Selected
Hi
Im tryong to make 4 button but when the web is started the 1st button must be selected and the other thrre buttons must be enabled , if the user clicked the other button the button that was selected must come enabled!
can somebody help me please??
Best wishesh
View Replies !
View Related
AS3 - How To Use Button.selected?
Last edited by ad.sign : 2008-08-06 at 18:34.
I'm trying
ActionScript Code:
import fl.controls.Button;
var b1:Button = new Button();
this.addChild(b1);
b1.selected = true;
And it doesn't work.
Should the Button be supposed to 'select'.. ?
Where is the error?
Tanks in advance.
View Replies !
View Related
How To Use Button.selected?
I'm trying
Code:
import fl.controls.Button;
var b1:Button = new Button();
this.addChild(b1);
b1.selected = true;
And it doesn't work.
Should the Button be supposed to 'select'.. ?
Where is the error?
Tanks in advance.
View Replies !
View Related
Button Selected Question
What is the best/easiest way to create a button where, when the user clicks it, it turns into a different colour and stays that colour until a different button is pressed.
Sort of like a radio button.
View Replies !
View Related
Selected Button State
Is it possible to make the button stay in a selected state?
You know how when you click the button it stays green for a moment? Is there a way to make it stay green until, say, the button is clicked again?
Thanks!
View Replies !
View Related
Button [Selected State?]
If i create a button instance, is there any 'decent' way to make the button appear selected?
The only 2 ways i can think of is changing the color of it on a different frame or pasting a different colored image of the button right on top of it
View Replies !
View Related
[F8] Button Selected State
I'm working on my first website and I need my buttons to have selected states that indicate which section the user is in. Now I'm assuming that I would want to go with movieclips for buttons, using frame one for off state, frame two for the over state, and frame three for the selected state.
But this seems like a lot of coding to me. For instance if home_btn is in the selected state, then I would have to code all other buttons to send home_btn to off state when any of them are selected. Is there an easier way to do this that I'm not seeing? I have several buttons and I really don't want to have to copy tons of code to each button. Any suggestions would be greatly appreciated. Thank you for you time and any help you can provide.
View Replies !
View Related
Show Selected Button
I've created several nav buttons.
I'd like the selected button to display differently to show it's selected.
I've created a movie for the Up state with a frame for the selected and
unselected. This works when the button is selected, but I don't know how
to turn it off when another button is selected.
Greg
View Replies !
View Related
Tint Selected Button
var selectedGalleryBtn:Array = new Array();
addEventListener(Event.ENTER_FRAME, shadeGalleryBtn);
function shadeGalleryBtn(e:Event):void{
if(selectedGalleryBtn.length > 0){
selectedGalleryBtn[0].alpha = .6;
}
}
hi, i am trying to tint the selectedGalleryBtn instead of using alpha.
I can't seem to figure this out.
Thanks
View Replies !
View Related
|