ActionScript 3.0 :: Multiple If / Else Statements - Not Working

Dec 31, 2010

I've been developing an AS3 based 2D fighting game engine (like Street Fighter II), and have run into an issue. I'm using if/else statements in my onEnterFrame function to hit test my fighters. This works great in my first if/else statement, but for some reason it doesn't recognize my second if/else statement that follows the first. I know it's not the code, because if I bring the second if/else statement up and place it above the first statement (simply swapping the order), the hit test is successful. Why is it that only the if/else statement that comes first works, but any that come after it don't?

Here's my code:
function onEnterFrame(event:Event):void {
//MOVE THE char1
PlayerBase.players[0].x += plyr1vx;
PlayerBase.players[1].x += plyr2vx;
[Code] .....

I've also attached a .zip file with my published files so you can see the issue in the game (must be viewed in a browser for keys to work correctly). Move the left player using "A" and "D" keys. Make him punch with "Z" and kick with "X". Punch is the first if statement in my code, and kick is the second if statement (not working).

View 10 Replies


Similar Posts:


ActionScript 3.0 :: Trace Statements Not Working?

May 30, 2011

if trying to debug in Flash, and for some reason some of my trace statements don't work. I believe this only happens when they're in event listeners, but it is very annoying. I am using CS5 and coding in Flash Builder 4.

View 4 Replies

ActionScript 2.0 :: If Statements Not Working As Coded?

Aug 20, 2004

I'm constructing a game for college and I've run into a problem. I've created a drag and drop game,I have 9 instances called "case_01", "case_02" etc. The user must place them into one of two boxes (called "input_01" and "process_01"). I've then created an incorrect message on frame 3 and a correct mesage on frame 5. I've placed the following code on the submit button with the correct answers:

[code]...

but this isn't working correctly. Must each if have an else? I'm a complete novice at this actionscripting

View 6 Replies

Professional :: Multiple Statements One Drop Box?

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

ActionScript 3.0 :: Loop For Multiple For Statements?

Oct 20, 2010

I need to put a load of MC's on stage with the use of an array as such:

Code:
for (var i = 1; i = 4; i++) {
if (reg[i] == "singlewall") {
var Wall:MovieClip = new wallClass() as MovieClip;
mainClip.addChild(Wall);
}
}

I need a lot more then 4 though and I need a way to make new "Wall" variables
Tried doing it with:

Code:
for (var i = 1; i = 4; i++) {
if (reg[i] == "singlewall") {
var Wall:MovieClip = new wallClass() as MovieClip;
Wall.name = "mc"+i;
mainClip.addChild(Wall);
}
}

This does not work though, yields an infinite loop somehow

View 4 Replies

ActionScript 3.0 :: Multiple For Loops Within Various If Statements?

Jul 28, 2011

I'm building a quick products display app for my company (basically customers put in certain numeric values and the app recommends a product based on the numbers.) I've done this with if statments and addChild()s

Now if they've gotten one result and they want to try with different values I need to removeChild() the product images from the stage.

So far I have this working by adding the addChild()s to an Array and using a for loop to remove them everytime the calculate button is hit. This works fine until I get to product double ups (some products can work across multiple values) then it errors.

Below is part of the code I've shorthanded some of the parts which are working fine as well as the repeat parts so that it's not just a whole blob of code

Code:
stop();
import flash.display.MovieClip;
equal_btn.addEventListener(MouseEvent.CLICK, equClick);

[Code]....

View 6 Replies

ActionScript 3.0 :: Try/catch Statements Working But Not As Expected?

Aug 21, 2009

I've got some try/catch statements in an XML parser I've written that don't seem to be doing what I want them to be doing.

The code:

ActionScript Code:
try
{[code]........

The problems:

-In the case the type is analysis or info (with other tags being alright) the "Default Text" is staying blank, even without a text tag.

-If I purposely malform the option tag, no alert window shows up and none of the other properties in the catch block (optionText,selType, etc.) get set properly

View 3 Replies

ActionScript 3 :: Multiple Statements In For Loop (1084 Error)

Sep 30, 2011

I'm trying to do a binary search in a for loop. However, flash does not like the following for loop.
for(var select:int = Math.floor((min + max / 2)), var turns:int = 0;
turns < input.length / 2 + 1;
turns++, select= Math.floor((min + max / 2))){
if(input[select] > want){ max = select;
} else if (input[select] < want){
min = select;
} else {
return select;
}}

On the first line I get 1084: Syntax error: expecting identifier before var. I think I know why (I'm using , to separate the different statements), but how do I fix it? ; won't work since it's what the for loop uses.
( var select:int = Math.floor((min + max / 2)) ;
var turns:int = 0);
turns < input.length / 2 + 1; //etc
does not work either.

View 2 Replies

ActionScript 3.0 :: Multiple If Statements - Place All Of The Same Parts Of The Face?

May 6, 2010

I am working on a puzzle has four different eyes, nose, and mouth. These can be placed on a blank head. I want to be able to place all of the same parts of the face, and have a response that says "Beauty" if the mix up the pieces from different faces, it will say "Beast." I don't know how to set up the AS3 to make this work.

View 1 Replies

ActionScript 2.0 :: Multiple If Then Statements To Check 3 Text Fields

Sep 9, 2010

I am trying to check 3 scores at once. Is there a better way to code this... I want to check to see if they are all tied? If one score is greater than another? Seems like there should be a more cleaner way.

[Code]....

View 4 Replies

ActionScript 2.0 :: Replacing Multiple Statements With A Loop - Syntax Incorrect?

Jun 30, 2009

I have a series of images loaded in via XML and assigned to "loady" movieclips. This code works fine:

Code:

_root.myMCL.loadClip(_root.myImages[0].attributes.url,_root.loady0);
_root.myMCL.loadClip(_root.myImages[1].attributes.url,_root.loady1);
_root.myMCL.loadClip(_root.myImages[2].attributes.url,_root.loady2);
_root.myMCL.loadClip(_root.myImages[3].attributes.url,_root.loady3);

[code]...

I want to replace this with a loop since I know the total amount of items (myImagesNo), but this isn't working:

Code:

for (i=0; i<_root.myImagesNo; i++) {
_root.myMCL.loadClip(_root.myImages[i].attributes.url,this["_root.loady" + i]);
}

View 2 Replies

ActionScript 2.0 :: Replacing Multiple Statements With A Loop / Syntax Incorrect?

Mar 12, 2010

I have a series of images loaded in via XML and assigned to "loady" movieclips. This code works fine:[code]

View 1 Replies

ActionScript 3.0 :: Using Multiple If Else Statements & Manual Dynamic Xml Data Input To Trigger A Goto And Play

Dec 19, 2011

Below is code that has a timer countdown that reads off of the computer. Below in bold is code to read "if it reaches the date, go to and play frame (2).

[Code]...

Below is code that is manual input - I had set up a dynamic txt field in flash named it : raffle_tix_remain When loaded on to the host I can manulally update the xml code and the change will take effect. raffle_tix_remain.text = root.loaderInfo.parameters.raffle_tix_remain;

My question: Since the raffle_tix_remain is a manual input from a user to xml Is there a way to tell flash once it refreshes and "raffle_ tix_ remain" goes to (0)zero gotoAndPlay(2); and let it play like a "sold out" sign i guess that would be a if else statement.

[Code]...

View 1 Replies

ActionScript 2.0 :: Use Multiple "if" Statements?

Mar 1, 2002

say i want something to happen, but I only want it to happen if more than two conditions are satisfied...is there a way to use multiple "if" statements?

View 3 Replies

ActionScript 2.0 :: If Statements Within If Statements?

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

ActionScript 2.0 :: Multiple Loops Not Working?

Jun 30, 2009

I'm new to flash, and this is my first post.I'm using Flash MX Pro, 2004 V7.I have this code in the first frame:

________________________________________
for (i = 0; i < 5; i++){
_root.attachMovie("A","A_" + i, i + 10);

[code].....

View 2 Replies

ActionScript 2.0 :: Multiple Conditions Not Working?

Jul 26, 2009

I've got two functions that work separately, but don't like to work together. Specifically, function "onEnterFrame" stops working after function "connectT."

function onEnterFrame(){
connectT();
checkBounds();
}

[code]....

View 7 Replies

Multiple Instances Of Movieclips Working With AS3?

Jul 9, 2009

I have several movieclips in my project which are being used as buttons, and when you rollover the mc's the content is viewable the entire time the mouse is hovering in the area of the movie clip, once the mouse moves off it disapeers. Great. I have the code that allows this to happen, but i have multiple mc's and only one works at a time. Here is the code:

mc.addEventListener(MouseEvent.ROLL_OVER, overHandler);
function overHandler(evt:MouseEvent):void {
mc.gotoAndStop(2);

[code].....

View 2 Replies

PHP :: Multiple Image Uploader Not Working

Dec 30, 2011

I'm attempting to create a multiple image uploader (think Coppermine) where the user clicks a button in an SWF, selects a file or multiple files, and then these files are uploaded to a directory. I have a PHP script that handles the uploading a file, and my Flash file iterates over the files in the FileReferenceList and sends the file to this PHP script to upload. The directory path in the PHP script is correct, and permissions set to 777.

The contents of my ActionScript 3.0 class look like this:
package com.yourfightsite.imageupload {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
[Code] .....

The three methods at the bottom of the class fire JavaScript functions in my HTML page that add the file names to a file queue widget, and update the percent value next to them, and finally mark them as complete. However, when I select files, they are added to the file queue widget as expected and then nothing. The files aren't uploaded, the files in the file queue widget aren't updated, and no errors are thrown, either in the console (I'm using Chrome) or Flash when publishing my movie.

View 2 Replies

ActionScript 3.0 :: Working With Multiple Projects

Aug 11, 2009

I am working on an educational project where users access multiple interfaces that teach them scientific concepts and I've come to a snag in the best method of developing these interfaces.As they were developed in the last module the format looked like this. Each interface was a separate swf file that contained all needed code, graphics, and a set of fake data for whatever the interface needed. Each revision of the interface is compiled and displayed through meetings or emails where the actual swf file is sent, we do not have a test server nor do we have access to the internet in the rooms where reviews happen. Currently after the final look and interaction is approved all calls to the fake data are modified to either make database calls themselves, or call functions from it's containing swf file once it is loaded.[code]Obviously I haven't gotten it to work but I'm thinking something along those lines. Any suggestions on a method to do this the best. Ultimately I would like to be able to do this for embedding assets as well. For example a font, currently I load fonts from an external file, which means each FLA needs a copy of that font file and at completion all files load the same text file.

View 3 Replies

ActionScript 3.0 :: Working With Multiple Bitmaps?

Jun 23, 2010

The next bitmap I have is the problem. I started with working on creating the playable avatar. He is on the same layer, but he only works if I add him AFTER the tile bitmap has been completed, AND if I call him with a listener.Call me crazy, but this seems to be when it works. The main class builds the tiles into the bitmap data, and while this is running, if the certain tile is where the main character starts, it calls the Hero class, and that class creates the new bitmap data. Doesn't work before running the loop that adds the tiles, nor after. weird right?

View 2 Replies

ActionScript 2.0 :: Multiple Conditions Not Working

Jun 15, 2011

I have some code that needs to read like the following:IF the original position(origX) DOES NOT EQUAL where my object is(this._x) AND delay variable(delay) is set to 0, then I need to display a movieclip. There is an X on the movieclip so users can close it, and when they click the X, the delay variable is set back to 1, so the movieclip won't keep loading.

ActionScript Code:
var delay = 1;
if (origX == this._x && delay == 1)
{

[code]....

View 4 Replies

IDE :: CS5 Working With Multiple Instances Of A Movieclip?

Jan 17, 2011

I am working on a project which looks like a crossword puzzle. When you mouse over on the white boxes they will light up. When you mouse over the letters they will have 3d rotations and when you rollover only some specific letters, they will flip some specific boxes.

Right now what happens is, when you mouse over the boxes with letters on them, the letters will rotate but the box will not light up. This is because I have created the box movieclip, with the invisible button inside it, and then just duplicated it in my scene to create a tile. But the invisible button for the letters are on the scene,so it's kinda overriding it.when I tried having the buttons on the scene rather than inside the movie clip, what happened is when you roll over one of the boxes, all of them will animate.

View 1 Replies

ActionScript 2.0 :: Multiple DuplicateMovieClip Not Working

Apr 16, 2011

I'm trying to make a moving star field using a for loop and duplicateMovieClip, but when I try to add more than one duplicateMovieClip statement, it ends up only doing the last one... so for example, with the sample code at the bottom, it would only make 20 small blue stars, instead of doing each one. I have no idea why it wont do each one, probably because im really new to Flash, and Actionscript.

[Code]...

View 2 Replies

Professional :: Multiple Scenes Not Working On Any Computer?

Dec 21, 2010

I try to run a swf or html file of my fla file and it only works on my machine but not on my laptop. I have the latest flash player installed but it still doesn't work. My laptop works for single scenes swf and html but not for multiple scene file.

View 5 Replies

ActionScript 3.0 :: Working With Multiple Instances - For Loop?

Dec 17, 2011

I'm very new to Adobe Flash CS5.5. Can you create a common instance EG: "Enemy" and then control it like so:
Enemy.x += 1;
So that all instances of Enemy will move forward one pixel each frame? Instead of just one enemy? If this is not possible could I set up some sort of array of enemies like you can in C and try something like:
int EnemyNo = 1;
for(EnemyNo = 1; EnemyNo < 5; EnemyNo++) {
Enemy[EnemyNo].x += 1;
}
Does Flash even support "for" loops?

View 21 Replies

ActionScript 2.0 :: Multiple MCs Using The Same Instance Name - Only 1 Of Them Working For The Function?

Nov 17, 2010

Got 9 MCs which I want a rollover effect for. I made 1, copied it and it's instance name 9 times. And made this script:

Code:
function menu_btn_over() {
myTween = new mx.transitions.Tween(_root.main.menu.btn.btn_parent, "_x", mx.transitions.easing.Strong.easeOut, _root.main.menu.btn.btn_parent._x, 0, inspeed);

[code]...

But it only works for one of the buttons. The one I made the copies from.I figured you could do this since it's the same MC? I could be wrong though. If that is the case, is there some way I can make the same action for every button without having to make a bunch of calls for each one? for example:

"_root.main.menu.btn1 <and> btn2 <and> btn3 <and> etc.onRollOut = function() {"

View 1 Replies

Actionscript 3 :: Working With Multiple Sounds & Channels

Nov 17, 2011

Are there any audio management libraries for ActionScript 3? The more tailored they are for game development the better.I'm finding it hard to understand and work with multiple channels, which is making a lot of my audio sound screwy and cancel each other out, etc. I've been working on an RPG that can at a given time have quite a number of sounds playing such as environmental noise (like opening doors, thunder, rain, etc), walking enemies, inventory sounds (for events like dropping an item into your inventory), passive spell-casting sounds, voice clips, weapon swinging etc. Alternatively, if there are any good resources that explain how to use multiple sound channels strategically.

View 1 Replies

ActionScript 2.0 :: Multiple MCs Using The Same Instance Name - Only 1 Of Them Working For The Function

Aug 12, 2008

Got 9 MCs which I want a rollover effect for. I made 1, copied it and it's instance name 9 times. And made this script:

[Code]...

But it only works for one of the buttons. The one I made the copies from. I figured you could do this since it's the same MC? I could be wrong though. If that is the case, is there some way I can make the same action for every button without having to make a bunch of calls for each one? for example:

[Code]...

View 7 Replies

ActionScript 3.0 :: Multiple Instances Of Movieclips Working

Jul 10, 2009

I have Multiple movieclips that when you hover over, a info box pops up and stays active until the mouse is moved away from the info box. Simple enough. I have multiple movieclips and i cannot get more than one to work. In order for the movieclip to work the instance name is 'mc' and this is the code i am using:

[Code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved