ActionScript 2.0 :: Write An If/else Statement For A Mc Button?
Apr 6, 2009'm trying to write an if/else statement for a mc button that says if mc is on stage don't attach it, else attach it.
View 5 Replies'm trying to write an if/else statement for a mc button that says if mc is on stage don't attach it, else attach it.
View 5 RepliesI have a script which is giving me a lot of trouble since I have no idea how to write another "if statement" inside another if-else statement. I keep getting errors, I guess I don't know where to put the braces exactly...
example:
if(bla == bla) {
<------------how would I write another if statement here?
}else if (bla == bla){
}
write a if/else statement. normally you would write:
Code:
if(condition){
//code
}else{
//code
}
but, as many of you might know, this would also work:
Code:
(condition) ? /*code*/ : /*code*/;
are there more of these alternative ways to write your code in actionscript?like for this problem:
Code:
trace("my name is: " + nameVar + ", and i like it!");
many programming languages have a nice way to enter variables in your string, like C:
Code:
("my name is: %d , and i like it!", nameVar);
if else statement I am trying to write for a gallery. I want to have it so if picture is on last one to go to first set on xml. Heres what I am writing it as:
Code:
function nextImage() {
if (p<(total-1)) {
p++;
[code].....
I have it written on my next image function because many things refer to that so check here then proceed to first set if on last. The problem is it stays on 4 or last item in xml. Can someone hit me with some insight.
In my movie I load a swf to a movieclip with this code
PHP Code:
_root.ImageViewer.loadMovie("deneme.swf");
Now can I do this? before calling the swf named deneme. When I press a button If I attain a number to a global variable with this code
PHP Code: on (release) {_global.myVar = 5;gotoAndPlay("CloseUpAnimation");}
Can I read this variable from the swf which I load into my movie?If I can read how can I write a If Statement that will gotoAndPlay according to that variable?
PHP Code:[code]...
I am attempting to create what I call an 'On Air' rotator for a radio station. I would like to pull in an image file for each program when it is on air. I have the following AS 3 code that seems to work:
var now = new Date();
var day = now.getDay(); // Returns integer between 0 and 6
var hour = now.getHours(); // Returns integer between 0 and 23
[Code].....
The weekday programming is the same every day. We have some programs that are three hours in length. I would like to cut down on the number of statements I write. I am unsure how to combine the weekdays and have a range of hours in one conditional statement. Will the following work?
if (day >= 0 && day <= 4 && hour >= 6 && hour <= 10)
I'm attempting to express the condition "if the day is Monday through Friday and the hour 6 am to 10 am"
How i write the inline conditional statement in Flex with two expressions(case) [code]...
Flex compiler only check the first expression and on behalf of that give result.But i want to check both statement and show result.
i have to generate a button dynamically... and have to keep a click handler for the same how to write script for clicking buttonim using following code for creating button dynamically
var btn:Button = new Button;
btn.label = "Print";
how to write a actionscript code for a button when the button is clicked it should move to the nextframe.
// About and smile1 button scripts
stop();
_root.smile1.onPress = function() {
if (mouse_over_smile1) {
[code]....
i have given 3 functions as onEnterFrame,onPress,onRelease. i tried all these but didnt get the result.smile1,smile2,smile3 are button instances which are declared on the monie clip.my main thing is i hav a button, when i click on that button it should go the next frame which i have declared in "gotoAndPlay(6)" method.
i'm trying to use if statements but can't get this thing to work i want to check if another button is visible on release of a button to determine what action to be taken.the 'gotoAndPlay("firstscene",1)' is just there as an outcome, will be changed later. anyway this is the code i've got on the button i'm pressing. blobyellow2 is an instance of a button blobyellow is it because it's an instance that it's not working?
[Code]...
edit: sorry forgot to put what's wrong with the code. it acts as though the statement is correct no matter if it is or isn't.
I am new to CS4. I have been using Macromedia 8 and used to be able to write code on a button very easily. So click on the button and go the actions. But How do I do it in Cs4?
View 1 RepliesI'm trying assign two functions to one button. The first click does a loadMovieNum to level 1. The second click will unloadMovieNum on level 1. So the first click loads a movie, the second click unloads it. Pretty basic.
I'm guessing it's a simple if statement, but I don't know how to go about it.
Anyone want to take a stab?
How to write the GetURL function to a button in AS3?
View 6 RepliesHow 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 RepliesI have a button which controls the horizontal movement of a movie clip and next to it I have a button, if the user clicks the button once it moves up half way and when they click it again I would like for it to move up the rest of the way.This script has been applied to the button
on (release) {
if (xpos = 0) {
trig.xposnew = -396;
[code]....
I have a flash movie that plays through automatically pausing on each frame for a set amount of seconds.
I used the following code to pause the movie which works 100%:
stop();
var interval:Number = setInterval(
function():Void {
[Code]....
But now i have several buttons on the movie as well, now what i want to happen is that when any one of the buttons is clicked it should ignore the above piece of code and not pause on the frame but stop on the frame.
I'm having a memory lasp. I trying to write for each button to goto and play at a label. what the correct code for that is please.ActionScript 3.
View 4 RepliesI am just trying to write a small actionscript in Flash CS4 for a navigation button and I am really lost.
I turned Script Assist and can not figure out even the first line nor can I turn Script Assist off. Should I be using Script Assist and, if not, how do I deactivate it so that I can type directly into the text box?
Is there a way, for a Button's "label" field, to display text over several lines? Or else to automatically "wrap" the text in several lines instead of cutting part of it?
View 4 RepliesWhat command would i use if i wanted to be able to click a button and when i do that text apears in teh dynamic textbox?
View 3 RepliesI've been attaining help with buttons and movieclips here, and I got awesome code from cbeech.The buttons code I'm trying to write will keep a button in the active state when pressed, and if any other buttons are in the active state, they will close up...Im posting alink to a flash file of the effect i want in actionscript 2.0 . However, I need the effect/code in actionscript 3.0. and I need it to be modular where I can easily add or remove buttons to my heart is content.
Put more clearly, when a user rolls over a button, I want the button to play the "open" frame in the button/movieclip. When the users rolls off the button, the button/movieclip goes the "close" frame in that button/movieclip. If the user presses the button, the button/movieclip plays the "open" frame and will stop at the stop (action) to stay in the active state, and if there are any other buttons open, they should go their respective "close" frame and play from there. Here's my starting code. please bear with me; Im just migrating from 2.0:
[Code]...
i have 9 images. the one that loads in is based on the number established by the variable loopCount, which increases by 1 each time the main movie loops. Based on what value loopCount has at the time, i want a matching button to appear. For example:
loopCount has the number 5 assigned to it this time around image 5 loads in button 5 needs to load in to match. i am guessing its some simple if statement, but i am at a loss. here is my attempt at the code:
[Code]...
I am having a problem using an if statement in a button. What I want to do is go to a frame dependent on which frame we are already on. For example if I am on frame one and I press the button the first time it will take me to frame five, if I then press the button a second time the actionscript detects we are on frame five so goes to frame ten and so on.
ActionScript Code:
on (release) {
gotoAndPlay(5);
if (currentframe == 5) {
gotoAndPlay(10);
} else if (currentframe == 10) {
gotoAndPlay(15);
} else if (currentframe == 15) {
gotoAndPlay(20);
}}
When I first press the button it takes me to frame 5, the second time I press it goes to frame 10, but when I press after that instead of going to 15 it takes me back to 5 then 10 then 5 then 10 etc and is stuck between going from 5 to 10 and back again.
I have an exam game with different categories of test, all linking to a single results page. I would like to be able to set the back button to return the user to the main page for category they were just in, in case they want to retake the test, or take another part of the test, as some are broken up into multiple parts. I imagine there must be a way to detect what test category the user came from and program an If statement that sets the back button direct them to the main test page/frame. Something like, if user comes from Test1, btnBack=mainTest1, else if Test2, btnBack=mainTest2, etc.
Clearly not the right syntax, but something along those lines in terms of function. I understand how these statements work, but I have just never written one from scratch before, or really done much of anything with them; and have no idea where to begin. At the very least, could anyone direct me to a reliable, easy to follow guide somewhere online that would point me in the right direction? I've seen some guides, but they're not always the easiest to follow, if you've never done what they're instructing you to do, before.
This is what I get in the output window:
Statement must appear within on handler
back_button.onRelease =function () {
I have this email form. Click on the bottom where it says submit track.It takes you to a form section.On that button i have an if statement, but it doesnt work.I only want the playhead to play when all 3 fields have been filled out, i thought i had it right, but i was wrong
View 7 RepliesThis is what I get in the output window: Statement must appear within on handler back_button.onRelease =function () {
View 7 Repliesi'm an AS2 novice but I wanted to write a class that when you rollover a button it would grow and the others would shrink! At this point it's only missing the other buttons to shrink cause I have no Idea on how to refer them in the code!
[Code]...
Having a few problems with what I thought was a simple if statement. Here is the code:
[Code]...
I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.
Here is my current small piece of code I have on a given "letter" button..
on (release) { if (_root.Acheckmark._visible=true) { _root.AScore = _root.AScore+_root.APoints; } else if (_root.Bcheckmark._visible-true) { _root.BScore = _root.BScore+_root.BPoints; }}