Simple Trace Statement
I can't for the life of me come up with a trace statement that tells me which "children" are on the stage at run time.
I use this to tell me how many are on the stage:
ActionScript Code:
trace(this.numChildren);
It seems I am missing an addChild call, and I want to figure out which children are on the stage. Thus eliminating areas that could be causing my problem
Simple enough I'm sure.
Thanks!
Lance
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 06-12-2008, 08:20 PM
View Complete Forum Thread with Replies
Sponsored Links:
Trace Statement Not Working
OK I have no idea whats going on, I can't get anything to work properly right now. I'm kinda new to this so If i'm missing something obvious please forgive me.
In an effort to simplify things I wrote the most basic script I could and it is NOT working,,, by that I mean I'm not getting the "trace statement" I'm not getting any errors either...
Here is the code I have PLEASE HELP !
(I have an FLA File named "landingPage" and an AS file named "main" the AS is in a sub folder named 'src' and the document class for "landingPage" is "src.main". All I want here is a simple trace statement to make sure I am starting on the right foot.....)
ActionScript Code:
package src
{
import flash.display.MovieClip;
public class main extends MovieClip
{
public function Main()
{
trace("working");
}
}
}
View Replies !
View Related
Trace Statement Not Working In Document Class
Hi,
I am new to actionscript and just like some of you, I would like to start off on the right foot. After several attempts to solve this problem I am now taking a break and reaching out to those in the community. I have created a .as file named Main.as and the code inside main.as is:
package
{
import flash.display.MovieClip;
public class Main extends MovieClip{
public function Main()
{
trace("This code works..");
}
}
}
then i created a new fla file and named it testas. I then typed Main in the Document class under properties.
The code has no errors and when I attempt to test the movie, there is no output to the output panel..
Can anyone please help or explain to me why this is happening??? Thank you...
View Replies !
View Related
Need A Simple If/else Statement, SOSneed A Simple If/else Statement, SOS
hi, i'm a new learner.
currently, doing an exercise on button.
i want to do a navigation button like
www.fendi.com (pls refer, thx ; )
where button that onPress it will remain,
the rest not clicked, will fade out.
i think i need a right if/else statement.
i've tried few, but still not working.
i have my flash file attached.
hope some experts here can help.
hear from you guys soon, thanks
View Replies !
View Related
What Trace Out Do You Get With This Simple Eg?
Hi Im trying to determine if an (enter) has occured within an input field. I have a feeling the character I need to test against may be different on a MAC and on a PC. So was hoping to get some feedback as to what results you get on your computer.
on my mac the following example always traces out "RETURN" when I hit return.
To test you will need to add an input textfield to the stage and call it "tf" then place this code on a frame.
ActionScript Code:
tf.addEventListener (KeyboardEvent.KEY_UP,checkKey);function checkKey (e:KeyboardEvent) { // for (var i=0; i<tf.text.length; i++) { var char = tf.text.charAt(i); if (char == "
") { trace ("RETURN"); } if(char == "
") { trace ("NEWLINE"); } if(char != "
" && char != "
" ) { trace (char); } } trace ("-------------------
");}
It would be a great help if you could check this out!
CHeers
View Replies !
View Related
Simple Slideshow: LoadVars, Undefined Trace...scope Issue?
I'm making a simple slideshow (Flash MX 2004 V7.2).
I'm using LoadVars to access an outside text document to get the number of slides used in the slideshow (path: vars/slideInfo.txt, totalFrames=4).
Now I KNOW this is elementary, and I know it is something I'M doing/not doing, but I can't get my slideshow to recognize: totalFrames=4 (unless I hardcode it in!).
Using trace I get "undefined" everywhere in my code except within my .onLoad function statement which traces the number correctly: 4 (or whatever I change it to).
From hours of internet searching I think this may be a scope issue.
I've tried adding additional code to fix this (my last efforts reflected below). Still I can't get the number of slides out of this function to be used by the rest of the slideshow.
Will someone please point out what I'm doing wrong (I know I'll feel stupid but I'll still appreciate it!)?
Thanks!
Trace Output from below code:
undefined
undefined
4
4
Code:
var totalFrames:Number;
var slideInfoLV:LoadVars = new LoadVars();
var totalFrames:Number;
trace(totalFrames); //output: undefined
slideInfoLV.onLoad = function(success:Boolean) {
if (success) {
slideCounter();
trace(this.totalFrames); //output: 4
totalFrames = this.totalFrames;
trace(totalFrames); //output: 4
} else {
frameNum.text = "error";
}
};
slideInfoLV.load("vars/slideInfo.txt");
trace(totalFrames); //output: undefined
View Replies !
View Related
Simple If Statement Pob's
here's the problem...
i have a movie which has 4 buttons on the main timeline.
button a
button b
button c
button d
each button triggers an mc to fade in when clicked, the mc then stops. there is another event in each mc after the stop action which fades it out again.
each button also asigns it's own value to a text field labeled "text"
i would like to be able to have each button, when clicked, to check the content of the text field and fade out the movie that it relates to, so only one movie is visible at any one time and the previous one fades out.
the script i thought would work is as follows;
on (release) {
tellTarget ("contenta") {
gotoAndPlay (2);
}
}
on (release) {
if (text=cantentfora.contenta.GotoAndPlay(16)) {
} else if (text=contentforb.contentb.GotoAndPlay(16)) {
} else if (text=contentforc.contentc.GotoAndPlay(16)) {
} else if (text=contentford.contentd.GotoAndPlay(16)) {
}
}
on (release) {
text = "contentfora";
}
check it out here, you can also download the fla.
http://www.angelfire.com/tv2/qualia/test/index1.html
any help would be much appreciated.
View Replies !
View Related
Fix This Simple Statement
hi ya,
just a quick one...
can any1 fix this statement. 'a' is a variable and 'amount' is a target
[a].amount = mainfoldernames[0][1]
so if 'a' = web
then the statment would read
web.amount = mainfoldernames[0][1]
you see?
any help v.appreciated
Danny
View Replies !
View Related
Simple IF Statement
I have a MX .fla file.
Frame 1 loads varibles from a .asp page with contents:
&username=Guest
Frame 25 (there is nothing inbetween these frames frames) has:
if (username=="Guest") {
getURL("http://www.google.com", "_blank");
stop();
} else {
stop();
}
This does not work (open the URL). If I set variable username=Guest it does! It is just when it is fetching the variables from a .asp page it dosent.
I even added a dynamic text box to frame 25 with Var: usename and Guest is displayed in the text box when loaded, therefore I know the variable is being loaded to the .swf.
How do I fix this condition statement?
Thanks!
View Replies !
View Related
Should Be A Simple IF Statement :(
hi, i will try to make the problem i have as clear as i can:
i have a main scene, where the buttons are in the first frame on their own layer. there is a stop function here.
when one of the buttons is clicked
****************************************
on (press) {
var whichScene = "theGuys";
}
on (release) {
gotoAndPlay("movementDown", 1);
}
****************************************
this above code is for the button "theGuys"
the variable is set and then the scene movementDown is played. This scene moves the buttons off the screen.
in the movementDown scene on the last frame there is a code which says
*************************************
stop();
if (whichScene = "theGuys") {
gotoAndPlay("theGuys", 1);
}
if (whichScene = "yourStuff") {
gotoAndPlay("yourStuff", 1);
}
**************************************
this is when the problem occurs. it just always plays the "yourStuff". i tried using the set Variable method but it still didnt work.
thanks pete
View Replies !
View Related
Help With Simple If Statement
Hi, I'm have a problem with a calculator I'm working on. below is some code for calculating a commission. There are 3 tiers to the commission table (i.e., 0-100.00 = 33%; 100.01-500.00 = 33%; 500.01-100000.00 = 20%). Those are adjustable through input text field on the stage.
the commission is calculated by the value in the "winningbid" variable. Anyway with the code I wrote below there seems to be a problem when the winning bid amount is between 1000.00-4999.99. Anythime the winning bid is in that range, the function enters the second if statement when it should be entering the 3rd if statement. Am I missing something here?
Code:
function comish () {
if(winningbid <= commission1b){
trace("<= 1b");
comtot = winningbid*("." + rate1);
}
// problem somewhere here...1000.00-4999.99
if(winningbid > commission1b && winningbid <= commission2b){
trace("2nd tier // commission1b/2b = " + commission1b + "/" + commission2b + " // winningbid = " + winningbid);
trace(winningbid + ">" + commission1b + " && " + winningbid + "<=" + commission2b);
x1 = commission1b*("." + rate1);
x2 = (winningbid - commission1b)*("." + rate2);
x3 = x1 + x2;
comtot = x3;
}
if(winningbid > commission2b){
trace("> 2b");
y1 = commission1b*("." + rate1);
y2 = (commission2b - commission1b)*("." + rate2);
y3 = (winningbid - commission2b)*("." + rate3);
y4 = y1 + y2 + y3;
comtot = y4;
}
trace("comtot = " + comtot);
wegetround = comtot;
_root.weget = roundTo(wegetround, 2);
perc1round = (weget/winningbid)*100;
_root.perc1 = roundTo(perc1round, 1) + " %";
}
View Replies !
View Related
Simple 'if Statement'
Heya, I've made this box thingie :
www.liquid-visual.com/editorialSTAGEtest.swf
and I just can't seem to get it working. The code I have attached to the little arrow button has the following code on it:
Code:
on (release) {
if (_root.layer2._y=166.3) {
_root.layer2._y += 156;
} else {
_root.layer2._y=166.3;
}
}
What should happen when you click the arrow in the swf is that the box extends to _y coordinate: 322.3
But I can seem to work out why the 'else' command doesn't send it back to _y coordinate: 166.3 when clicked again. Any ideas?
View Replies !
View Related
Simple If Statement Help
I have created a sliding menu similar to:
http://www.actionscript.org/tutorial...NU/index.shtml
Notice now this continues to drag no matter where the mouse is on the stage.
In the one I created, on my maine timeline I have the action:
if(_root._ymouse > 300) {
startDrag("/:dragControl", true);
}
if(_root._ymouse < 300) {
stopDrag;
}
so it will only drag when the mouse is over the menu (or appear to be).
The first statement works just fine. It does not start dragging until the mouse is down far enough. My problem is in the second statement. Once it starts dragging it continues no matter where the mouse pos is. Is this because the first statement continues running because the mouse (i)was(/i) greater than 300?
This is very basic but does not work and I do not know why. Can anyone please tell me where the problem is so I know where I messed up and how to fix it?
Thanks to all
View Replies !
View Related
Simple If Statement ?
I have a button that I need to check to see if another action is being performed and if it is I want it to execute, but if it isn't i don't want it to do anything. Can anyone help me set this up?
Example:
if I press "btn1" then it checks to see if movie "one" is playing. if it is then it pauses the movie, if the movie isn't playing, then it does nothing. Thanks in advance for the help.
View Replies !
View Related
Simple If Statement
Hi there a little bit of help, is this the correct way to define these if statements. Not too sure if i am doing it correctly.
Code:
function decreaseHealth (){
if (WaterAverage >60 <= 80){
currentDecreaseIncreaseHp+0;
}else if
(WaterAverage >40 <= 59){
currentDecreaseIncreaseHp-1;
}else if
(WaterAverage >20 <= 39){
currentDecreaseIncreaseHp-2;
}else if
(WaterAverage >10 <= 19){
currentDecreaseIncreaseHp-3;
}else if
(WaterAverage >0 <= 9){
currentDecreaseIncreaseHp-5;
}
}
View Replies !
View Related
Simple If Statement
Hi. I'm working on a button that opens up a submenu on the stage. The part that I can't really figure out is the if statement that goes once the MouseDown event has started.
I have an addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); and I can get the button to open up the subMenu (which is in a different class), but if I keep clicking the button it keeps opening up more submenus on top of the last one. I know i should have an if statement once the button is clicked but i dont know how to set it up. Basically something that says if the submenu is already on stage, don't open a new one, but if it's not on stage, then open one.
thanks.
View Replies !
View Related
Simple If Statement
I hope the following is pretty self explanatory. There is a ball movie clip "mc1" on stage. The addEventHandler simply starts a tween and the ball rolls from left to right until it's off the stage. I'm simply trying to make the clip stop when it reaches a certain x value on stage. I'm trying to teach myself simple techniques for the if statement and loops. Help with either is appreciated.
import fl.transitions.Tween;
import fl.transitions.easing.*;
mc1.addEventListener(MouseEvent.CLICK,ballRoll);
function ballRoll (e:Event):void {
var ballTween:Tween = new Tween(mc1, "x", None.easeIn, 0, 700, 3, true);
}
var posX = mc1.x;
if (posX == 300) {
mc1.gotoAndStop(0);
}
I have also tried the following:
import fl.transitions.Tween;
import fl.transitions.easing.*;
mc1.addEventListener(MouseEvent.CLICK,play1);
function play1 (e:Event):void {
var myTween:Tween = new Tween(mc1, "x", None.easeIn, 0, 700, 3, true);
var posX:Number = mc1.x;
if (posX == 300) {
mc1.stop();
}
}
Edited: 09/20/2008 at 09:19:15 AM by iRyFlash
View Replies !
View Related
Simple If Statement
I am using Flash 8, and for some reason, my if statement won't work. I have a scrollbar which scrolls a movieclip (that contains AS loaded material (eg. attachmovie). I want it so that only when the material is longer than the scrollbar do I see the scroll bar.
For some reason, it doesn't work. The traces don't even work!
if (scrollbar._height < menu_mc._height) {
scrollbar._alpha = 100;
trace("works");
}
else {
scrollbar._alpha = 0;
trace("not")
}
View Replies !
View Related
Simple If Statement Driving Me MAD
I'm trying to use a function to determine whether the user has used up all of his bullets in a game I'm designing. the script is very simple:
if (clicks==10) {
gotoAndPlay("gameOver");
} else {
return;
}
Although the 'clicks' variable counts properly and eventually reaches 10 and the function containing the if statement is successfully called after every shot, the script never sends the user to the 'gameOver' frame ('gameOver' is a frame label).
I've tried using _root.gotoAndPlay and gotoAndPlay(_root.gameOver) and I've even tried changing the name of the frame label.
If anyone has any ideas, even if you can explain why it doesn't work but have no alternatives, I'd appreciate the input. Thanks in advance!
View Replies !
View Related
Kinda Simple If Statement
hi,
i have a list of buttons and what i wanna do is when any button is pushed to go to a frame and play an animation (the same frame no matter what button was pressed) i can do that easy enough, however after the animation is played i then what to go to another frames depending on what button was pressed, i know i need to use the if statement with something like... if(button == home)
{goto home}
if(button == contact)
{goto contact}
etc
except im not sure what i put in for "button" and what i put in for "home" and "contact" etc.
can anyone help me?
thanks
rich
is there an easier way to do this?
View Replies !
View Related
Simple If Statement Problem
Hi all,
I am trying to declare a variable and then call the variable.
I'm pretty sure I'm missing quotation marks or something of that nature.
What am I doing wrong???
-----set variable--------
on (release) {
fav1 = 1;
}
-----call variable--------
if (fav1 <> 1) {
setProperty ("_root.favorites_page.fav1", _visible, false);
}
--------end code---------
Is this enough code to see my problem or do I need to post more info?
View Replies !
View Related
Simple If() Statement Needed
i have a simple verticle motion tween that i control by
on (release){
_root.clip3.play();
}
from frame 1 to frame 18 to frame 36 with stops(). i would like it to play()
only if it is at frame 18 and not if it is at frame 1. could someone show me
the syntax for this simple (?) script, please? i could of course make it
"gotoAndPlay(19)" instead if that would work better with an if()
statement...
thanks for your help in advance,
gn
View Replies !
View Related
If Then Statement Simple Part (not For Me Though)
i have mc with the following script
onClipEvent (load) {
fadespeed = 5;
}
onClipEvent (enterFrame) {
_level1._alpha -= fadespeed;
if (_level1._alpha<0) {
gotoAndStop("services1");
} else {
gotoAndStop("profile");
}
}
now on line seven as marked i want to go to the services1 marker frame if the alpha of movie on level 1 is 0. however this doesn't seem to work. i have scripting on the next frame that loads another movie and this is the only way i see to make things go in the corrrect order. like a movie is loaded then when another buttone is clicked it goes to looping frames with the top script and if i can figure out the script will move to the next frame for more actions.
any ideas or better way to do this would be of much help
thank you andrew
View Replies !
View Related
Simple IF Statement Problem
Hi,
I'm not a newbie as asuch but this should be easy to solve. I can't seem to get it right.
I have a series of movieclips. I'm using buttons to set their "visible" property on and off.
What I need is a button that when pressed says:
If movieclipA is visible and movieclipB is visible go to the next frame, else display an error movieclip.
I know I need to use an if/else statement but I can't seem to get the syntax right.
I'd really appeciate any help!
Here what I have so far:
on (release) {
if (movieclipA._visible =true, movieclipA._visible =true) {
gotoAndPlay(4);
} else {
setProperty("errorclip", _visible, true);
}
}
View Replies !
View Related
Simple If Statement Not Working
I have my main swf that calls video.swf onto the stage. Video.swf had 12 emptyclips that load dynamic thumbs. Over the thumbs I have 12 buttons. b1, b2, b3 so on so on.
Im trying to disable the buttons if there is no thumb loaded into the emptyclip.
Here is what Im trying.
if(_root.mtclip.video.h6._url== "http://www.solidtorch.com/tnike/videos/thumb6.jpg"){
_root.mtclip.video.b6.enabled=false();
} else {
_root.mtclip.video.b6.enabled=true();
}
Ive tried _parent. _root, even using and onClipevent on the MC themselves. Cant get it to work.
Any ideas why?
Josh
View Replies !
View Related
Simple If Statement Question
Hi Everyone,
I have a quick question about using a loop to write button functions. I would like to get the value of ring2var to equal "true" and for the if statement to recognize it. Any ideas as to why the code below does not work. Thanks in advance for your help.
Don
for (i=0; i<7; i++){
mc=this["ring"+i];
mc.onRollOver=function(){
_root.thebutton=this+"var";
_root.thebutton=true;
trace(_root.thebutton);
ring2var=true;
}
}
this.onEnterFrame=function(){
if (ring2var==true){
trace("GIL");
}
}
View Replies !
View Related
Simple Function And If Statement
This should work, but it doesn't:
I have two buttons, and it seems that the variable for 'activebutton' -
IS NOT BEING RECOGNIZED. Am I referencing my variable correctly and expressing the IF statement correctly ??
// Button 1
this.buttonsoa.button1.onRelease = function() {
_global.activebutton = "oabenson";
buttonhit();
loadVariables("data/contentoa_benson.txt", "");
};
// Button 2
this.buttonsoa.button2.onRelease = function() {
_global.activebutton = "oadeeks";
buttonhit();
loadVariables("data/contentoa_deeks.txt", "");
};
//abstract and keyfindings are buttons- that I want to be effected differently
depending on what the variable 'activebutton' is.
if (activebutton == oabenson) {
this.content_mc.abstract.onRelease = function() {
loadVariables("data/contentoa_benson.txt", "");
_root.contentoa.content_mc.onstates.gotoAndStop(1) ;
};
this.content_mc.keyfindings.onRelease = function() {
loadVariables("data/contentoa_benson_key.txt", "");
_root.contentoa.content_mc.onstates.gotoAndStop(2) ;
};
} else if (activebutton == oadeeks) {
this.content_mc.abstract.onRelease = function() {
loadVariables("data/contentoa_deeks.txt", "");
_root.contentoa.content_mc.onstates.gotoAndStop(1) ;
};
this.content_mc.keyfindings.onRelease = function() {
loadVariables("data/contentoa_deeks_key.txt", "");
_root.contentoa.content_mc.onstates.gotoAndStop(2) ;
};
}
View Replies !
View Related
Simple If Statement Not Working.....HELP
What I'm doing here is just wanting to show an artists name when the next record is accessed. The "if else" is not evaluating properly. Here's what I have .
First frame I initialize my variable to 0 like this since the first is always 0
var currentSong:Number = 0;
function showArtist(songNumber)
{
trace(songNumber);
if (songNumber = 0) {
trace("A");
} else if (songNumber = 1) {
trace("B");
} else if (songNumber = 2) {
trace("C");
} else {
trace("F");
}
I call it like this:
//Randomly gets the new number stored in a variable called songNum
{....
......}
//move current artist out
showArtist(currentSong);
//move new artist in
showArtist(songNum);
//set the currentSong
currentSong = songNum;
This code always traces out "B" So my trace looks like this:
0
B
1
B
1
B
2
B
I'm baffled, Can anyone help?
View Replies !
View Related
Simple Question About An If Statement
I am trying to have a certain moveclip turn invisible .....based on the x coordinate of another movieclip.
So, if the one MC 's x value is less then something, I want this other one to go invisible.
I'm trying this....
if (this.strip._x ==197.6) {this.mens.left._visible = false
}
But it just doesn't want to work. I've tried < 200 etc..... It doesn't seem to pick up the x value of the 'strip' movieclip.
Help? Thanks.
View Replies !
View Related
Simple If Else Statement Problem
Hi,
I'm trying to do following thing: when I enter frame on main timeline, I have to check if a movieclip is in a right frame on its timeline. If it is not, it should go to a another frame and play.
if (MC_instancename("frame1")) == true {
//DO NOTHING
}
else
{
(MC_instancename.gotoAndPlay("frame2"));
}
This didn't work.. I'm a novice in scripting, please help me to get started..!
View Replies !
View Related
Simple IF Statement Question.
Hi, i have a button that when pressed changes the value of a variable named "frm" from 1 to 2.
on another frame i have an if statement that reads
Code:
if(frm == 2){
prods.gotoAndPlay(2);
;
}
now, the MC instance "prods" does play the 2nd frame like it's told, except it only does so for a second then it reverts to the first frame of the MC. not sure what im doing wrong or i am missing. Please help.
View Replies !
View Related
[CS3] Please Help With A Simple Conditional Statement
Horizontal scroll menu keeps falling off the stage when cursor is on right side. I really need some help!
I have attached the file and below is the code. Thank you in advance!
var myShape:Shape = new Shape()
myShape.graphics.beginFill(0x7E00E3);
myShape.graphics.drawRect(50,10,450, 100)
addChild(myShape)
menu_mc.mask=myShape
stage.addEventListener(Event.ENTER_FRAME, movemenu);
function movemenu(myevent:Event):void {
menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
if (menu_mc.x>300) {
menu_mc.x=300;
}
}
View Replies !
View Related
Please Help With A Simple Conditional Statement
Horizontal scroll menu keeps falling off the stage when cursor is on right side. I really need some help!
I have attached the file and below is the code. Thank you in advance!
var myShape:Shape = new Shape()
myShape.graphics.beginFill(0x7E00E3);
myShape.graphics.drawRect(50,10,450, 100)
addChild(myShape)
menu_mc.mask=myShape
stage.addEventListener(Event.ENTER_FRAME, movemenu);
function movemenu(myevent:Event):void {
menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
if (menu_mc.x>300) {
menu_mc.x=300;
}
}
View Replies !
View Related
Simple If/else Statement Don't Work
I've made this simple script as my first encounter with ActionScript. However, the if statement outputs same data everytime, even if the answer is correct. Not very dynamic.
TheAnswer outputs the "fraga" variable correctly, so it cannot be a variable issue?
here's my code:
fraga = inputAnswer
if (fraga== "diskmaskin") {
svar = "rätt." ;
} else {
svar = "fel." ;
}
theAnswer = "Ditt svar " + fraga + " är " + svar
View Replies !
View Related
Help With A Simple Conditional Statement
Horizontal scroll menu keeps falling off the stage when cursor is on right side. I really need some help!
I have attached the file and below is the code. Thank you in advance!
var myShape:Shape = new Shape()
myShape.graphics.beginFill(0x7E00E3);
myShape.graphics.drawRect(50,10,450, 100)
addChild(myShape)
menu_mc.mask=myShape
stage.addEventListener(Event.ENTER_FRAME, movemenu);
function movemenu(myevent:Event):void {
menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
if (menu_mc.x>300) {
menu_mc.x=300;
}
}
View Replies !
View Related
Simple And/Or If Statement Question
ActionScript Code:
error = false;
if (urlText.text.indexOf("*") != -1 and urlText.text.indexOf("@") != -1) {
error = true;
}
if (urlText.text.indexOf("&") != -1 and urlText.text.indexOf("!") != -1) {
error = true;
}
if (urlText.text.indexOf("^") != -1 and urlText.text.indexOf("~") != -1) {
error = true;
}
can this be grouped into one statement somehow like if (this1 and this2 or this3 and this4 or this5 and this6) {error = true;} ?
View Replies !
View Related
Some Help For A Simple Condition Statement...
Hello! I wanted some help this condition statement...
There are 2 tweens called "mc_sun" and "mc_welcome" I want to run when someone clicks on a button called "btn_home", but I don't know exactly how to write the code because I've already tried these 2 modes and noone work at all!
THANKS FOR THE HELP!!!!
Attach Code
In this one, both tweens run but I have to double click the button "btn_home" so the 2nd tween runs.
btn_home.onPress = function () {
if(mc_sun._y == 700) {
new Tween(mc_sun,"_y",Regular.easeOut,startY,startY-200,16 ,false);
}
if(mc_sun._y == 500) {
mc_welcome.play();
}
}
And in this one, where I placed the 2nd "if statement" into the 1st one, doesn't work, what can I do if I want that both tweens run when someone clicks just ONCE on the button "btn_home"??????
btn_home.onRelease = function () {
if(mc_sun._y == 700) {
new Tween(mc_sun,"_y",Regular.easeOut,startY,startY-209,16 ,false);
if(mc_sun._y == 500) {
mc_welcome.play();
}
}
}
View Replies !
View Related
Simple If Statement Problem
hello
i'm trying to create an if statement which only allows something to happen if a movieclip is at a certain frame.
for example, something like this:
function checkHitTest(event:Event) {
if (handle.hitTestObject(target_29)) and (cup.frame=2){
angle.StatusTxt.text="39°";
}
}
it's the bit after "if (handle.hitTestObject(target_29))" that i'm trying to fix. it worked before without "and (cup.frame=1)" and i know that's it's not real actionscript i've written but it's just to explain what i think i'm sort of after. so basically i want "StatusTxt" to show the angle 39° if movieclip "handle" is over movieclip "target_29" AND ONLY if movieclip "cup" is at frame 2.
I hope this makes sense - any help is greatly appreciated.
View Replies !
View Related
Simple Timer IF Statement
I'm building a continous move in flash, and i'm displaying some text and images and want to hold the timeline for about 20 seconds and then resume play again. I'm trying to write a simple timer in AS to keep from having to create 10000 frame long movie clips. Here's what I have so far:
Quote:
stop();
this.onEnterFrame {
time = getTimer();
if (time == 20) {
play();
}
}
Unfortunately, this isn't working for me, and i'm unsure why. I suspect two things, A: my "time" var takes only a snapshot value of the timer and not a continous value, so the timer never reaches the value of 20. Or, B: I have somesort of syntax wrong and the if never gets a chance to load. This seems like a relitively simple task, and i'm hoping one of you guys can shed some light.
Thanks!
--Isis.
View Replies !
View Related
Simple If Statement Movement
So I have been on hiatus from coding flash for like a year or more. Trying to remember just simple stuff is hard.
What am I doing wrong here. This is linking to a movieClip.
Code:
onClipEvent(load){
_root._x=200;
this._x=0;
this._y=200;
speed=3;
}
onClipEvent(enterFrame){
this._x-=speed;
if(this._x>0){
this._x+=speed;
}
}
View Replies !
View Related
IF Statement Not Working. Seems Simple....
Hi
I'm building a Flash app with Flash and mProjector, but this is code related, and not caused by mProjector. (90% sure )
Anyway, my App is setup like this so far:
1. Open app, form appears. (works)
2. User fills out form, clicks on a button to save form results to XML file on local Hard Drive. Checkboxes are present.
A listener object sits in the background and updates a Text field with the checkboxes status.
The Text fields value is written to the XML file. (works)
3. User presses a button to clear form fields. (works)
4. User clicks open document, navigates to saved XML file and opens it. (works)
5. XML is loaded into Flash. Form fields are filled out. (works)
6. The two Checkboxes, based on two If Statements and the contents of the XML file, are told to be selected, or unselected. (Doesn't work)
Heres the code for the IF Statements:
Code:
if (data_xml.firstChild.childNodes[3].firstChild == "1") {
check_email.selected = true;
} else if (data_xml.firstChild.childNodes[3].firstChild == "0") {
check_email.selected = false;
}
if (data_xml.firstChild.childNodes[4].firstChild = "yes") {
check_fax.selected = true;
} else if (data_xml.firstChild.childNodes[4].firstChild = "no") {
check_fax.selected = false;
}
A **Trace of:
Code:
"data_xml.firstChild.childNodes[3].firstChild = " + data_xml.firstChild.childNodes[3].firstChild;
Produces: data_xml.firstChild.childNodes[3].firstChild = 1
** Not real trace. Flashes built-in tracer is out of reach once the Swf is compiled into a mProjector app, and I couldn't get mProjectors Traceviewer to work for me, so I'm sending my trace commands to a dynamic text field. Seems to work.
Which confuses me, the Value is obviously "1" the xml file says so, the app says so once its imported. But the If Statement doesn't care.
If I use "=" in the IF statement, the checkbox is told to be selected, no matter what the loaded XML file says.
If I use "==" in the IF statement, then the checkbox is told to be unselected no matter what the XML file says. (Or is just unresponsive in general. I:E not unselecting it if it was selected on XML load)
Soooo..... What kind of mindlessly simple thing am i missing here?
I really didn't expect bugs from this. Bugs yes, but not from this bit of code.
Since all I have to do is change the code back and forth between "=" and "==" to get the checkboxes to change behavior, I'm positive the problem doesn't lie in something like variable or instance names.
I get no errors when I check the code in Flash, and I can't find any loose bits of code or typos that could be the problem.
Any suggestions?
Thanks
- Lem
View Replies !
View Related
Simple Timer IF Statement
I'm building a continous move in flash, and i'm displaying some text and images and want to hold the timeline for about 20 seconds and then resume play again. I'm trying to write a simple timer in AS to keep from having to create 10000 frame long movie clips. Here's what I have so far:
Quote:
stop();
this.onEnterFrame {
time = getTimer();
if (time == 20) {
play();
}
}
Unfortunately, this isn't working for me, and i'm unsure why. I suspect two things, A: my "time" var takes only a snapshot value of the timer and not a continous value, so the timer never reaches the value of 20. Or, B: I have somesort of syntax wrong and the if never gets a chance to load. This seems like a relitively simple task, and i'm hoping one of you guys can shed some light.
Thanks!
--Isis.
View Replies !
View Related
Simple Question About An If Statement
I am trying to have a certain moveclip turn invisible .....based on the x coordinate of another movieclip.
So, if the one MC 's x value is less then something, I want this other one to go invisible.
I'm trying this....
if (this.strip._x ==197.6) {this.mens.left._visible = false
}
But it just doesn't want to work. I've tried < 200 etc..... It doesn't seem to pick up the x value of the 'strip' movieclip.
Help? Thanks.
View Replies !
View Related
Simple If Statement - Driving Me Crazy
Can someone tell me the correct syntax - it keeps on asking me to toss in brackets, when I do, it tells me they're unexpected. I still haven't figured it out. I'm trying to make a button that cand do more than one thing depending on what it did the last time it was pressed.
on (release) {(If _root.p==0){
stopAll(_level0);
_root.p=1;
}
else if (_root.p==1){
startAll(_level0);
_root.p=0;
}
)
Thanks
View Replies !
View Related
Simple Loadmovie With If Statement Problem
This is probably an easy question, but it's from an Actionscript beginner
I'll keep it short:
Each button in my menu has this:
on (press) {
tellTarget ("_root.black") {
gotoAndPlay(2);
}
mctoplay = home;
}
So when you click it, a movie clip (named black) will play, which is basically just a big black box which fades in so there's a nice transition between pages.
Each button sets a different mctoplay - eg. the about page is mctoplay = about and so on for each page.
When the 'black' movieclip comes to it's last frame I have:
if (mctoplay==home) {_root.frame.loadMovie("home.swf", 0);
}
else if (mctoplay==about) {_root.frame.loadMovie("about.swf", 0);
}
else if (mctoplay==contact) {_root.frame.loadMovie("contact.swf", 0);
}
What happens is the first if statement seems to apply no matter what mctoplay is current set to. Can anyone help? All I really want to do is load some external movies within a frame in
my main movie, but have a movieclip play just before this happens but after the user has clicked the button to load it...
Thanks in advance.
View Replies !
View Related
Simple IF Statement Doesn't Work?
Hi Ive got two variables "message" and "name" and bot of them has to be filled in before I send the email. I use the following
if (name == "" | message== "") {
do nothing;
} else { process data; }
why doesn't this work?
Ive also tried using the OR like || but still nothing?
pls help
View Replies !
View Related
Simple If Statement Checking BytesLoaded
Trying to load external thumbs into seperate movieclips incremantaly. I only need 10 thumbs so I dont need anything really complicated. Been trying something like this.
code:
onClipEvent(load){
this._visible=false;
this.thumbclip.loadMovie("thumb1.jpg");
}
onClipEvent(enterFrame){
if(this.thumbclip.getBytesLoaded==this.thumbclip.g etBytesTotal){
this._visible=true
_parent.nextFrame();
delete this.onEnterFrame
}else{_parent.gotoAndStop(15);
}
Then on the next frame have another MC with the same actions except thumb2 gets loaded.
Problem is when _parent plays to the next frame, the onClipEvent gets fired again and wipes out the thumb.jpg. If I take out _parent.nextFrame it all works, but then they all show at once.
Also, when tracing delete this.onEnterFrame, it's not deleting, it keeps looping my trace.
View Replies !
View Related
|