ActionScript 2.0 :: Simple If Statement Won't Work?
Feb 18, 2006
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");[code].....
I am attempting to create one function to respond to multiple button clicks. I have a simple if statement in my onBtnClick function that does not work. Just need the button that is in that variable to go to frame 1. Trace statements are working inside the statement so I the if statement runs correctly?
I'm trying to check to see if an object exists by using a simple if statement.
if (object.name) { //Do this }
However, if the object doesn't exist, I get this error, "Error #1010: A term is undefined and has no properties" - which I understand is because the object doesn't exist. Is there a better way to check to see if an object exists?
i cant seem to get a simple if/then statement working with an input text. Here is my AS
[AS] on (release) { password = inputName if (password == "test") {
[Code].....
For some reason when i type in test in the movieclip inputName it still sends me to ign.com. Everything is in the same frame and i just cant get it working.
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:
stop(); this.onEnterFrame { time = getTimer(); if (time == 20) { play(); }}
Unfortunately, this isn't working for me, and 'm unsure why. I suspect two things, A: my "time" var takes only a snapshot value of the timer and not a continuous 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.
have a very common function i use in educational quizes that self rate the user depending on their score (resulting from answering multiple choice questions). So I have set up a variable called score no trouble...but when i implement my trust "if else" heuristic from AS2...i get all these errors and my flash file does not work.
stop(); if (score <= 5){ endMsg.gotoAndStop("score1");} else if (score > 6 and score <= 11){ endMsg.gotoAndStop("score2");} else { endMsg.gotoAndStop("score3");}
im trying to make a website based on a tutorial. when a certain button is clicked a selected page will load when the previuos page plays the OUT:label and hits the end label which are situated on the every pages mc timeline. Tyhe problem is that the function doesent work
the function is like this
Code: Select all kontakt_btn.addEventListener(MouseEvent.CLICK, newPage); function newPage(e:MouseEvent):void
I am executing a hittest when a chicken meets a crocodile; the chicken is afraid for the crocodile and turns back flying up in the air and back on the ground. In fact most of it works, allthough I can't get the wings to stop fluttering. As soon as the chicken returns on the ground, this must happen.This is the piece of code where it is about: (the function winger() is called once at the hittest)
[flash=]function winger() { var counter:int=0;[code].......
without the counter it works. changing it into an if-statement with the counter af the 2nd tweener, doens't work either.
I'm doing a simple array test...I thought I could have values in an array and then run it through a loop and have a IF this value equals "x" do whatever, ELSE do this.
I have the value on a button and it doesn't work.The loop runs but the IF ELSE statement doesn't do what I THOUGHT it should do. It runs every value through the script as if the IF ELSE statement doesn't matter. Am I missing something?Here's the flash code (see below):
var myArr:Array = new Array; myArr = ["red", "green","blue"]; function checkArr (checkTest){[code].....
I want to stop scrolling once emptyScroller._y = 0, so the content doesnt get scrolled right off the edge of the browser. I want to say something like: if emptyScroller._y < 0... "stop scrolling upwards, but allow the user to still scroll downwards until y = someVar"
I have written a nested if statement that refuses to work properly. My fla file consists of the main timeline and a movieclip. The problem lies in the pwrbtn function. I need the pwrcomp Boolean to prevent the call to firstpage() from happening more than one time. However when I test it keeps cycling so my traces are frame2, true, frame2, true, so on and so forth. Have I just made some small mistake that Im not seeing?
I recently built a preloader using the MovieClipLoader object. I used the following events: OnLoadComplete, OnLoadProgress and onLoadStart. I registered my listeners etc and then I decided I wanted to get a bit fancy. So I decided that within the onLoadProgress I would add an"if" statement, this if statement would basically say if the loaded content equals 70 then animate the preloader graphic off the screen using tweening (very simple). The onLoadProgress is continuously called while the content is being loaded but it seems that it does not want to correctly execute my if condition.
Here is the code for the onLoadProgress. loadListener.onLoadProgress = function (target:MovieClip, bytesLoaded:Number, bytesTotal:Number) { trace("onLoadProgress"); txtLoaded.text = String (Math.floor (bytesLoaded / bytesTotal * 100)) + "% loaded"; mcProgress._xscale = bytesLoaded / bytesTotal * 100; // address the bar [Code] .....
I am just testing out how to place a button to go to a scene.I have 2 scenes named, one and two and 2 buttons...One on each scene to get them back to the other scene.The instance names on the buttons are scen1_btn and scene2_btn.My Functions are just called scene1 and scene 2.The code I have below is what I wrote, and I thought would work, but isn't.[code]
I have this little slideshow, it is for practise for my students. It always worked well in as 2.0, 5 slides, and two buttons: back and next.The script in2.0 has: prevFrame and nextFrame in the code and for the exceptions in frame 1, and frame 5 we made a new frame 1 in the actions layer, and coded the back button, gotoAndStop(5); and a new frame 5, and coded the next button: gotoAndStop(1); Works.
Now I put the thing over tot as 3.0: And I can not get it to work properly....the buttons work, but when I am on frame 5, and go back to 4, it will go no further than 4, evenso when I go back to frame 1 from 5, I can not go further up than frame 1.
I'm not familiar with AS3 at all.I'm working on a simple 2 minute presentation. For testing purposes, I have a layer named "label" that I am using to set a label called "test" (currently it's on frame 1445)I'm trying to put an action in the timeline, frame 1, that will cause the play head to automatically jump to the "test" label so as I build the presentation and test it, I don't have to sit through the entire thing just to see if my latest animations are working as expected. I'd like to move this "test" label down the timeline as I continue to build new parts of the presentation. I would expect this code to jump the play-head to where ever I put that "test" label..Instead, it either doesn't work at all, or it jumps to some other random spot around frame 160. NO other labels are being used in this presentation (I'm using the FlashEff component plugin for effects, in case that info is necessary)
I'm an AS2 guy finally being drug into the AS3 world and finding it difficult.I just want to make a simple rollover effect.[code]I noticed the first line in the code, do I have to import something? Either way my text in the button doesn't move when I rollover. It moves upon render but then it stops.URl...
I have a scene for the title screen and a scene for the game itself. On the title screen i have a start button, that when clicked it is supposed to go to the game scene; but for some reason this wont work.
actions for startclick (start) on(release){ gotoAndPlay("Game", 1); }
I am having trouble getting a hitTest to work. My two MCs are lines, one horizontal, one slanted. When the horizontal line gets within the "bounding box" of the slanted line the hitTest is true, but it's not touching the slanted line yet. I saw that the shapeFlag property comes into play here, but only when using coordinates... I'm not sure how to apply it to these two lines. I want the hitTest to be true only when the lines actually touch. I have attached a simple FLA of the problem.
What I'm Trying To Do: Modify the y coordinate of a MovieClip on the stage from an external .as File, simple as that.If someone could tell me why its not working and how I can go about fixing it without modifying the existing class structure (ChildOfMain must subclass MainClass).
Download Source Files 6 kB
For those of you who don't want to download the source files (I thought it would make it easier if you could handle it yourself)
Document Class For Project: Main Class Objects In Project Library platform (movieclip) subjectMovieClip (movieclip)
I'm trying to get a simple random SWF loader to work. and I'm close...I have 10 movies saved as movie1.swf to movie10.swf saved in a directory.For my index file (swf file that will load one of the 10 movies randomly) I have one single frame with this in the actions:
stop(); var movieArray : Array = ['movie1','movie2','movie3','movie4','movie5','movi e6','movie7','movie8','movie9','movie10']; var loader : Loader = new Loader(); loader.load(new URLRequest(movieArray[Math.round( Math.random() * movieArray.length-1 )] + '.swf')); addChild(loader);
For the most part it works. But every now and then the screen comes up empty on a refresh. My guess is the math might be slightly off and is calling a file that is not there.
I boggled with this simple script.This script is on the MC. Everything works except the last onRelase function which just won't go to "disable". If I change "disable" to "fadein" it will work. Please see the attached timeline pic to get better idea and please do let me know what I'm doing wrong.[code]
I do not know action script, and, have created a button in flash that pops up information when you rollover the button.The button works fine, but, the entire area - where the information pops - is also poping up when I rollover that area.