ActionScript 3.0 :: Button Functions In IF Statements?
Aug 30, 2009
This time I am trying to use button functions with in IF statements. However I am having trouble with the if statements regonizing the currentFrame(); or currentFrameLabel();. I want diffrent button functions depending on what frame the playhead is in. But the frames are in diffrent movieclips and what not.The next problem is that I do not full understand the way to do frame paths (IE Root.Movieclip.Movieclip) in AS3. series of tutorials that I could read and follow,
View 12 Replies
Similar Posts:
Mar 3, 2011
I was wondering if anyone would be able to shorten this.All of my attemts at it have resulted in errors/not working.
ActionScript Code:
enemy1.onEnterFrame = function() {
if (this.hitTest(p1)) {
[code].....
View 1 Replies
Jun 17, 2004
I have one function that puts text in a text field and makes a button goto a url onRelease.The code is like this:
Code:
item.onRelease = function() {
myButton.onRelease = function() {
getURL("http://google.com", "_blank");
}
talk = this.txt;
}
the only problem is that the button doesn't work onRelease. i think that it is because there are too many functions there, but at the same time,
View 5 Replies
Apr 25, 2009
I'm trying to make a "next track" button. "T" is meant to be track number, and every time they click this button, I wanted "T" to increase by one until T>4 where I need it to go back to T=1 (I've only got 4 tracks). Then, I want, depending on what "T" equals, for it to start playing Track"T" and stop playing previous track. I also want the track playing to be looping continuously. At the moment, everything is muted, until I press the button; where it then plays all four tracks at once. I also have a problem with the mute button, but I've got a strong feeling both are of the same reason. I think my problem is that it does not know what "T" equals to begin with so it accepts all if statements; playing all tracks. But I'm new to Flash (my second project) so I'm not sure.
on (release){
stopAllSounds();
T =T+1
if (T>4){
T=1
} if (T = 1){
_root.snd1.start(0, 100);
[Code] .....
View 3 Replies
May 5, 2009
How do you script a Pause of X Seconds on X Frame and also on that frame have a button release statement that can take you forwards or take you backwards, elsewhere in the timeline - Without affecting the 'Pause' statement... therefore not mucking up the timeline and causing it to jump around at the end when all catches up?I take it once a pause has taken place - a button that can take you elsewhere, if clicked on - does not Cancel the initial pause and therefore lies my problem?
View 3 Replies
Apr 13, 2010
I'm trying to create a script that will disable a button after its been clicked, and once a certian number of buttons has been clicked, it takes you to a certian frame. All this takes place inside a movie clip.
[Code]...
View 1 Replies
Jun 14, 2004
I have three buttons: each one changes a variable to a name: one, two and three and plays the movie.when the movie gets to frame 100, it should get the variable and play the label with the same name of the button...How should be the AS of this frame so it plays to the correct label?
View 1 Replies
Nov 8, 2009
I'm designing an interface for a class, and the buttons that I am using all have multiple functions.For example, when the story button is clicked, I need the mc to stop playing and change to text (in the same window/screen, just no mc playing). The mc is 31 frames long, but if there's a way to just make it loop continuously until told not to, Currently, my code looks like this:
stop();
story_btn.addEventListener(MouseEvent.CLICK,story);
function story(event:MouseEvent):void { gotoAndStop(32);}credits_btn.addEventListener(MouseEvent.CLICK,credits);[code]...
When I click the button, the mc does not stop playing and the text does not show up.
View 6 Replies
Oct 7, 2004
If they get a question wrong in my quiz ( weakest link) the money clip goes to zero and it goes onto the next question. If they get it right the money clip advances and they go onto the next question. I want to include each time that it should only go onto the next question if all questions have been asked. SO i want an extra if clause in both sections, saying if current question is more than 11 go to '#game over"The questions are saved in the frame of the quiz
_root.qArray = new Array("question: A;B;C;D")
_root.qArray.push("Question?:A;B; C; D")
There are 11 questions.At the moment at the section with choosing answers I have
function selectAnswer(n) {
// correct
if (answers[n] == correctAnswer) {
_root.money.nextFrame();
[code].....
View 1 Replies
Sep 3, 2009
Let's say I have 3 buttons (movieclips) and, using AS2, I want that when mouse is over a button, that button changes its state, something like
[Code]...
so that the same thing happens for each button when the mouse is rolled over it, by simply calling for each button a function inside which I refer to the button by using "this". And the problem is I cannot (don't know) how to do this in AS3. I mean if I use "this" inside a function, this refers to the main timeline. So is there a possibility to write a function like
[Code]...
View 3 Replies
May 2, 2006
i have to scripts each in a different movieclip, i have
Code:
_root.navigation_n_logo["next_btn"].onRelease = function() {
nextImage();
};
and
Code:
_root.navigation_n_logo["next_btn"].onRelease = function() {
galleryChoice(2);
};
so as you see, I want both functions to execute on the same button but it only does 1. how can i fix this? so that both functions execute on the same button/movieclip
View 4 Replies
Jul 14, 2009
How could I code one button to do this
var showpage:Loader = new Loader();
var url:URLRequest = new URLRequest("fade.swf");
on1.addEventListener(MouseEvent.CLICK, showPage);
[code]....
And the Very Same button when clicked again to do this removeChild(showpage);Pretty much, What I have is a lightswitch, and when you click it, A black Fade appears arounf my FLVplayback.. And I want it, to where you click it again, the Black fade goes away..I can do this with two different buttons.. But was wondering if at all possible with one button.
View 1 Replies
Apr 25, 2011
I have a button which should generate a salt mc and statin mc, but when i put the generating loop on the main timeline and run the function from the button it doesnt work. PS. i need the generating funcion on the maintime line as I need to remove the mc when I click the 'reset' button and also do hittests with the mcs
View 1 Replies
Jun 18, 2009
I can't figure out how to get a button to toggle between to functions?It has to be more simple than an if()...else().. statement right?example:
myBtn_mc.addEventListener(MouseEvent.MOUSE_UP, what goes here?);
/* if the MOUSE_UP event is called and the chalkboard is blank, then write to the chalkboard
else erase the chalkboard */[code].......
View 3 Replies
Feb 23, 2010
I'm making a menu in flash and I want that when I CLICK the button/movieclip moves up and when I CLICK again it moves down again. I allready did it with MOUSE_OVER and MOUSE_OUT but that gave me problems.
Here is the Code:
//Eventlistenersmenu_over.buttonMode = true;menu_over.addEventListener(MouseEvent.MOUSE_OVER,onOver,false,0,true);menu_over.addEventListener(MouseEvent.CLICK,onOut,false,0,true);//Functionsfunction onOver(e:MouseEvent):void {menu_over.gotoAndPlay("menu_op");}function onOut(e:MouseEvent):void {menu_over.gotoAndPlay("menu_beneden");}
View 3 Replies
Oct 31, 2011
I have used the loader script to load an external swf into current project. I have added a button to unload the external file when wanted, and was wondering if you could have multiple functions for that button, so that when you click it to unload it works as a 'home' button as well, and takes the user back to the mainpage again?Might be wise to mention that im kinda new to adobe flash and as3, and not sure if the way i have used to load the external swf was the easiest. Seems like a few have had some issues with this subject before me as well.
View 8 Replies
May 8, 2008
How would I manage to enable a button to perform several operations? I want a button to do the following.
I want it to change colour etc, when it is hovered over, I also want it to activate anther flash file on the page via local connection on release. How do I allow the button to set up different actions? Do I need to make 2 separate invisible buttons? And have action script applied to both of them for the 2 commands? How for example would I be able to extend this so that I can have the button doing several things? Say:
1) On rollover it changes colour
2) On rollover it activates a flash mc on the page
3) On Click it changes colour
4) On release it takes the user to another page
View 2 Replies
Sep 20, 2009
How to add multi functions to a button ?[code]...
and by first_btn I wanna to disable one of the second_btn functions on press .
but the rest of second_btn functions remain work.how to do this ?
View 3 Replies
Jun 8, 2010
I have written two arrays for two separate functions and trying to have a button call both. How is this done properly? The function calls, collection() and left() are conflicting.[code]...
View 1 Replies
Apr 26, 2011
i have a button which should generate two different variables, but it only carries out 1 function and not the other. If i put another button calling the second function it just overwrites the mc generated from the first function.
Also, I need the functions to be on the main timeline as i also need to remove the mcs when needed.
View 1 Replies
Feb 25, 2012
[Code].....
Even though I pressed only one button. The main menu button. PS: The faces are Colon and a P.
View 9 Replies
Feb 5, 2009
I am having trouble with defining buttons I have on a separate frame. I define the buttons in my main class on my first frame fine, I have a mc called buttons and then on frame 1 I have some buttons and on frame 2 I have a button called btspin.
so when I have the following:
buttons.btspin.addEventListener(MouseEvent.CLICK, spinmouseclick);
function spinmouseclick()...
in the class it doesn't work. And that makes complete sense to me.
So what I did instead was keep those functions still there, but I moved the listener into a function that is called once you get to the second frame. The function is called fine but when referencing the button inside that function I have a problem:
function spinmouseout(e:MouseEvent):void {
//Change BT Color
buttons.btspin.buttoncolor.transform.colorTransform = new ColorTransform();
}
when called mc-buttons is on the right frame it gives the error:
TypeError: Error #1010: A term is undefined and has no properties.
at MethodInfo-11()
View 1 Replies
Jan 28, 2003
how to make button do multiple things at the same time. i.e when button is pressed it animates object1 and object2 i have a buttons that opens a sliding door (code is:
on (release) {
control.gotoAndStop(2);
}
so it opens a door where sound control is and i want for the same button at the same time to open lets say another door somewhere in the same stage with a music tracks in ther
View 1 Replies
Jan 8, 2005
I'd like a button to load a movie but only every third or fourth click. Is this possible? I don't know much about variables.
View 1 Replies
Sep 14, 2006
i have a lil problem with making button functions to work on a mc within a mc...i have this on my outer mc:
Code:
onClipEvent (enterFrame) {
this.onRollOver = function() {
[code].....
View 6 Replies
Sep 30, 2009
I have attached a sample fla file of what i am talking about. I am trying to get a button to do two different functions with one CLICK event. depending were you are on the time line a window should open on close when button is clicked. The problem is it dose it once, opens then closes. I would like it to work every time the button is clicked either open or close depending on the state.
View 5 Replies
Jun 8, 2010
Im doing something wrong.I have written two arrays for two separate functions and trying to have a button call both. How is this done properly? The function calls, collection() and left() are conflicting.Currently left() isnt working, but with collection() commented out it does.
Code:
collection_btn.onPress = function(){
_root.introscroller.gotoAndStop(1);
collection_btn.gotoAndStop(2);[code].....
View 1 Replies
Jan 19, 2011
I'm working on a gallery. In the "Picture.as" class I load the picture and there is also a function with an animation to make the picture disappear. In the main class the pictures are put to stage by putting instances of the Picture class.All I need to do now is to adress the function in the according Picture instance. It works fine as long as I use the direct link, but when I use a variable it does not work anymore.Here's my code:
Code:
public class.... // just for the example
{
[code]....
View 3 Replies
Nov 3, 2009
I'm populating a list of buttons dynamically with a forloop like this:
Code:
for(x=0;x<imageList.length;x++)
{
[code].....
View 2 Replies
Oct 17, 2010
I'm putting together a pretty basic website/portfolio. The buttons/code that go from page to page work great. The code I'm using to access larger images from thumbnails is basically the same, however it's not working.I have the site setup so that each larger image is it's own separate page, so basically the thumbnails act as buttons to access a specifically labeled page. Ex- Thumbnail/button "Character1_btn" goes to the page labeled as "Character1" to display the larger image. I hope this makes sense.Below is the code I'm using. As I said- all functions but the character1 function are working properly.. I really need the character 1 function to work.Quote:
stop ();
home_btn.addEventListener(MouseEvent.CLICK,playhom e);
function playhome(event:MouseEvent):void{
[code].....
View 2 Replies