ActionScript 3.0 :: Write The Conditional Statement For Two Variables That Could Have A Range Of Values?

Mar 24, 2010

I am attempting to create what I call an 'On Air' rotator for a radio station.  I would like to pull in an image file for each program when it is on air.  I have the following AS 3 code that seems to work:

var now = new Date();
var day = now.getDay(); // Returns integer between 0 and 6
var hour = now.getHours(); // Returns integer between 0 and 23

[Code].....

The weekday programming is the same every day.  We have some programs that are three hours in length.  I would like to cut down on the number of statements I write.  I am unsure how to  combine the weekdays and have a range of hours in one conditional statement.  Will the following work?

if (day >= 0 && day <= 4 && hour >= 6 && hour <= 10)

I'm attempting to express the condition "if the day is Monday through Friday and the hour 6 am to 10 am"

View 5 Replies


Similar Posts:


Actionscript 3 :: Write Inline Conditional Statement In Flex With Two Expressions(case)?

Jan 7, 2012

How i write the inline conditional statement in Flex with two expressions(case) [code]...

Flex compiler only check the first expression and on behalf of that give result.But i want to check both statement and show result.

View 4 Replies

ActionScript 3.0 :: Conditional Statement For Multiple Variables

Oct 27, 2009

I have a conditional statement (if) that I am trying to use contingent on multiple variables being true. So the AS I have right now is:

[Code]...

But when I run that I get the following error message: "Error 1050: Can not assign to a non reference value" What do I need to change so that once 1,2 and 3 have been visited visitComplete is set to true?

View 3 Replies

Stopping A Flv Using A Conditional Statement?

May 26, 2009

I have FLV files that continue playing when I leave the frame that they are on. I can stop the playing FLV by putting this code on the following frame:
 
if (demo.playing) {  demo.stop();}
 
Where .demo is the name of the instance of the .flv component.
 
Here is the problem - I have many frames with many flvs, and when I tell flash to stop multiple FLVs, for instance:

if (demo.playing) {  demo.stop();}
if (demo2.playing) {  demo2.stop();}

I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference
 
As far as I know, flash is telling me that since the instance of "demo2" has not started playing yet (ex. the user only went to the page with the "demo" flv, but not the "demo2" flv yet) that flash has no idea what demo2 is yet. I thought using a conditional statement would remedy this, but I suppose the .swf can't stop playing something it does not yet know exists.

Is there any way I can introduce all of the flv's at the beginning of the file, yet not have them play and not have flash "forget" about them so that I can stop them using the code above? Or is there a way to have the conditional statement not error in the event that the referenced instance has not yet been "introduced"?

I really wish they would have added an "exit frame" command in AS 3.0...

View 1 Replies

ActionScript 3.0 :: Movieclip In Conditional Statement Of If?

Nov 28, 2009

In the code below how can I use the movieclip in the conditional statement? This is simplified, there is lots more going on but the basic issue is shown. I want to say if currently dragged mc is dot1_mc do the copyDragTo35 function

