ActionScript 3.0 :: Condition Within An If Statement Is Executed?

Nov 11, 2010

I am developing a small game in flash and decided to use AS3 for it! Now the problem that has happened to me is that the condition within an if statement is executed!!!

Here is my code:

ActionScript Code:
if (y > 850 && splodeCount == 0)
{
play('Sploding');
splodeCount++;
}

Now instead of trying if the conditions (y > 850 && splodeCount == 0) are true it simply follows them as if they were orders. For example it places the object at y 850 and makes the splodeCount 0!

View 3 Replies


Similar Posts:


ActionScript 1/2 :: Execute Code In Previous If Statement If Second If Statement Is Executed?

Aug 31, 2011

if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code

[Code]...
 
I dont want to copy the code from the first into the second and the first and second into the third.
 
My mind isn't working and there is probably an extremelly simple way to get this working.
 
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.

View 7 Replies

ActionScript 1/2 :: If/then Statement Once First Part Of Code Has Been Executed?

Aug 17, 2009

I have some code on the main time line which basicially just says when this button is pressed go to this frame indicated by the frame label. In this case "answer". This is done inside a movie clip, which isn't on the main time line.

View 24 Replies

ActionScript 2.0 :: Possible To Have More Than One Condition On If Statement?

May 18, 2002

Is it possible to have more than one condition on an if statement?eg. if something is black and if it is 40cm then do the following..both conditions must be fulfilled before the action can occur.

View 3 Replies

ActionScript 2.0 :: For Loop WITHIN An If Condition Statement?

Jan 21, 2012

Is it possible to use a for loop within an if condtional statement? I have been trying but just get errors no matter what I do. I have a series of buttons that pop up in a window and I want to make it so a click anywhere outside of the buttons will close the pop up window. I have been doing this by running a hitTest that checks if any of the buttons are being touched one at a time. It works, but it seems overly tedious, especially since there are a lot of buttons. I do not want to put the hitTest on the background of the window because it will cause the mouse cursor to turn into a hand even when it is not over one of the actual buttons.

If the for loop can't be within an if condition, then maybe there is a better way to use the hitTest code, but I couldn't figure that out either. Here's a simplified version of what I have now (it works, but is too much code..):

[Code]....

View 6 Replies

Actionscript 3 :: Is This Statement About The Following Condition Correct

Feb 17, 2011

Look at this code:

var a:Number = 1;
var b:String = "hello";
if (a == 1 && b == "goodbye") {
trace("options a and b");
}

The book I am reading says: "In this example, the test would evaluate to true, because one of the two conditions (the first) is true. As a result, "option a or b" would be traced."Isn't the above statement incorrect? this if statement to me reads as "if a is 1 and b is goodbye THEN output it"

View 3 Replies

ActionScript 2.0 :: Multiple Condition (If Statement) Checking

Dec 11, 2009

I am trying to do a multiple if statement checking to determine which frame label within a MC (NE) and is located on frame 3 of the main timeline, to display. In the main timeline frame 1, I have declared a new var:
var n_e;
button1.onRelease = function (){
n_e1 = 1;
main timeline go to and stop at frame 3
}
[Code] .....
But it doesn't seem to work, and most of the time it lands up on Ne("2") instead...

View 6 Replies

ActionScript 2.0 :: Concatenate Two Strings As A Condition In A Case Statement?

Jun 14, 2010

I can't for the life of me come up with anything that works...

