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
Similar Posts:
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
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
May 26, 2011
I am trying to get my pages through Case Statement But.
[Code]...
View 6 Replies
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
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
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
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
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
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
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
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
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
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
Dec 17, 2008
I'm trying to use the value from a combo box in a switch case statement but it isn't working
Code:
var switchValue:int = 0;
switchValue = int(cmbColour.selectedItem.data);
switch(switchValue) {[code]....
View 4 Replies
Feb 20, 2009
I've got a slider on my navigation bar that rides along with the mouse; movies play perpendicular to it as I scroll. If I click on the movie, I link out to another page (easy enough). However, the actual slider doesn't do anything more than look nice. I know that if I don't make this thing child proof, I'm going to catch grief about it. So I tried to set up a switch that links out according to range values y<0 && y>125. As it stands, I don't get any errors, it just always goes to default. I'm missing something.I could always try a gia-normous 'if' statement, but I thought that I'd give the switch a try.
View 4 Replies
Nov 2, 2010
I see Switch statement in:
switch() {
case 'string': ...;
}
but would hope if I could do this?
View 1 Replies
Jan 16, 2009
I'm trying to use switch/case staement instead of if/else but it's not working. Here's the code.
ActionScript Code:
//working code
function checkTarget(drag){[code].............
View 3 Replies
Feb 18, 2004
How do you do a range using switch statement in ActionScriptFor example:
score = txtScore.text
switch(score)
{
[code].....
View 3 Replies
Feb 18, 2004
How do you do a range using switch statement in ActionScript For example:
[Code]...
View 3 Replies
Nov 27, 2002
Is there such thing as a "select case" statement in actionscript? If there is what is its format?
View 2 Replies
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
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
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
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
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
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
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
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
Jun 6, 2011
I have some trouble with the conversion applied by BlazeDS to the name of the properties when this name begins with a lower-case letter followed by a capital letter. I have an ActionScript class similar to this:
[Code]...
View 1 Replies