ActionScript 3.0 :: Cannot Get If Statements To Work
Oct 6, 2009
How to do a rollover button where you rollout and it doesn't another option depending on the current frame. So I decided to open up another actionscript file and do a test so that I knew that I could make an if statement work in a barebone state. And I can't get it to work
First I stated my variable to be 0. I added 3 buttons. Button One makes the variable unit "myVar" to 1 and Button Two makes it 2. And my output button reacts to these variable changes. But it doesn't work.
ActionScript Code:
One_btn.addEventListener(MouseEvent.CLICK, OneV);
Two_btn.addEventListener(MouseEvent.CLICK, TwoV);
Output_btn.addEventListener(MouseEvent.CLICK, OutputV);
var myVar:Number = 0;
function OneV (event:MouseEvent):void {
[Code] .....
View 4 Replies
Similar Posts:
May 22, 2007
the flash autoformat destroys my code... And i use it all the time .. my switch and for statements doesnt work anymore after autoformat, it adds ';' where it shouldnt..
View 14 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
Apr 15, 2009
I am trying to use if and else statements and failing. I am either completely missing their purpose, or just not writing the correct code. Scenario: I have designed a gallery that consists of animation in movie clips that are placed on the time line. With the if/else statements I need Flash to know what movie clip the user is on, so that the users next action loads the correct movie clip.
[Code]...
View 4 Replies
Apr 18, 2009
Is it possible to double up If Else statements? [code]...
View 2 Replies
Sep 14, 2009
how do i create an if statement for some buttons to say something like:
-if button1 is pressed go to frame1
-if button2 is pressed go to frame2 etc.
i know i could use button1.onRelease = function(){blah blah;} but i would like to start using if statements and this is a good place to start i guess
View 1 Replies
Dec 3, 2006
I want to join two if statements together and I'm unsure of the syntax. This is what I have but it is obviously wrong. if (Key.isDown(Key.RIGHT) or if (moveRight_btn.onPress){
View 7 Replies
Nov 20, 2009
well after I made all of the conditional statements I came to the conclussion and the annoyance that I cannot retrieve the statements value, I need help:[code]it does not return the value.. why?
View 5 Replies
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
Aug 25, 2009
After searching for how to do this i discovered the Get/Set functions of as.3. The only problem is that i am not experienced enough with this kind of statement to get it working, so i have come here to seek from the wise and masterful members Here is some more info:Inside a fla called "Main" i have 2 MovieClips. The first is called Main and has a class linking to the com/Main.as file which has this code:
Code:
package com{
import flash.display.MovieClip
[code]....
View 10 Replies
Apr 19, 2010
used to be able to handle variables and if else statements back in AS2.0, but I don't know how to go around them in AS3.0For instance, a code like this:
stop();
var pageNum = 1;
var pageAnim = 1;
[code]....
View 7 Replies
Apr 12, 2012
i have got a project im working on that requires if statements
basically im wanting to create 2 or more statements detailling if an answer is right, to move onto the next question but before it does that, to play an audio clip then move on. the next statement will be similar, but i cannot remember how to create them i.e. the syntax.
if i could get a response ASAP that would be gr8, as i have 2 weeks to get it done.
View 3 Replies
Jan 28, 2009
I'm making a small movie in Actionscript 2, but have found a problem related to the scope of my functions.Figure I have an audio/mute movieclip, with a global variable called "elaudio" (boolean). When "elaudio" == true , the volume is up, when "elaudio" == false, the volume is muted.I'm attaching sounds from the timeline using Actionscript with an object sound, this way:
Code:
_root.audio.attachSound("myWav");
_root.audio.start();
[code].....
View 2 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
Sep 28, 2010
When use the full path name and the identifier of a movie clip, my conditional statement works fine. However, when I swap the identifier out with "this", it no longer works. This script is contained within the movie clip I am trying to reference. I have found that, "this" works fine by itself on the timeline. It just stops working when I place it within a conditional statement.
Here is my script:
function functionOne() {
randomX = 550*Math.random();
randomY = 400*Math.random();
} functionOneInterval = setInterval(functionOne, 1000);
function functionTwo() {
[Code] .....
The reason I am trying to use "this" instead of the identifier name is because the movie clip it is referencing will be duplicated. This script here generates a random destination point for an enemy spaceship and tells it to constantly move to the changing points. This script is contained within the enemy spaceship movieclip, and I am planning on duplicating several of them at once.
View 1 Replies
Mar 10, 2009
In this example, is there anyway to fade in and out 'mcContactAmer' and 'mcY' as well as place them at specific coordinates, other than externally load them as swfs? This is the only thing holding me back from moving forward on this project and my boss would like to move forward,
View 3 Replies
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
Jan 11, 2010
I'm working with 2 global variables and I need to compare them on 6 different button function clicks for a lot of different scenarios.[code]My function is starting to look like this;[code]only problem i see is that there are many different scenarios and this if statement could get very long. Is there a way to combine it somehow so there wouldn't be that many else if's?
View 3 Replies
Jan 25, 2010
I want to write AS3 code that has 2 variables; one that acts on odd numbers and the other that acts on even numbers entered into a text field ?(sorry I'm not making much sense here! Will explain the context further)I'd like to use an XML calendar in my Flash project that shows the odd or even dates in the calendar depending on what number you enter in a field being either an odd or even number. (This is based on ACT Water Restrictions odd and even watering restrictions)It means that if your street number is an odd number you can use water as per restrictions when the date also is an odd number. Similarly, if your street number is an even number you can water as per restrictions when the date also is an even number. You're probably familiar with this system.
The context is for my Adult Migrant students to understand the concept of our water restrictions here which is governed by this odd and even system.So what I'm doing to do next is buy a cheap XML calendar online which I can adapt for my project but I'm not sure whether I should be approching this code problem with an if/else statement to get the results or something else?how to write the code!!
if my number I enter is an even number then display (in an XML calendar) even days
else
if my number I enter is odd then display (tin an XML calendar) odd days
View 5 Replies
Apr 9, 2010
So I am creating a drag and drop game but the thing is that there is not one question for each statement. Is it possible to have say... 10 statments on the right and one "box" on the left where the statements can be dragged to, if its correct it stays there, if its incorrect it goes back to its original position.
View 12 Replies
Jun 15, 2010
I am interested in have a dynamic text field display three quotes at different intervals. I thought I could use the Timer to trigger these quotes by loading them into the dynamic TextField.
However, I cannot seem to get it going. I try to attach a number from the timer but that throws an error /1176: Comparison between a value with static type flash.utils:Timer and a possibly unrelated type int.
[Code]...
View 3 Replies
Oct 4, 2010
if(bookmark == "Q3") movieHolder.loadMovie("Q_3.swf");}else if if(bookmark == "Q4"){
movieHolder.loadMovie("Q_4.swf");
}else if if(bookmark == "Q5"){
[code].....
View 3 Replies
May 10, 2011
In a change of statements, i have if, else if, and else. Can I add a fourth condition? if so how?
View 2 Replies
Jun 23, 2010
Everytime I start my Flex application (as opposed to Air), Firefox is "waiting for.I am pretty sure that namespaces URL are not loaded, so why is Flex reaching out to adobe? Flash update?I am using Flash Builder 4.5ports into the Class?
View 1 Replies
Aug 30, 2010
Here's my question. Suppose I've written some AS3 code like:
statementOne;
statementTwo;
Is there any possibility that the garbage collector will run during or between my two statements, or does it only run after my "user" code has finished and returned control up to flash? We have an A-Star codeblock that's sometimes slow, and I'd like to eliminate the GC as a potential culprit. The codeblock is obviously more complex than my example above, but it doesn't involve any events or other asynchronous stuff.
View 6 Replies
Jul 12, 2011
I have an xml file that has a start date and length of a project... I use a repeater to load each project. The users' screen only shows 2 weeks at a time. I would like to make it so that if a project doesn't fall within the two weeks on screen, that the project isn't loaded. I could do this by sorting through the XML and finding the correct projects to load, and putting them into an array collection, but there's a "move date" button which allows the user to change the two weeks that are showed. Once the two weeks are changed, I would need the projects that fit into that new 2 week window to show.
[Code]...
View 1 Replies
Jan 26, 2012
I'm hoping to find out what the correct syntax is to better organize Case statements in Flash AS3. So below for example instead of having 3 case statements, couldn't I organize it somehow into just 1?[code]
View 5 Replies
Feb 6, 2012
Iv been trying to pass arguments through an addEventListener event in actionscript such as...
target.addEventListener("pComp", rakeSoil(target));
but i get errors.
Iv tried to google but no luck :/
View 3 Replies
Feb 1, 2009
I have been seriously investigating on using switch statements in this case to solve my problems, which I seem to see output showing up in clickHandler3 executed properly. However, I don't think scenario_save() has been doing anything, since I could not see the Alert.show statement been disclosed in the switch(pop2), and neither is any of the lines been written like I expected, but I do see the Alert.show in the switch(x) by executing the Alert. I have marked the sections using comments, and I wonder if I am allowed to use nested switch statements over another in Actionscript.
[Code]...
View 4 Replies