function setCurrentCMI(id){
if (_level0.strInteraction+id==""||_level0.strInterac tion+id=="undefined") {
//does nothing, user hasn't been here yet

[code]......

View 0 Replies

ActionScript 3.0 :: Condition - If The Variable Change Condition Don't Change

Sep 12, 2009

I have a BD return by PHP without problem : I have "all_good" and "no_good" If the variable change my condition don't change ..... why

[Code]....

View 3 Replies

ActionScript 2.0 :: First Requirement Of The If Statement When Type In The Proper Input And Go Straight To The Else Statement

May 14, 2009

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.

View 7 Replies

ActionScript 2.0 :: Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails?

Oct 10, 2008

The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.The purpose of the application is to load an XML file(works)Populate 2 text fields with information from the XML file(works)Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);

Heres the code:

Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {

[code]....

The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.CheckBoxes are mandatory.But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.

View 1 Replies

ActionScript 2.0 :: If Statement Inside If Statement Won't Work

Mar 30, 2011

why this code won't work

[Code]...

I'm sure you can put if statements inside other if statements, seriously I can't figure it out

View 4 Replies

ActionScript 3.0 :: Another 'if' Statement Inside An 'if' Statement?

Sep 22, 2010

I need to write an if statement inside an if-else statement. But no matter how I write it it keeps giving me a syntax error.The syntax error is "1083: syntax error: else is unexpected".[code]No matter how or where I place the braces, it keeps giving me errors.

View 13 Replies

ActionScript 3.0 :: Use A For Statement To Create An If Statement

Jul 12, 2010

what I'm trying to do is create an else if argument for each object in an array based on a user set number

Code:
for(var i:int=0; i < numberOfElseIfs; i++){
GENERATE AS3 CODE
}

to which I want it to GENERATE THE FOLLOWING CODE:

Code:
}else if(baskets[i].used == false){
baskets[i].used = true;
drawButton(i);
}

the problem is obviously that the compiler reads this code rather than understanding I'm trying to regenerate the code within the for loop...does that make sense :S? So basically I need as3 to read the code between the for statement as if it is going to echo that out later. Is this even possible?

View 4 Replies

IDE :: CS4 File Saving - None Of The AS Is Executed

Sep 17, 2009

I have students whose flash file works until it is saved. For instance, they create a untitled.fla file, press ctrl + enter and the swf file plays perfectly. At the end of class they save it, the next day they open it, and none of the AS is executed. The swf file plays as if no AS was ever written.

To make things even more puzzling, the file will play from different drives. For instance, if the .fla file is saved to a thumb drive, everything works. If the file is placed on the desktop everything works. If the same file is placed in a different students directory, everything works. I've contacted Adobe support, they directed me to read their (worthless) forums. I have recontacted their support trying to find some real assistance.

View 9 Replies

ActionScript 2.0 :: CS3 Code Executed Before Frame?

Jul 22, 2009

Was testing out my movie and using the simulate download option. Bored while waiting I started to resize the movie. Then I got an error about over 256 levels of recursion. Intrigued I tried to simulate the error again. I realized that it would only happen when I resized the movie a bunch while it was doing simulate download. Sometimes I would also get an error "A with action canceled because object didn't exist".

Digging through the code I couldn't figure it out. On the first frame of my movie all I had was a setInterval that changes the loadbar display to show how much is loading. It also tells it to stop(). Once loaded it tells it to gotoAndPlay(5). Frame 5 is where all of my other code is at. This error was happening at Frame 1? Then I remembered I had used "with" in some code to realign stuff on resize. Like:

[Code]....

As soon as I commented out the stagelistener stuff the error stopped. The stage code is on frame 5. It should not start running until the movie has loaded as frame 1 stops the movie until it is loaded. It is running BEFORE the movie is loaded though because I get the "with action" error and the 256 levels of recursion error. If I put a trace in the listener function it doesn't trace back until it is at frame 5, but for some reason part of it still runs. Anyway, sorry for the long explain...just a strange, strange error. Now I don't know what to do about it. I want the stage listener, but I definitely don't want an endless loop or other errors occurring.

View 1 Replies

View All Executed Code In FLA File

Jun 20, 2011

I wonder if there is any way to view the Actionscript that is exectued when executing a fla file. Or maybe a tool that would allow me to generate Actionscript through a graphical interface.For example, I create a Flash File and draw a circle.

View 1 Replies

ActionScript :: When Are Event Handlers Executed

Jun 23, 2009

When, in ActionScript, an event is dispatched:

foo.addEventListener("some event", someHandler);
foo.dispatchEvent(new Event("some event"));

At what point are the event handlers executed?

I ask because I caught this at the end of an Adobe developer guide:

Notice that some properties are assigned to the [AsyncToken] after the call to the remote service is made. In a multi-threaded language, there would be a race condition where the result comes back before the token is assigned. This situation is not a problem in ActionScript because the remote call cannot be initiated until the currently executing code finishes.

But I could not find any information on what they meant by "currently executing code".

See also: [URL]

View 2 Replies

Flex :: Protect URL Where Flash App Can Be Executed?

Sep 24, 2010

Is there an easy copyprotection, so that I can define in code the URL where flash/flex app can be executed

View 1 Replies

Actionscript 2 :: Flash Actions Get Executed Over And Over

Feb 21, 2012

My flash actions layer contains the whole source code. My question is: why does the actions layer get executed with a fresh start (new variables) more then once?

the following code snippet demonstrates what i mean:

var notyetexecuted:Boolean=true;
function addNetStream(counter) {
if (notyetexecuted = true) {

[Code]....

why this is the case and how Flash executes layer?

View 4 Replies

ActionScript 2.0 :: Codes Are Not Completely Executed?

Jan 13, 2012

I use flash MX 2004, and I've been facing a problem. I made this flash program to load a jpeg, and to resize and display it.. But the problem is, it works, but not in a stream I mean My program work in 4 phases::

1. Load the jpeg
2. Check and compare the image's height and width with the given parameters
3. resize the image... 3.1.. First height... 3.2.. Then width
4. Display the resized image

The problem I am having is, it does phase 1, then does nothing... I experimented with it a bit, and then i found... Let it do the phase 1, then goto another frame, then back to previous frame... It does step 2.. Do same thing again for other phases... Its sort of like I am refreshing my frame again and again to make my code work in bits and pieces.

View 3 Replies

ActionScript 3.0 :: Block Of Code Is Only Executed Once?

Jun 12, 2009

I have a block of code in a game I'm making that checks to see if guy1 is in contact with guy 2:

Code:
var randomGuy1X:Number = Math.random()*550;
var randomGuy1Y:Number = Math.random()*400;

[code].....

View 5 Replies

ActionScript 2.0 :: Cancel On(rollOut) When On(release) Is Executed?

Oct 13, 2010

I just can not manage to cancel the on(rollOut) event when the on(release) event has been started. I attach here a simple I need the solutions urgently because am trying to make a flash menue for my website.Here the code so far:

on(rollOver)
{
_root.gotoAndStop(2)

[code].....

View 10 Replies

ActionScript 3.0 :: Script Is Not Executed - Standard-TimeOut?

Nov 27, 2009

I have a problem with a script, that is debugged without mistakes, but is not executed anyway. The Script consists of the movie with a keyframethat creates a new Instance for an Object that again creates a series of new Instances for another Object (array) that controls an associated Movieclip.The Error: A Script was executed longer than the Standard-Time-Out of 15 Seconds.

View 11 Replies

ActionScript 3.0 :: Use HitTestObject To Determine If An Instruction Is To Be Executed?

Feb 26, 2010

I think in my last post I was trying something that wasn't possible, or correct There are 9 Children. The alpha of evt.target changes on mouse click, and a square is added around the evt.target which overlaps the two neigbouring Children.
 
The number of Children is then 10, and I am trying to detect whether the next evt.target is overlapped by the square before passing an instruction to change/not change its alpha.

[Code]...

View 35 Replies

Flex - Cairngorm XXXCommand Be Executed Several Times?

Oct 8, 2009

I ran into a problem.I'm doing a GIS program using flex. There's a map in my Application,when I click one icon on the map,windowA pops up,when I click a link inside windowA,windowB pops up,but here my problem coming out,when I close windowB and click the link inside windowA another time,Two windowB pop up...

[Code]...

View 3 Replies

Can Force Actionscript Code To Be Executed Lineary

Dec 31, 2009

Let's say I have some code like this in AS3.[code]The constructor for Thing is going to cause a swf to be rendered onto some movieclip.If the loop is run 10 times or so, most of the time I will only end up with a subset of Things showing up on the clip. I'm guessing this is a problem that flash is having loading a bunch of Things at the same time.I've been able to solve this problem by passing callbacks to the Thing constructor, and only continuing the loop once the previous Thing is completely loaded and calls back.First of all, is this a known problem? Or am I going about this in the wrong way? Secondly, is there any way I can tell flash/as to run this code in a linear fashion without the callbacks? It gets kind of annoying doing this everywhere.So I think richardolsson is right, we must be doing something wrong. To restate the problem, if I try to load multiple swfs onto the stage, even as few as two or three, without waiting for the previous one to finish loading, I will get an unpredictalbe number loaded. For example, running the loop above 10 times, I may end up getting the 2nd, 5th and 10th Things loaded. The others seemingly getting lost in asynchronousity. Flash shows no runtime errors in these situations. So here's the basic idea of how we are doing things.[code]This is the basic scheme. If I try to create a bunch of instances of 'child' WITHOUT waiting for the onLoaded function to finish on the previous 'child', random instances simply won't show up. I wrote the above code very quickly, it is not compy/paste, so ignore simple errors. Are there any glaring reasons why the above method does not work?

View 7 Replies

Actionscript 3 :: When Is Flash Frame Script Executed Exactly

Sep 8, 2010

I have a movieclip which has in the actions for frame 1

this["myCustomVar"] = "bla";

I then do this:

var mc:MovieClip = new MyMovieClip();
trace(mc.hasOwnProperty("myCustomVar")); // is false

Why does the movieclip not have myCustomVar, or to put it more generally:

When are frame scripts in movie clips executed exactly?

View 2 Replies

Actionscript :: Code Not Executed Without User Interaction?

Sep 27, 2011

The following code works as expected: when a user clicks the button, the installer automatically launches.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"[code]....

I verified that the installApp function is executed.Why doesn't the second piece of code work? Is user interaction required? If so what's a way around this?

View 1 Replies

ActionScript 2.0 :: When Pressing On The Button The Action Is Executed Just Once?

Sep 3, 2009

I have this project and I wanna when pressing on the button the action is executed just once

coz the action is Executed by the number of times you've pressed on .

here is my project :

[URL]

View 8 Replies







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