Button Instance And Conditional Statements
I am trying to create an _x position sliding nav.
My button instances are.. left_btn and right_btn.
the movie clip they are navigating has 13 buttons in it that i want to show up inbetween the two buttons (right and left )...instance named... btn_mc
my script is below.
this script is working fine untill i get to the _x value where the button is to be invisible ( you would be at the end of the nav and therefore making the _x value less would make the btn_mc go way off stage to the left).
as you get to the third stage ( where _x<= 599) the right button is not found...this is correct....however when i hit the left button (to decrease the _x value) the right button does not show up again.
so basically i need... left button to be invisible at first position..then show at second and third position
alternatley the right button should be visible at first and second position and not at third
suggestions?
right_btn.onRelease = function(){ btn_mc._x -=347 if(btn_mc._x <= -599){ right_btn._visible=false; }else{ right_btn._visible = true; } }
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 10-28-2008, 08:23 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Conditional Statements On Button States?
OK,
I have a navbar, each button mc has an up, over, release state which also calls a mouse over event - follow mc -- to have a line follow the mouse to each button (see FLA)
I need the release state of each button to remain -- not change once the HTML is loaded for each button, and when RollOut happens.
I guess I need an if else statement?? Help!
this is what i have on each button:
Code:
on (rollOver) {
_root.follow.A = "projects";
this.gotoAndStop("over");
}
on (rollOut) {
this.gotoAndStop("up");
}
on (release) {
this.gotoAndStop("release");
}
Also - after Release - or Rollout - the instance of "follow" mc (line) needs to remain in place - so it doesn't follow mouse again - once a button is selected - Another, if else statement!? Not sure!?
check out the FLA -- please - see how I can add this functionality to the buttons!
thanks a bunch!
d-R
Conditional Statements
Hi all-
I am trying to make what i hope is a very simple game. There will be 4 different people and 4 different colors. The "player" has to match the person with the right color by clicking on the person button and then clicking on the color button. If the match is correct a small movie clip plays.
I just need a little push in the right direction. Is this an "if else" situation? I have just been sitting and staring at my screen - i do not have much experience with conditional statements.
thanks in advance.
Shawn
Help With Conditional Statements
I just downloaded the Flash 8 demo from Macromedia and read through a bunch of tutorials. I am now making a project that starts with an animated menu with three choices. I have the menu as a separate scene. After you choose one of the menu options, Flash jumps to another scene in which the menu fades away. I created on scene for this so I wouldn'y have to do it three times for each button. All the aforementioned stuff works fine. However, after I click a menu button, I want Flash to go to a resoective scene. So basically i have the menu scene. after clicking on a button flash goes to a fademenu scene. afterwards, depending on which buttons were clicked, flash should go to one of three other scenes. I expect this to work by having Flash set a variable, say, sceneselect to 1 if the first menu button was clicked, to 2 if the second one was clicked, etc. Flash would set the variable right after the click. then, i would add actionscript at the end of the fadeout scene that would check for the value of variable sceneselect, and then gotoandplay a certain scene. is that how it would work? and if someone could like guide me through this I would very appreciate it.
thanks
[MX] Conditional Statements For Mc's
hello all who are viewing this.
Ive posted a few questions on this forum but tend not to get any replies I dont know if my enquiries are too simple to reply to but again i will ask for help.
I have created some characters for a menu.
which will play with on (rollOver) with an invisible button.
I have attached a file for all to see.
My problem is that I need to write a conditional statement for the invisible button. Whats supposed to happen is that the Mc, (which is a simple alpha tween) plays and when certain frames are reached triggers other Mc's to play.
But I want to write a conditional statement to stop when the user rolls over the invisible button a second time the Mc going back to the beginning and starting again (check the attachment).
I know how to do this with a button when loading MP3's (boolean true, false)
but not with a Mc. I know this must be simple but cant get my head around it. All the examples Ive seen are usually with Numerical values such as a quiz.
anybody out there can help me?????
so that when the user rolls over the invisible button the affected movie clip only plays once instead of going back to the beginning
Conditional Statements
I'm using flash 8 to put together a website. I have links at the top of my page. When a user clicks on a gallery an animation runs in the main page and then it loads an external swf file. My problem is, I don't always want it to play that animation. Kinda hard to explain, I'll provide a link. I was wondering if I would have to write a conditional script to do this or is there another way.
here is the link.
http://www.litemediadesign.com/John
if you click on "bio" it works fine and then click back to "home" it works fine. But, if you click on a gallery (japanalia) then click on "bio" it plays an unnecessary animation (obviously because I told it to). Help me out!
My main Flash file is also available at
http://www.litemediadesign.com/John/index5.fla
Thanks!
[CS3] {as2} - Conditional Statements
Hello Flashers !
I have a web page with 6 buttons on it
making a a movie clip disappear on one click
and re -appear on the second click.
the problem is each of the movie clips
has a button on them that sends the user to a different URL
but if all the clips are on - well than all the buttons are on,
I am trying to write a conditional statement that would
enable the buttons only when their movie clip is on
and all the rest are off.
well code speaks louder than words so...
this is the script for one of the buttons/movie clips
essential they are all the same just the instance name changes
lineMc_james._alpha=0
jamesBt.onRelease = function() {
if(jamesMc._alpha<100) {
jamesMc._alpha= 100;
lineMc_james._alpha= 0;
} else {
jamesMc._alpha= 0;
lineMc_james._alpha= 100;
}
}
the script referring to to the button on jamesMc is:
ja1webBt.onRelease = function () {
getURL ("http://www.victorenyc.com","_blank")
}
any ideas on how to enter the statement in this line ?
Thanks for your patience )
Conditional Statements For FLV
Hello all,
Yes, I am a complete newbie....but like a dog with a bone. I have a button that stops my flv and goes to another frame. But, if there is no video playing at the time I press that button, I get the following error:
VideoError: 1000: Unable to make connection to server or to find FLV on server
at fl.video::VideoPlayer/stop()
at fl.video::FLVPlayback/stop()
at index_fla::MainTimeline/stopVid()
I guess I need to write a "if flv not playing, do this" sort of deal. Help, Please.
Gwendolyn
Conditional Statements
Hello.
I love the if and else statements, I use it all the time. However it only lets me (with my current puny knowledge) do 'if this is this, do this, otherwise this". Is there a way to add more else's, or more ifs? So if a variable was set to one it would do this, set to two do this, so on and so fourth to ten for example?
I'm trying to fire a random tween on mouse over, I thought about using arrays but can't get it to work.
Thanks, A.
Conditional Statements Help
I just downloaded the Flash 8 demo from Macromedia and read through a bunch of tutorials. I am now making a project that starts with an animated menu with three choices. I have the menu as a separate scene. After you choose one of the menu options, Flash jumps to another scene in which the menu fades away. I created on scene for this so I wouldn'y have to do it three times for each button. All the aforementioned stuff works fine. However, after I click a menu button, I want Flash to go to a resoective scene. So basically i have the menu scene. after clicking on a button flash goes to a fademenu scene. afterwards, depending on which buttons were clicked, flash should go to one of three other scenes. I expect this to work by having Flash set a variable, say, sceneselect to 1 if the first menu button was clicked, to 2 if the second one was clicked, etc. Flash would set the variable right after the click. then, i would add actionscript at the end of the fadeout scene that would check for the value of variable sceneselect, and then gotoandplay a certain scene. is that how it would work? and if someone could like guide me through this I would very appreciate it.
thanks
Help With Conditional, If, Else Statements... I Think.
Hey Guys,
I am not a programmer, so have no idea how to set this up. Any help would be appreciated.
Take a look at the link before you read on.
http://www.ednacional.com/port/SBliss.html
Basically there are 3 photos, 2 set to 0% alpha and 1 set to 100% and each have a mini page icon which changes the photo that is visible. i when the side bar opens i want it to find out which photo is visible and have the appropriate icon on rollover state (grow) so you always know which of the photos are visible.
DOWNLOAD MY FLA
Thanks for any help or suggestions!
OnClipEvent & Conditional Statements
I am having problems with the syntax of the set variable statements inside the conditional statements at the bottom of this. It is only returing the last value. Can anyone help me determine why? Everything else is working fine including the _visibility properties.
The code for a unversal preloader I am working on. This is based on FlashGuru's attach sound preloader. (in case it looks alarmingly familiar to you) The code is attached to the preloader as onClipEvent.
// anything you load into _level10 toggles the visibility the loader to true starting the preloader over again.
onClipEvent (enterFrame) {
// create a percentage: divide BytesLoaded by BytesTotal.
// move the decimal place by multiplying times 100.
percentloaded = Math.floor((_level10.getBytesLoaded()/_level10.getBytesTotal())*100);
// "PercentDisplay" is the name of the text field.
PercentDisplay = percentloaded;
// setting the _xscale of LoadIndicator(the bar) will show
// the progress lengthening the bar as the percentage increases.
setProperty ("LoadIndicator", _xscale, PercentDisplay);
// conditional statements checking loading status.
if (PercentDisplay == 100) {
this._visible = false;
set (_root.loading, "file complete");
} else if (PercentDisplay<100) {
this._visible = true;
set (_root.loading, "loading file");
} else if (PercentDisplay == NaN) {
set (_root.loading, "connecting");
this._visible = false;
}
}
Thanks in advance for your help.
-Rob
[Edited by LuminaryMedia on 08-21-2001 at 07:13 PM]
Simple Conditional Statements
In 4 -
I would like to create a simple conditional statement -
something like:
George Washington was the
1)First President
2)Second President
3)Inventor of the Telephone
Please enter the correct answer (form)
How do I do that?
Conditional Statements For Arrays
I'm trying to call movieclips depending on the data in the array, but I can't seem to get the conditional statements right, so that it works. Can anyone help?
var outfitArray:Array = new Array;
//Set function parameters
function createArray():Void {
outfitArray = new Array();
outfitArray.push(headGroup.selection.data);
outfitArray.push(topGroup.selection.data);
outfitArray.push(bottomGroup.selection.data);
outfitArray.push(accessoryGroup.selection.data);
}
function dressBarbie():Void {
if (outfitArray == (head1, top1, bottom1, accessory1)) {
dressUp.gotoAndStop(2);
barbieBody._visible = false;
}else if (outfitArray == (head1, top1, bottom1, accessory2)) {
dressUp.gotoAndStop(3);
barbieBody._visible = false;
}else if (outfitArray == (head1, top2, bottom1, accessory1)) {
dressUp.gotoAndStop(4);
barbieBody._visible == false;
}else errorField.text == ("Choose one from each category.");
}
Conditional Statements For Loops
I'm a newbie, and while I've learned quite a bit over the last several weeks, I'm still finding myself floundering in simple code.
Any help with the following problem is greatly appreciated. Thank you for your time.
The problem:
Using ActionScript in frame 1 of the main timeline , I've attached five small "circle buttons" (one movie clip looped 5 times using the "for (i=0; i<5; i++)" loop). The five "circle buttons" appear on the Stage when the movie starts. I'll refer to them and "circle1", "circle2", etc.
Each "circle button" changes color when clicked, independently of the others, and that's good. (Each button clicks through 5 colors).
The bad part:
I also have five large "squares" (movie clips) on Stage. I'll refer to them as "square1", "square2", etc.
I would like "square1" to simultaneously change colors as "circle1" is clicked; "square2" to simultaneously change colors as "circle2" is clicked, and so on.
Each square is equipped to do so. The problem is activating each square with the corresponding circle.
I've been trying to use conditional statements. When I use "if", any one of the five "circle buttons" activate all five squares.
When I use "if...else if" statements, only the first square is activated, and any of the five "circle buttons" will activate the first square.
I realize I could create five different movie clips for the circle button (vs. the loop) and this would solve this particular problem, but because of other interactivity in the script, I need to keep the "circle button" loop as is.
I've been working on this for days and I can't figure out what the problem is.
Here are the two button scripts I'm referring to, and it is attached to the "circle button" movie clip.
// on (press) changes the color of the circle button,
// each one independently of the other, as it should
on (press) {
f = _currentframe+1;
if (f>6) {
f = 1;
}
gotoAndStop (f);
}
USING THE "IF "(ONLY)
// on (release) attempts to target the corresponding square (only)
// using the 'if' here, any of the five circles will activate
// all of the five squares simultaneously
on (release) {
if ([movieclip:_level0.circle-0]) {
_root.square0.gotoAndStop (g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
} if ([movieclip:_level0.circle-1]) {
_root.square1.gotoAndStop(g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
} if ([movieclip:_level0.circle-2]) {
_root.square2.gotoAndStop(g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
}
. . .ETC.
}
}
USING THE "IF...ELSE/IF"
// on (release) attempts to target the corresponding square (only)
// using the 'if...else if' here, only the first square is activated,
// and any one of the five circle buttons will activate it
on (release) {
if ([movieclip:_level0.circle-0]) {
_root.square0.gotoAndStop(g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
} else if ([movieclip:_level0.circle-1]) {
_root.square1.gotoAndStop(g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
} else if ([movieclip:_level0.circle-2]) {
_root.square2.gotoAndStop(g=_currentframe);
if (g>6) {
g = 1;
}
gotoAndStop (g);
}
. . .ETC.
}
}
Conditional Statements For Arrays
I'm trying to call movieclips depending on the data in the array, but I can't seem to get the conditional statements right, so that it works. Can anyone help?
var outfitArray:Array = new Array;
//Set function parameters
function createArray():Void {
outfitArray = new Array();
outfitArray.push(headGroup.selection.data);
outfitArray.push(topGroup.selection.data);
outfitArray.push(bottomGroup.selection.data);
outfitArray.push(accessoryGroup.selection.data);
}
function dressBarbie():Void {
if (outfitArray == (head1, top1, bottom1, accessory1)) {
dressUp.gotoAndStop(2);
barbieBody._visible = false;
}else if (outfitArray == (head1, top1, bottom1, accessory2)) {
dressUp.gotoAndStop(3);
barbieBody._visible = false;
}else if (outfitArray == (head1, top2, bottom1, accessory1)) {
dressUp.gotoAndStop(4);
barbieBody._visible == false;
}else errorField.text == ("Choose one from each category.");
}
Conditional Text Using If Else Statements
Hi
I am trying to create a dynamic text box that tells the user if they have passed or failed a quiz.
CODEif (QuizTrack.percent_format = '<70') {
resultsText.text = "congratulations you have passed";}
else {
resultsText.text = "you have failed to score 70% or higher, please try again";
}
Conditional Statements W/ Buttons
hey folks,
I'm relatively new to the scripting side of Flash, so please forgive me if this is a no-brainer.
I want to put a conditional behavior on a set of buttons, basically so that each button will do this:
on (rollover) {load movie x}
if on (release) {load movie y}
else if on (rollout) {load movie z}
I have no problem with the syntax of loading the movie, but using button events in this conditional statement is the problem. Perhaps I should create a listener?
Any help would be much appreciated.
Devin
Conditional Statements To Load Images
I am working on a project where I want the user to type in a word in an input text field and then hit a button to make that word using sign language graphics I created. So basically you hit the button and it calls certain imgs depending on the letters you type. I am confused on how exactly to word the actionscript. I know I need to declare the letters a variable and use conditonal statements to basically say if the user types "a" then load "a.jpg". How can I make it so that the user can type in any kind of word and the images show up and it recognize specifc letters. Can someone help me make sense of what I am trying to do.
Thank you.
Sam
Conditional Statements Being Ignored When Function Is Called
I've been struggling with this for a while, and it's probably something stupid that I'm missing, but hopefully someone can help me out. I have a series of buttons that set the value of "loadcontent," for instance:
Code:
on(release) {
_root.loadcontent = A1;
}
Then I have a movieclip that, when it's position gets to a certain point, calls a function:
Code:
onClipEvent (enterFrame){
_y -= (_y-15)/4;
if (this._y <= 16){
_parent._parent._parent.attachcontent();
}
}
The function is meant to attach the movie that corresponds with the button pushed:
Code:
function attachcontent(){
//loads Subsection A content
if (loadcontent == A1){
content.attachMovie ("A1", content, content.getNextHighestDepth());
}
else if (loadcontent == A2){
content.attachMovie ("A2", content, content.getNextHighestDepth());
}
else if (loadcontent == A3){
content.attachMovie ("A3", content, content.getNextHighestDepth());
}
else if (loadcontent == A4){
content.attachMovie ("A4", content, content.getNextHighestDepth());
}
else if (loadcontent == A5){
content.attachMovie ("A5", content, content.getNextHighestDepth());
}
else if (loadcontent == A6){
content.attachMovie ("A6", content, content.getNextHighestDepth());
}
else if (loadcontent == A7){
content.attachMovie ("A7", content, content.getNextHighestDepth());
}
else {
content.attachMovie ("contentmovie", content, content.getNextHighestDepth());
}
}
The problem is, it seems the conditional statements are being ignored completely, and it just attaches "A1," or whatever is called in the very first attachMovie. So no matter what button is pushed, it just attaches the A1 movie clip. I can change the value after the == to anything, "WTF" for instance, and it still loads A1. Like I said, it's probably something very simple I'm missing, or I'm just going about it all wrong.
I think I've included everything that's going on. If there's anything missing, please let me know and I'll try to post it. Thanks in advance for your help...
[CS3] Conditional Statements In AS3.0 Moving To Different Frames
So I'm new to AS/Flash, but understand the concepts since I'm a web developer. We've recently had our flash developer leave and I'm stuck with finishing his project. The project is a SWF file that will be turned into a screen saver that is displaying a RSS feed that I've already got setup. We are sorting the feed items based on their priority, High, Med. and Low. What I'm trying to get to work is our sorting function to switch to a different frame so that it will display that frames contents. I've got a two part question.
1.) Do I need the text fields layer in all three frames as key frames with the AS layer covering all three frames?
2.) The only thing I really need done is to put a different background image on my bg layer, so I've got three key frames for this layer with three different images.
So what will happen is that when it's a "high" priority, it goes so say Frame 3, when it's low it stays at frame 1, and then "medium" it goes to Frame 2.
Here's the sortAlert function code I've got so far, I just need to know how I go about adding the switching of the frames.
Code:
function sortAlert() {
trace("=== Start Sorting Alert ===");
//init
emgAlert = <body> </body>;
nomalAlert = <body> </body>;
for (var i:int = 0; i< rssLength; i++) {
if (rssAlert.channel.item[i].priority == "HIGH") {
trace(">>> Sorting the "+i+"th item as HIGH");
//count the notes in emgAlert
countEmgAlert = emgAlert.item.length();
trace("countEmgAlert: "+countEmgAlert);
if (countEmgAlert == 0) {
emgAlert.appendChild(rssAlert.channel.item[i]);
//trace("[emgAlert]:
"+emgAlert)
trace(">>> Sorted the "+i+"th item as HIGH***
");
}
else {
//conpare the date and insert the current node to the place that is smaller than the next node
for (var j:int=0; j<=countEmgAlert; j++) {
if (transformdate(emgAlert.item[j].pubdate) >= transformdate( rssAlert.channel.item[i].pubdate)) {
emgAlert.insertChildBefore(emgAlert.item[j],rssAlert.channel.item[i]);
trace(">>> Sorted the "+i+"th item as HIGH***
");
break;
}
else if (j == countEmgAlert-1) {
emgAlert.appendChild(rssAlert.channel.item[i]);
break;
}
}
}
}
else if (rssAlert.channel.item[i].priority != "HIGH") {
trace(">>> Sorting the "+i+"th item as LOW");
//count the notes in nomalAlert
countNomalAlert = nomalAlert.item.length();
if (countNomalAlert == 0) {
nomalAlert.appendChild(rssAlert.channel.item[i]);
trace(">>> Sorted the "+i+"th item as LOW
");
}
else {
//conpare the date and insert the current node to the place that is smaller than the next node
for (var k:int=0; k<countNomalAlert; k++) {
if (transformdate(nomalAlert.item[k].pubdate) >= transformdate( rssAlert.channel.item[i].pubdate) ) {
nomalAlert.insertChildBefore(nomalAlert.item[k],rssAlert.channel.item[i]);
trace(">>> Sorted the "+i+"th item as LOW ***
");
break;
}
else if (j == countNomalAlert-1) {
nomalAlert.appendChild(rssAlert.channel.item[i]);
break;
}
}
}
}
}
//trace("[nomalAlert]:
"+nomalAlert+"
")
//trace("[emgAlert]:
"+emgAlert+"
")
countNomalAlert = nomalAlert.item.length();
countEmgAlert = emgAlert.item.length();
trace("<<< END Sorting Alert >>>
");
}
Any help would be appreciated!! Thanks in advance!
Conditional Statements With Frame Labels
Hello! I'm familiar with If statements in PHP but I'm not quite sure how to write what I want in this situation.
I have an MC 'submenu' that is its instance name too. In that MC are frame labels that animate it going down to a stop, and going up to a stop, it is an animated dropdown submenu.
Now only two buttons require the MC to drop down. I wanted to make an if statement for the buttons that don't need the submenu checking:
Code:
on(Release){
if (_root.submenu(framelabel =="down"){
_root.submenu.gotoAndPlay("up");
} else {
_root.submenu.gotoAndStop("start");
}
}
And on the two buttons where if the submenu is down, STAY down instead of repeating the dropping down animation I could write
Code:
on(Release){
if (_root.submenu(framelabel =="down"){
_root.submenu.gotoAndStop("end");
} else {
_root.submenu.gotoAndPlay("start");
}
}
This is all I want to accomplish here if you guru's could help me out.. I think I'm really close but missing something.
Conditional Statements With Math.random
I came across a tutorial (http://www.actionscript.org/resource...dom/Page1.html) on actionscript.org with a couple of my students. (I teach scientific visualization at a public high school in nc.) We use flash to create interactive maps and a few educational games/movies, but my kiddos have surpased my actionscript knowledge on this one. The tutorial was great, but we would like to use the math.random function with a gotoAndStop function for the controls on a monopoly style board game for social studies education, and we keep getting scripting errors. We are using flash 8 professional and the script below to send the person clicking a button to particular frame (as per a coin toss or dice). Thanks in advance for the help, sorry to be bothersome.
Christian Wilson
on (release)
{Math.round(Math.random());}
{if (i=0) {
gotoAndStop(2);
}
}
{if (i =1)
{
gotoAndStop(3)
}
}
Removing Children With Conditional Statements Help
I have a movie that need to remove a child in order to load another. This will be done through the use of a button. Works fine, yet I need to remove other children with the same button. Example... I click the button, the child is removed and we jump to another spot on the timeline. Now I choose another section of the movie. When clicking the same button I need the to code to recognize that this is a different child and remove it. I was thinking a switch statement would be the best route, yet I am not versed enough within as3 to know for sure and what the exact syntax is. Can someone point me in the right direction?
The code below is the code used to remove child:
backTest.addEventListener(MouseEvent.CLICK, Backer);
function Backer(event:MouseEvent):void
{
gotoAndPlay("skip");
removeChild(ArchSkipLoader);
player.stop();
govplayer.stop();
}
Thanks for any available help!
Text Boxes And Conditional Statements
I have attached two flash files. In the first file there is a input text filed that asks for the password. If the password is correct go to a frame, if it is incorrect go to another frame. In this case the text box must have a variable name and I need to refer to the box as such:
on(release){
if (NameofTextBox.text =="33") {
gotoAndStop(10);
} else {
gotoAndStop(5);
}
}
In the other file I ask a question and if the text answer is correct play a movie, if it is incorrect play a different. In this case I can rever to the text box as a variable. As below:
on (release){
if (NameofTextBox=="72") {
setProperty("wronganswertwo",_alpha,0);
rewardtwo.play();
} else {
setProperty("wronganswertwo",_alpha,100);
wronganswer.play();
}
}
The first file must be an instance name for the text box and no other way. The second file can be both ways. Howcome? These file were both created on a Mac OS 10.
Any help would be appreciated.
Conditional Statements/ Fuse/ Menu HELP...
Hey all you super cool über brainie peeps
I need some help making an menu or it is the conditional statements
to make the trantsion/animation run the way i would like it to.
I am trying to show hide some content by animating a mask using fuse/zigo
it shuld have been a simpel task..but im a moron.
WELL
At first the site is just a grey background and the menu.
press any random button -->load movie-->play open animation-->show contents
button 1..(if window is already open) press-->load movie-->play close animation-->play open animation-->show contents
button 2 ..press-->load movie -->play close animation-->play open animation-->show contents
ECT.ECT
i know i cant use ZigoEngine the way my code looks below, but it is just to illustrate what i am trying to do.
you can get my fla here http://www.box.net/shared/kacgh4uypn
PHP Code:
this.portfolio_mc.onPress = function() { if (menuClosed) {ZigoEngine.removeTween(infowind_mc.masker_mc);ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1); menuClosed = false } else {ZigoEngine.removeTween(infowind_mc.masker_mc);ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1); menuClosed = true ifelse {ZigoEngine.removeTween(infowind_mc.masker_mc);ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1); menuClosed = true };};
Conditional Statements Based On Text?
soooo...
here's a question!
can you make a conditional function that says if suchnsuch a dynamic text field says "blahdidah" right now, then do this? i tried it and it didn't work for me... but i feel like it must be possible.
Removing Children With Conditional Statements Help
I have a movie that need to remove a child in order to load another. This will be done through the use of a button. Works fine, yet I need to remove other children with the same button. Example... I click the button, the child is removed and we jump to another spot on the timeline. Now I choose another section of the movie. When clicking the same button I need the to code to recognize that this is a different child and remove it. I was thinking a switch statement would be the best route, yet I am not versed enough within as3 to know for sure and what the exact syntax is. Can someone point me in the right direction?
The code below is the code used to remove child:
backTest.addEventListener(MouseEvent.CLICK, Backer);
function Backer(event:MouseEvent):void
{
gotoAndPlay("skip");
removeChild(ArchSkipLoader);
player.stop();
govplayer.stop();
}
Thanks for any available help!
GEN Quest. About Conditional/loop Statements
Hi there,
Any ideas to the following conditional/loop action question much appreciated..
As long as no onRelease takes place my_mc is playing frame 1 up to frame 28, where a frame-script then tells the playhead to go to 1 and play from there again.
But when the onRelease event is issued the playhead should continue to play from whatever position it is at at the time, but ignore the script on frame 28 as it gets there and play up to frame 41 - the end of my _mc's timeline.
I'm confused by some of the info I have read on the subject of loops, where it said that For...in, Do while, For and While are no solution for this, as they would bring Flash to a halt. So I thought of a syntax, something like:
if (this._currentframe<28 ){
this.gotoAndPlay (_currentframe+1)
else if (this._currentframe ==28 ){
this.gotoAndPlay (29)
}
}; ..... (The idea is to jump over -or bypass- the frame which holds the script to go back to frame 1, and is only a mind spin NOT PROPPER CODE!)
If there is a way to include frame28 (as opposed to having to jump over it) it would be ideal, since the animation on the timeline wouldn't suffer the loss of 1 frame, but I'd be prepared to live with that.
It's funny, as I would have thought conditional scripts to achieve things like this to be one of the 1st things to be clearly & easily explained in the MM Flash tuts (or one of the thousends online, or forums), but either it really is something so profanely easy that no example is necessary (apart from for me ) or I must be looking right passed the obvious (wouldn't be the 1st time )
Any ideas on what would be good to use here??
Section Transitions, Conditional Statements?
Hey everyone,
I'm trying to make the transitions between each section of my site to be dynamic.
My code is below and I attached the fla.
Any help would be appreciated.
Code:
import caurina.transitions.*;
var determineSection:int = 0;
btn1.addEventListener(MouseEvent.CLICK, nextSection);
btn2.addEventListener(MouseEvent.CLICK, nextSection);
btn3.addEventListener(MouseEvent.CLICK, nextSection);
btn4.addEventListener(MouseEvent.CLICK, nextSection);
function nextSection(e:MouseEvent):void
{
if (determineSection == 1)
{
Tweener.addTween(mc1, {alpha:1, x:stage.stageWidth / 2, y:stage.stageHeight / 2, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc2, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc3, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc4, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
determineSection = 1;
}
else if (determineSection == 2)
{
Tweener.addTween(mc1, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc2, {alpha:1, x:stage.stageWidth / 2, y:stage.stageHeight / 2, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc3, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc4, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
determineSection = 2;
}
else if (determineSection == 3)
{
Tweener.addTween(mc1, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc2, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc3, {alpha:1, x:stage.stageWidth / 2, y:stage.stageHeight / 2, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc4, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
determineSection = 3;
}
else (determineSection == 4)
{
Tweener.addTween(mc1, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc2, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc3, {alpha:0, x:-200, y:200, time: 1, transition:"easeoutExpo"});
Tweener.addTween(mc4, {alpha:1, x:stage.stageWidth / 2, y:stage.stageHeight / 2, time: 1, transition:"easeoutExpo"});
determineSection = 0;
}
}
btn1.buttonMode = true;
btn2.buttonMode = true;
btn3.buttonMode = true;
btn4.buttonMode = true;
Conditional Statements And Unloading Movie Clips
Hello FK!
I am having a problem with this code
Code:
import com.yahoo.astra.fl.controls.TabBar;
import fl.data.DataProvider;
var tabData:Array = [ "Border,Badges,Banners,Flags", "Holidays & Special Occasion", "Sports & Leisure", "Wedding, Prom & Religious" , "Misc. Clips" ];
var tabBar:TabBar = new TabBar();
tabBar.move(10, 10);
tabBar.dataProvider = new DataProvider( tabData );
this.addChild( tabBar );
tabBar.addEventListener(MouseEvent.CLICK , _clickHandler)
function _clickHandler(evt:MouseEvent){
if (tabBar.selectedIndex == 0){
var banner_mc:banner = new banner();
banner_mc.x = 100;
banner_mc.y = 100;
addChild(banner_mc);
}
if(tabBar.selectedIndex == 1){
if(stage.contains (banner_mc) ){
stage.removeChild(banner_mc);
}
var wedding_mc:wedding = new wedding();
wedding_mc.x = 100;
wedding_mc.y = 100;
addChild(wedding_mc);
}
}
I am trying unload banner_mc. so that wedding_mc will appear when selected index == 1 pls help.
Loading Multiple SWF In A Movieclip Using Conditional Statements
Hello all,
I'm an actionscript beginner and having some trouble figuring out how to do what I'm trying to do. Is there anyone out there who can help? I've been searching for an answer but I haven't come across anything that seems to be working.
I'm trying to load several different SWFs in a movieclip on the stage at different times using conditional statements, all dynamically through actionscript. I've never done this before so I'm not sure how to even get started. What classes do I need to import first? How do I use the Loader class? Then how do I get each SWF to run as part of a conditional statement?
Sorry for all the questions, but I'm a novice. Thanks in advance for anybody who can give a suggestion!
[F8] AS2 Conditional Statements/ZigoEngine Fuse/ Menu Trantsion HELP...
Hey all you super cool über brainie peeps
I need some help making an menu or it is the conditional statements
to make the trantsion/animation run the way i would like it to.
I am trying to show hide some content by animating a mask using fuse/zigo
it shuld have been a simpel task..but im a moron.
WELL
At first the site is just a grey background and the menu.
press any random button -->load movie-->play open animation-->show contents
button 1..(if window is already open) press-->load movie-->play close animation-->play open animation-->show contents
button 2 ..press-->load movie -->play close animation-->play open animation-->show contents
ECT.ECT
i know i cant use ZigoEngine the way my code looks below, but it is just to illustrate what i am trying to do.
you can get my fla here http://www.box.net/shared/kacgh4uypn
PHP Code:
this.portfolio_mc.onPress = function() {
if (menuClosed) {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = false
}
else {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = true
ifelse {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = true
};
};
Thanks.
ZigoEngine/menu/animation/conditional Statements/ Fuse/HELP..
Hey all you super cool über brainie peeps
I need some help making an menu or it is the conditional statements
to make the trantsion/animation run the way i would like it to.
I am trying to show hide some content by animating a mask using fuse/zigo
it shuld have been a simpel task..but im a moron.
WELL
At first the site is just a grey background and the menu.
press any random button -->load movie-->play open animation-->show contents
button 1..(if window is already open) press-->load movie-->play close animation-->play open animation-->show contents
button 2 ..press-->load movie -->play close animation-->play open animation-->show contents
ECT.ECT
i know i cant use ZigoEngine the way my code looks below, but it is just to illustrate what i am trying to do.
you can get my fla here http://www.box.net/shared/kacgh4uypn
PHP Code:
this.portfolio_mc.onPress = function() {
if (menuClosed) {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = false
}
else {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = true
ifelse {
ZigoEngine.removeTween(infowind_mc.masker_mc);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,',[5,this.startx,this.starty], 1);
ZigoEngine.doTween(infowind_mc.masker_mc, '_width,_x,', [815,this.startx,this.starty], 1);
menuClosed = true
};
};
thanks..
How To Get Button's Instance Name On Stage? OR Can A Button Ahve 2 Instance Names?
i have a button the the stage, with an instance name of: "butt1"
the button itself lives inside a movieclip, where it is called thisButton
when flash runs and I click the button I want to output the button's instance name on the stage (i.e. butt1) but i'm only getting the button's instance name in it's own movie
this._name gives me = thisButton
is the name i want stored in a separate property?
edit: sorry - i realise that the problem is that the button code is inside the mc itself, where the button's name is thisButton
Need Syntax For Conditional Button
I have a "Build-A-Bike" project where the user clicks one of many buttons which "add" parts to a motorcycle. The ADD button does 3 things: 1.Using setTransform it changes the alpha of the parts(MovieClips.aa = +100) on the stage so they are visible, 2. Replaces dynamic text on the parts list (to show price and indicate parts picked), and 3. Adds the price (total = total+500) to the dynamic total box.
So far a winner. I also have a "remove" button which "undoes" all those things for each "Add" button.
The problem:
Each time you hit the button it adds, or subtracts from the total...as in more than once. You can subtract the price of a gas tank 10 times and have a negative total. I need the syntax for a conditional statement(basically). I need it to heck that the ALPHA of a given movie clip is 0 or 100 and use it as a condition for executing the change in the value of the totalvar. Something like this?:
(((So if gastank.aa = 0 then total = +500 else total = +0, )))that way if the movieclip is invisible(alpha @ 0) it knows not to subtract again from the total.
Otherwise I will have a very confusing interface! any help is greatly appreciated. I can send a .fla if anyone wants to examine it...
bigbrain28@yahoo.com
Button Conditional Test
I'll bet this is easy...but I've looked through the posts and couldn't quite find the right code...
2 buttons...audon audoff...on top of each other...when sound on is clicked sound off is set to invisible...and vice versa...
I'm using the buttons to control several different sounds...what I need to do is know when it's been turned off so that when a new sound is attached it won't automatically play...
bg=new Sound("sound1.swf");...etc...
button code: sound off...
on (press, release) {
bg.setVolume(0);
audoff._visible=1;
audon._visible=0;
}
and....sound on...
on (press, release) {
bg.setVolume(100);
audoff._visible=0;
audon._visible=01
this works great...both buttons are movies...
so I think I need something that tests if the sound has been turned off...so when I load a new sound....
attachMovie("sound2.swf",10);
bg=new Sound("sound2.swf");
if (audoff._visible=1) {
bg.setVolume(0);
}
or what???...do I need to create a varible to make the conditional work...?
I know that's not the right syntax...but I hope it conveys what I'm trying to accomplish...again I'm just an unworthy designer begging for help...
Thanks!
Conditional Statement For Button
Hello...this is a straightforward conditional statement that I am having trouble with and I hope I will be able to explain it well.
I want a button called "next_btn" to change a variable called "pres" to whatever variable is next in the sequence. So on the first click it will change pres=vice and then the second time it is clicked it will change it to pres=vice2 and the third time pres=sec and the fourth pres=trea.
I am sure there are many ways to do this. My first thought was an if statement where if(pres=vice) {pres=vice2;} and so on. An easier way would be a switch statement but I am not sure of the syntax. Another way would be to change the variables to numbers and do a loop so that every time the next button is clicked it adds 1 or something but again I am not sure how to write this out. Please help...this is what I have so far:
next_btn.onRelease = function() {
nextImage();
if(pres=pres){
pres=vice;
}
else if (pres=vice) {
pres=vice2;
}
};
but when I click the button a second time it doesn't change the variable to vice2. Thanks for the help...
Help With Conditional Button Fuctions
Hi,
Relative Flash noob. Definately and actionscript noob. Please lend me a quick lesson :-)
I have a framework .swf file with 5 buttons that each load a subsection .swf within the framework using LoadMovie. Each of these sub .swf files has an animated intro. What I'd like to do is have an outro animation for those too...
My problem. I can't figure out how to have the existing sub .swf file (upon button click) play its outro animation and THEN load the .swf file requested buy the button click.
I'm researching conditional statements and elseThan stuff.. but im not a programmer.. Can anyone point me in a direction of a tutorial or example close to what I want. I think i can hack it up if I see an example which is close..if anyone could point me in a direction I'd greatly apprecieate that!
Thanks
SD
Conditional Button States
Good morning --
This should be easy, but I can't find reference on it. I've got simple buttons controlling pause / play in a small swf. The IT guy here asked me if I could tweak them so that they are a different color when active. Something like:
Inactive = Gold (which is what they are now all the time except for the rollover and down states)
Active Play = Green (but this should probably re-set to gold upon entering a new scene?)
Active Pause = Red
Also, hitting Pause a second time should un-pause it.
Is there actionscript for this stuff?
Thanks in advance....
Gully
PS: Actually, I think I have solved the problem, or am at least well on the way to doing so.
Here's a link to the test version.
Edited: 12/18/2006 at 12:39:07 PM by GullyFoyle
Conditional Statement For Button
I'm trying to figure out the correct conditional statement for a button link to load a movieclip not only when i first press the button but also when i press it after I press one of two other buttons that load other mcs.
Movie Clip As Button Conditional Question
Hey everyone,
I was wondering if there was a way to make a movie clip act as a button only when certain criteria was met and then turn back into a regular clip when they are not. I have a gallery that has a zoom-in and zoom-out button. I have the clip dragable when you zoom in, but when you zoom out it is still draggable. Any ideas? Thanks in advance
-JD-
HTML Code:
if(picture._xscale>=100){
picture.onPress = function() {
this.startDrag();
}
picture.onRelease = function() {
this.stopDrag();
}
}
Conditional Button States And Current FLV Source
I am attempting to make a small video player that plays a video with 4 chapters. Each chapter has a button that swaps out the current FLV, like so:
Code:
chapterNav.addEventListener(MouseEvent.MOUSE_OVER, onNavButton);
chapterNav.addEventListener(MouseEvent.MOUSE_OUT, offNavButton);
chapterNav.buttonMode = true;
// Mouseover button state
function onNavButton(evt:MouseEvent):void {
evt.target.gotoAndPlay(2);
}
function offNavButton(evt:MouseEvent):void {
evt.target.gotoAndPlay(1);
}
chapterNav.chapter1Button.addEventListener(MouseEvent.MOUSE_UP, chapter1);
chapterNav.chapter2Button.addEventListener(MouseEvent.MOUSE_UP, chapter2);
chapterNav.chapter3Button.addEventListener(MouseEvent.MOUSE_UP, chapter3);
chapterNav.chapter4Button.addEventListener(MouseEvent.MOUSE_UP, chapter4);
function chapter1(evt:MouseEvent):void {
player.source = "color.flv";
}
function chapter2(evt:MouseEvent):void {
player.source = "MT.flv";
}
function chapter3(evt:MouseEvent):void {
player.source = "mtv.flv";
}
function chapter4(evt:MouseEvent):void {
player.source = "troopers.flv";
}
Nothing too crazy going on here. What I want to do now is have the button state stay on Frame 2 when that button's chapter is being viewed. I tried doing this:
Code:
function chapter1(evt:MouseEvent):void {
player.source = "color.flv";
buttonStateCheck(evt.MouseEvent);
}
function buttonStateCheck(evt:MouseEvent):void {
if (player.source == "color.flv") {
chapterNav.chapter1Button.gotoAndPlay(2);
} else if (player.source == "MT.flv") {
chapterNav.chapter2Button.gotoAndPlay(2);
} else if (player.source == "mtv.flv") {
chapterNav.chapter3Button.gotoAndPlay(2);
} else if (player.source == "troopers.flv") {
chapterNav.chapter4Button.gotoAndPlay(2);
}
}
But I get this error:
1119: Access of possibly undefined property MouseEvent through a reference with static type flash.events:MouseEvent.
Using If Statements Within A Button
wondering if anyone can help me out...
I'm using flash to spice up the navigation on an HTML page. All the sections are single words, and I've used the same movieclip (with dynamic text) for each of the five sections. The problem is that all five sections will go to the same URL when clicked on... Is there anyway to insert a variable so that the user will go to different URLs when different instances of the same movieclip are clicked on?
Thanks in advance.
Compound Conditional Input-text With Submit Button Problem
I'm sure I have this almost right but it won't work - I have searched but can't quite find the solution. I'm sure it is really simple so any help is greatly appreciated.
It is for an educational interactivity derived from these rules:
Quote:
Quantity Ordered/Discount Applied
300 – 350 = 7%
200 – 299 = 5%
100 – 199 = 3%
Less than 100 = No discount
In the animation there are 4 text input boxes (input_'x') each with their own submit button (submit_'x'_btn) beside them. The pupil will enter a 'quantity' number into each box, hit the submit button and a movieclip will play to represent the '% discount' resulting (say, five_mc).
So here is my pidgin code so far, it should make sense as to what I want to happen.
Code:
submit_1_btn.on (release) {
if (input_1<=350 && input_1>=300) {
_root.seven_mc.play();
} else if (input_1<=299 && input_1>=200) {
_root.five_mc.play();
} else if (input_1<=199 && input_1>=100) {
_root.three_mc.play();
} else if (input_1<100) {
_root.nodisc_mc.play();
}
If someone can sort that into woarkable code I would be very thankful, and for bonus points an 'Invalid Entry' rule would be amazing.
Thanks in advance
Scott@AOKLearning
edit: nearly forgot,
Flash8 Pro
Win XP
must be published in Player 7
Multiple If Statements Within Button
Currently working to build in if statements within a button. Attempted to reference color changes of specifc images/movieclips within the movie.
Example coding:
on (rollOver) {
locColor = new Color(_root.inbox.L1);
if (variablename1 == "New Message") {
setProperty ("L1", _alpha, "100");
locColor.setRGB(0x00FFFF);
}{
locColor = new Color(_root.inbox.L2);
if (variablename2 == "New Message") {
setProperty ("L2", _alpha, "100");
locColor.setRGB(0x00FFFF);
}
}
Any support on this would be very helpful. If only one If statement is used then - it works perfect, but if two or more If statements are used - then nothing happens. Even tried the "else if" and "|| (OR)" in the script. Still no luck. Look forward to your support.
|