ActionScript 2.0 :: Run A Function In An If Else Statement?
Jan 14, 2004How do I run a function in an if else statement?
View 4 RepliesHow do I run a function in an if else statement?
View 4 RepliesI was wondering if there was a way to get a function to run the getURL statement? something similar to this:
function go(){
getURL("www.whatever.com","_blank");
}
I'm wondering if there is a limit as to how may if else you can put in a function. I have a form that never seems to fire the last if else on the first load. It will work once I've run through the form, and all of the times after that, but never on the first try. In other words, when I test the form for the first time, if # 5 never kicks in. But after the form has sent, I can run the form again and if # 5 will work like I want it to. I did add .tabIndex to the form because it wouldn't originally tab the way I wanted it to and I wondered if this might be part of the problem. I also tried moving the if else statements around, but that didn't seem to make any difference. Does it only read 4 if's at a time?
Here's the code:
// add evenlistener for submit buttonsubmit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
function ValidateAndSend(event:MouseEvent):void{
// if #1
if(company_txt.text ==""){
company_name_mc.gotoAndPlay("red");
[Code] .....
[code]...
now when you first look at this code.. it looks perfectly fine right? .. well if you use this exact code and place a clip on the stage with an instance name of 'mc' .. publish and rollover 'mc'... the trace statement does not show.. is there something I never read about with respect of creating functions inside if statements??
I would think you could use the function name(){ syntax.. and not be forced to using variableName = function(){ syntax in creating functions inside if statements..
I am trying to make a dropdown menu where the user hovers over a bar it gets larger with more links then when they roll off it disappears. I am struggling to get my links to only appear when the menu is extended.. atm they show all the time. I thought it might be possible to have the btn function inside of the mouse event but it doesn't work.
Code:
import com.greensock.*;
import com.greensock.easing.*;
var emptyMc:MovieClip = new MovieClip();
function mouseMove(event:MouseEvent){
if(mc.hitTestPoint(mouseX, mouseY, true))
[Code] .....
I also would like to call an array at some point to go to the dynamic text field for my links.
In the main timeline I have this onEnterFrame function. I also have this movieclip and in it's own timeline stops at frame one. When this movieclip is rolled over it plays and then stops at frame 9. I'm trying to make an if statement in the onEnterFrame function that says when that one movieclip is on frame 9, delete the onEnterFrame function.
I tried to do this code, but so far all I have is
if (movieclip._currentlabel = "framenine") {
delete this.onEnterFrame;
}
I am trying to reference a function in an if statement and it's not doing anything. The reference is here.
Code:
private function newNumber (qTotal:Number, curNum:Number):Number {
var newNum:Number = Math.floor(Math.random()*qTotal);
[code].....
I have set up a system that spawns barriers for the player to dodge but it appears the functions won't trigger properly from within "if" statements.
PHP Code:
var speed:Number=2;
var barNumber:int=6;
var barLoop:int=0;
var timer:Number=0;
var limit:Number=100;
[Code] .....
I am trying to reference a function in an if statement and it's not doing anything. The reference is here.
Code:
private function newNumber (qTotal:Number, curNum:Number):Number {
var newNum:Number = Math.floor(Math.random()*qTotal);
for (var j:Number=0; j<curNum; j++) {
[Code]....
so I am trying to embed xml files for a game based on the button I select. I assume I would need an event listener, however I do not know how the function should look.
Code:
[Embed(source="folder/jonesy.sng", mimeType="application/octet-stream")]
[Embed(source="folder/markysng", mimeType="application/octet-stream")]
[Embed(source="folder/John.sng", mimeType="application/octet-stream")]
The instance name for the button is "jonesy", "John" , "Marky". I would like when the user selects the button jonesy, the above code is activated.
If the user selects " John, or Marky" the corresponding embed code for those are loaded.
I have
Code:
jonesy.addEventListener (MouseEvent.CLICK, whichxml);
John.addEventListener (MouseEvent.CLICK, whichxmljohn);
function whichxml (e:MouseEvent):void
[code]....
this isnt' working though. Not sure what is missing, or if it just needs to be an IF Then statment.I guess embeds have to go on the intro frame, or first frame? But, the problem I have is that, I have so many embeds it is freezing the whole game.
I have a main.as scipt whereby i put the following in the constructor main function.
L1: LoginScreen.enterBtn.addEventListener(MouseEvent.MOUSE_DOWN, checkLogin);
L2: map.visible=true;
it will execute checkLogin function but stuck at Line 1. how do i make it run Line 2?
I am having a problem with the if statement in my timer function, the trace statement within in it is not working, eventually I wanted to use this if statement further but need to make sure it is working first.
Code:
timerFunction();
} function call in function above
function timerFunction() {
trace("hey");//this trace works
var myTimer:Timer=new Timer(1000,15);
[Code] ......
I have a movieclip with the instance name information_mc. I am trying to get this movieclip to move up and down, depending on its y co-ord or in what direction it is tweening at the moment it is clicked.I have the following AS:
Code:
information_mc._y = 240;
var curMovement:String = "goingup";
[code]......
I'm just trying to make a simple function that will return all the data from my SQLITE database as an array. But it looks like when my function is returning the array, the SQL statement is actually still executing... so it's empty... Does anyone have a suggestion? Or am I just going about this whole thing wrong.I know I could just have the event listener functions outside this function, and they could then set the data. But i'm trying to make a AS3 Class that holds all my SQL functions, and It would be nice to have everything for this particular function just in one function, so it can return an array to me.
public function getFavsGamesArray():Array
{
getFavsArraySql.addEventListener(SQLEvent.RESULT, res);
[code].....
I have a bunch of event listeners that refer to different movieclips but trigger the same function.I have an if statement within this function that I need to trigger if the function is triggered by a specific movieclip.
ActionScript Code:
//movieclip stuff....
addChild(backgroundPoint);
backgroundPoint.addEventListener(Event.ENTER_FRAME, animateBall);
[code]....
I know I could just create two separate functions but the code within the function (not shown here) is fairly long and I dont like repeating code.
Code:
_global.picWmax = 436;
But when I call the imageSize function with the if statement it doesn't work.
Code:
function image(){
[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.
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.
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.
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
I'm making the transition from AS2 to AS3 and have some rollover and rollout code below. I'm looking to place an if statement into the onClipOver function that can trace what specific button is being pressed. In AS2 I would use the "this" command to see which movieclip was being used. how to properly write the IF statements using AS3 in the code below.
[Code]...
I suspect I'm doing something silly here. Keep getting a #1009 error pointing towards the fadeOut function on frame 2. Here's the scoup, TIA! Frame 1: Clickable Logo that sends the playhead to frame 2
[Code]...
how to integrate an if/then statement with the "getDay" function.
I want Flash to find out what the date is. I know I can do this with:
Code:
var dayOfWeek_array:Array = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var today_date:Date = new Date();
[Code]....
How do I get these two to talk to each other, first finding the day value and then loading the correct movie based on that value?
I am trying to get an "if statement" to run a simple function.
View 5 RepliesI 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 Replieswhat 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?
I 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){
}
I have a movieclip on the screen called "mc_bg". Within this movieclip are 7 movieclips called "barrier1" through "barrier7".From main.as I want to be able to do this call:
for (var i: int = 1; i < 3; i++ ){
trace("got here")
trace(mc_bg["mc_barrier" + String(i)])
[code]....
I've got a Vector of ViewToActionMap objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
[code].....
Is it possible to use a if statement with a eventlistener in it?
eg
if(myBut_btn.addeventlistener(MouseEvent.CLICK)){
[code]....