ActionScript 3.0 :: Checking Three 'if' Statements Are Correct Or Wrong?
Jul 24, 2009
I'm working on a quiz where a user has to drag three movie clips to correct positions then press the 'next'button to move on (calls funtion nxt).I have nxt function to check to see if the three movie clips have been dragged onto the three correct positions (other movieclips),the code works but only if all three are correct.I want the function to check to see if all the clips have hit the right target,
if so, then add +1 to the 'score' and go to frame 'end'
if the clips aren't on the right target then just go to frame 'end'
At the moment the nxt function doesn't work if the answers are wrong.
function nxt(event:MouseEvent):void
{
if (asc1_mc.hitTestObject(blank1_mc))[code]...........
I'm having the hardest time getting this to work, I have the concept of how things need to be put together, but the code is wrong. I can't even get the first if statement to work.I have a menu that is going to be loading external swfs into an empty mc. It needs to check to make sure the external swf has gone through its stopping animation before loading something else. Here's what I've got so far... I hope this is clear enough...button:
Code: on (press) { //check if this is the first mc being loaded
i have created a simple drag and drop game where users have to match shapes by dragging and dropping. What i would like is for a counter to count each correct drop and display a message if they are success-full.[code]
I'm just wondering if this is the "right" way to do the error catching. I have a program that creates a random number of squares (up to 25), but no more, and usually less (like I said, random number). Due to the fact that there's a random number of them, I create an array ahead of time. Only some of the squares in the array get used, and the others sit there and aren't added to the stage. Anyways, at the end of the box creation, the program goes back through and deletes all of the boxes in a loop:
It seems to work okay, but I just want to know if this is the correct way to check for errors. If I put a trace in the catch block, it catches the squares that aren't in the display list, obviously, because they aren't there to remove.
I am after finding out which drag and drops are correct, so I can score accordingly rather than just have a single score throughout. I need to know if the circle was dropped correctly or the square etc. I'd ideally like to have this interaction as a command on a button, but my AS3 is letting me down
var score:Number = 0; var startX:Number; var startY:Number;
The thing I want is like I will have a input text field for someone to type his email address, but after he presses the send button I want it to check that input field and see if there is the "@" and the "." symbol available in the field or no.
I'm trying to get the depths of all the blocks to be at the correct levels at the correct times so that the 3d effect is maintained. I've tried many things, but have had little success. All the instances of the blocks are stored in an array, but since it's adding them in accordance with when they're added to the stage, it doesn't help me locate them to swap depths. Is there a way to arrange them by location on the board?
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();
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.
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){
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] .....
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?
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:
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:
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.
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:
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] .....
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?
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.
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,
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,
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?
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
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.
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.