PHP Code: var item:MovieClip;
//add event listeners to all dots
kite_mc.dot1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
kite_mc.dot2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onItemDragStart);
function onItemDragStart( e:MouseEvent ):void {

[Code]...

View 2 Replies

Stopping A Flv Using A Conditional Statement If The FLV Is Playing?

May 25, 2009

How would you stop an FLV using a conditional statement where the condition is if the FLV is playing?

I'm using AS 3.0. My best shot was this:
 
if (demo.flv == play){ demo.flv.stop();  }
 
I'm sure the "== play" part is wrong, but I cannot find the correct code that checks to see if the video is currently playing.
 
My flv component does have an instance name of "demo". The command "demo.flv.stop(); works fine as a non-conditional, but the flv is not always playing with my navigation set-up when you land on the frame with the code, so I need a conditional.

View 3 Replies

ActionScript 3.0 :: Conditional Statement And A Counter?

Sep 1, 2009

I'm trying to make a button that if you hit it 4 times it plays a movie clip. On the 5th hit- I want it to play a different movie clip. After the 5th hit- it resets itself and the process would start all over again. The script is all in one keyframe and the movie clips are being played with functions.

playButton_btn.addEventListener(MouseEvent.CLICK, goButton1);
function goButton1(evt:MouseEvent):void{  runningMan_mc.gotoAndPlay(2);}

View 6 Replies

ActionScript 3.0 :: Conditional Statement For Loaded Swf?

May 14, 2010

I am initiating loading a swf file, "bg1.swf". I have a button that, when clicked, is suppose to check to see if "bg1.swf" is loaded.I cant figure out how to write the conditional "if" part.  Currently, instead of checking to see if my statement is actually true, it executes loading bg1Req?  Here is the code .

var bgLoader:Loader = new Loader();
var bg1Req = new URLRequest("bg1.swf");
var bg2Req = new URLRequest("bg2.swf");

[code].....

View 7 Replies

ActionScript 1/2 :: Syntax For A Conditional Statement?

Dec 1, 2010

My son is doing a self-study course and is currently haviong a problem with the syntax of a condtional statement in Actionscript 2The folllowing code,

if (colour="red") {gotoAndPlay("BadEnd_red")}
else if (colour="blue")  { gotoAndPlay("BadEnd_blue")}
else  //colour ="green"  { gotoAndPlay("BadEnd_green")}

[code]....

View 3 Replies

ActionScript 3.0 :: Conditional Statement From XML To File?

Dec 16, 2011

I'm trying to pull in a conditional statement from an XML file to an actionscript file. Basically, the idea is that I have an activity called "keyPress.as" that is included on a Flash page. Directions, success and failure text are pulled in dynamically from XML as well as the resulting screen shot on success. Success is defined as the correct key stroke from a user when the corresponding page's .swf file is run. Could be a single key or key combination.
 
Here's the basic AS code that I'm using (please assume that 'pageData' is the loaded XML - that is done in another file - and it works for pageData.directions, which pulls in the directions text from the XML <directions>text</directions>):

[Code]...

View 3 Replies

Actionscript 3 :: Conditional Statement Not Working?

Jan 23, 2010

In my code here:

var manTimer:Timer = new Timer(1700,5);
manTimer.addEventListener(TimerEvent.TIMER, moveMan);
function moveMan(e:TimerEvent):void {[code].....

I am trying to get it so that when btnElScorcho or btnTheGoodLife is clicked it'll move my "man" mc out onto the stage. It starts at 590px and ends at -10px. That part is working.What is not working is my conditional statement that tells it to only move the "man" if he is at the x position of 590 or greater, because, when one of the 2 buttons is clicked again, I don't want to move him out if he is already there or if he is already moving out.So for some reason, "man" will still move when the buttons are clicked a second time and oddly enough, "man" will only move twice as opposed to the normal 5 times set in the function.Maybe I can change the if statement to check if the button has already been clicked as opposed to where "man" is?

View 1 Replies

ActionScript 3.0 :: How To Create Conditional Statement

Dec 12, 2011

create conditional statement that will tell, that if time is 0 and enterframe event didn't played, we will trace in output window ("event didnt started")

View 1 Replies

ActionScript 2.0 :: Conditional Statement Not Working?

Jul 31, 2008

In the code below i can't seem to get the second conditional statement to work.

on (press) {
startDrag(this, true);
}
on (release) {

[Code].....

View 3 Replies

IDE :: Leg Movement Conditional Statement For Game

Oct 26, 2009

I have a character in a game that moves in accordance with keyboard commands.. I'd like to have it so that when the character moves on the stage his legs simulate walking. Meaning.. when moving right, his legs rotate counter clockwise. But since there are two moving at the same time, one moves forward to a point while the other moves back to a point (the legs don't circle over his head), I need a conditional statement that indicates that when his leg's rotation is greater than 149, it reverses direction until its at a certain point, then moves back.. The below code is for one leg.

addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event): void{
if (Bear.Leg.rotation >=149){
Bear.Leg.rotation -=1;}
else {Bear.Leg.rotation +=1;}

I know why this doesn't work, it passes 149 and then moves back until it's below 149 and gets stuck in a loop. I need it so that the first statement gets overrided then flips back to it later. How can I do this?

View 2 Replies

ActionScript 2.0 :: Switch Statement Range EX: Case 90 To 100?

Feb 18, 2004

How do you do a range using switch statement in ActionScriptFor example:

score = txtScore.text
switch(score)
{

[code].....

View 3 Replies

ActionScript 2.0 :: Switch Statement Range EX: Case 90 To 100

Feb 18, 2004

How do you do a range using switch statement in ActionScript For example:

[Code]...

View 3 Replies

ActionScript 3.0 :: Remove Child Conditional Statement?

Mar 23, 2010

I have a video being added to a mc:
 
mc.addChild(video);
 
I need to create a conditional statement to see if "video" is loaded in my mc so I can remove it to add an image into the mc
 
if (mc...=="video"){
removeChild(video);
mc.addChild(image);
}
 
Not sure how to create the "if" part.

View 6 Replies

ActionScript 3.0 :: Play Or Stop Conditional Statement?

Aug 3, 2011

I have an animation that plays from the beguining to the end. I would like to add a conditional statement that IF the animation is Playing and the ANIMATION BUTTON is clicked, it stops and goes back to frame one. ELSE (if the animation is on frame one (not playing) it starts playing to the end.
 
My script goes like this -
 
animation_btn.addEventListener(MouseEvent.CLICK, startplaying);
function startplaying (event:MouseEvent);void{
play();
animation.play();
}
 
animation is the name of the animation time line.

View 5 Replies

Actionscript 3.0 :: Alternative To Key.isDown Conditional Statement?

Oct 19, 2010

I have a logic-sorta question about finding an alternative to an if/else statement that controls key.isDown detection.(NOTE: I am using senocular's KeyObject class, the utility found on his website senocular.com, that returns key.IsDown functionality to AS3)

typically in most game/character movement tutorials I see this:

Code: Select allif (key.isDown(Keyboard.RIGHT))
moveRight();
else if (key.isDown(Keyboard.LEFT))

[code]....

The problem im having with this code is the fact that theres an order it checks the keys due to the if/else statement.For example, if I was holding down the LEFT key and then simultaniously began holding down the RIGHT key, the RIGHT key's function would execute and override whatever the LEFT key's function was doing, since the RIGHT key is the first thing checked in the if/else statment.

The only work-around i can think of is making all the keys a single If statement, and a switch statement that controlls the movement. Which im having a lot of trouble getting to work at the moment...

View 1 Replies

ActionScript 3.0 :: Conditional Statement Only Reading The Final Else?

Apr 10, 2009

In this conditional statement (listed below), only the ending else is being populated, regardless of the url being selected. Within the code below the "content/PT.xml" is being displayed. Both my AS3 statement and html are posted. Does anyone see an error that I am overlooking.

[Code]...

View 6 Replies

AS3 :: IDE - URLLoader Data Not Being Recognized By Conditional Statement?

Jun 1, 2009

I am loading data from php using the echo method into flash via the URL loader:URLLoader method. The data then gets assigned to an objectMy problem is that the loaded data is being imported in fine and I can trace it and even display it in a text box, but if I try and use this data in a conditional statement - the statement just won't recognize its value?

My PHP---v
$row = mysql_fetch_array($query);
echo "result=success";

[code].....

View 1 Replies

ActionScript 3.0 :: Conditional Statement - Go To The Selective Frames?

Jun 22, 2009

i setup this conditional statement.my intention was that if the object foot_mc was on point0_mc then it will go to frame 5

OR

if foot_mc was on point1_mc it will go to frame 10....

function Oncheck(evt:MouseEvent):void
{
if(foot_mc == point0_mc) return;[code]....

i get NO errors but it will always go to frame 15.... instead i want it to go to the selective frames depending on where foot_mc is...

View 4 Replies

ActionScript 2.0 :: DateChooser.selectedDate Conditional Statement?

Oct 16, 2010

all I want to do is check to see if a date is selected, trace something; else, trace something else. simple enough right?assuming my_dc as DateChooser instance name, I use:

this.onEnterFrame = function() {
yesterday = new Date(2009, 0, 22);
my_dc.selectedDate = yesterday;

[code].....

View 5 Replies

ActionScript 3.0 :: URLLoader Data In Conditional Statement Not Recognized?

Jun 1, 2009

I am loading data from php using the echo method into flash via the URL loader:URLLoader method. The data then gets assigned to an object.My problem is that the loaded data is being imported in fine and I can trace it and even display it in a text box, but if I try and use this data in a conditional statement - the statement just won't recognize its value?[code]My problem is in green above. The variable/data being imported in is indicating which measuring unit the user preferred - "inchs" for inch's or "cms" for centimeter's.The statement never seems to recognize this data and always proves false and 'else' is executed.However if I instruct the data to be displayed in a text box eg."display.text = n.unit;" The text box displays the correct result as if the data has came across fine?

View 3 Replies

ActionScript 1/2 :: Conditional Statement Not Working Properly On Button?

Nov 25, 2009

Here is my current small piece of code I have on a given "letter" button..

on (release) {  if (_root.Acheckmark._visible=true) {  _root.AScore = _root.AScore+_root.APoints;  } else if (_root.Bcheckmark._visible-true) {  _root.BScore = _root.BScore+_root.BPoints;  }}

View 1 Replies

ActionScript 2.0 :: Displaying Dynamic Text - Conditional If Statement?

Feb 9, 2010

I have a dynamic text box (called navgxchangeBox below) that is being fed by an xml file.Depending on the output (weather positive or negetive) I'd like the text to display green (for pos) or red (for neg). I know I need to write a if conditional statement but not sure if it is correct. The text is displaying in color, but I don't think the condition loop is executing. Can anyone look at my code below and tell me what I am doing wrong?

ActionScript Code:
//
var myXML = new XML();

[code].....

View 3 Replies

ActionScript 3.0 :: Conditional Statement For ROLL_OUT If Button Clicked

Mar 2, 2011

I've been struggling with an issue for a while now and can't find a solution. I've got a series of movieclip buttons that I have going between states on ROLL_OVER, ROLL_OUT and CLICKED. It's very straightforward - except for the fact that I can't get the CLICKED function to take precedence over the ROLL_OUT and I was wondering if there was a way to make the ROLL_OUT conditional on the click. ex:

ActionScript Code:
//this is coded on a series of 5 buttons, only 1 is shown as example:
paintings2000_but.addEventListener(MouseEvent.ROLL_OVER,onPaintingsOver);
function onPaintingsOver(state)

[Code]....

So my issue is that I need the ROLL_OUT to be conditional based on whether someone has clicked the button or not; but I can't find a solution for how to do that in this context!

View 3 Replies

ActionScript 2.0 :: Get Control Of The Time Line Using A Conditional Statement?

Nov 26, 2008

I'm using Flash MX 2004 Actionscript.

I'm trying to get control of the time line using a conditional statement.

if (myVars.logged == "Logged") {
gotoAndStop(20);
}

I trace the myVars.logged variable and the trace tells me the value is Logged.

But the above statement won't go to frame 20.

View 9 Replies

ActionScript 2.0 :: [Flash CS4] Conditional Statement To Trigger An Event

Nov 30, 2008

I want to trigger an event when 4 buttons are being set to visible(originally set to ._visible=false at the beginning of the movie) say, the instance names of the buttons are "a","b","c",and "d", and their visibility is triggered by other events.When all of them are triggered/being set to visible, I want a movieclip to play (say, the name of the movieclip is "animation") I tried using the if statement and came up with the following code:

[Code]...

View 7 Replies

ActionScript 3.0 :: Conditional Statement To Determine If An Xml Child Is Null?

Jun 16, 2009

With this code, I need to determine if the xml child is null and form a conditional statement upon that info.I have it very close but something is just "un-tweeked" enough that it wont work correctly.AS3 and XML provided below...

Code:
var url = txtBox_mc.getTix.url;
var request:URLRequest = new URLRequest(url);
txtBox_mc.getTix.addEventListener(MouseEvent.CLICK, GetUrTix);[code].....

The problem now only the " if (url == null) { " is read, thus returning those results. I believe the issue is within the definition of url " var url = txtBox_mc.getTix.url; "...

View 3 Replies







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