If Statement / Labels Problem
with the: if(Key.isDown(65)){ ; } How would I ad code to the above to go to a certain frame label and play whats on that timeline. for example I have a boxer on the main timeline (a MC) and inside that movie clip is another movie clip called fighter(instance name) which is key framed out with animation, with frame labels like punch (label) kick(label).
I'm having trouble writing the above code to make my boxer punch when the A(65) key is hit. can you help me with this code?
if(Key.isDown(65)){ in other words what goes in here to make my boxer punch on the other timeline ; }
P.S. where do I put the code? (in a frame on the main timeline or in the boxer MC or in the fighter Movie Clip?)
If you can help I thank you soooo very much! im pulling my hair out. lol Mike
FlashKit > Flash Help > Flash ActionScript
Posted on: 03-26-2006, 06:37 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
If Statement / Labels Problem
with the:
if(Key.isDown(65)){
;
}
How would I ad code to the above to go to a certain frame label and play whats on that timeline. for example I have a boxer on the main timeline (a MC) and inside that movie clip is another movie clip called fighter(instance name) which is key framed out with animation, with frame labels like punch (label) kick(label).
I'm having trouble writing the above code to make my boxer punch when the A(65) key is hit. can you help me with this code?
if(Key.isDown(65)){
in other words what goes in here to make my boxer punch from the other timeline ;
}
P.S. where do I put the code? (in a frame on the main timeline or in the boxer MC or in the fighter Movie Clip?)
If you can help I thank you soooo very much! im pulling my hair out. lol
Mike
Conditional Statement Problem - Frame Labels?
Hello -
I'm working on a little panel with 4 boxes.
Box1 expands so that the other three contract using the tween class.
Box 2 links to a java popup window regardless of it's 'state'... which is where my problem is.
Using a conditional if/else statement I want Box2 to open the popup window when in it's "maximise" or normal state ("maximise" is the frame label in the box2 mc) - but NOT effect anything else.
If Box2 is in it's "minimise" state then I want it to return to it's normal state before it opens it's popup.
Does that make sense?
I don't know how to check for the state of the mc!!! Help?!
Here is my code:
Code:
//Actions for box2
box2.btn_box2.onRelease = function()
{
if (box2.state =="minimise") {
box1.gotoAndPlay("close");
box2.gotoAndPlay("maximise");
myTweeningY = new Tween(box2, "_y", Regular.easeOut,560,250,1,true);
box3.gotoAndPlay("maximise");
myTweeningY = new Tween(box3, "_y",Regular.easeOut,615,450.9, 1, true);
box4.gotoAndPlay("maximise");
getURL ("javascript:pop1();" );
} else {
getURL ("javascript:pop1();" );
}
}
Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails.
[Flash CS3 (Flash 8 available as well)]
[Actionscript V2 (AS3 Not available for this project. End result must be in AS2. Plus I haven't learned AS3 yet)]
Hi
Sorry about running two posts so close together, but I couldn't change the other one to reflect the changes I've made in my problem.
The 1st post dealt with my theory that my IF statement wasn't written correctly, and so failed. But I've since disproved that.
Okay here is the situation.
I isolated elements from a larger app that I'm putting together and the problem still followed.
The Flash movie contains 2 Text files, one Component button, and 1 component checkbox.
The purpose of the application is to load an XML file(works)
Populate 2 text fields with information from the XML file(works)
Compare the two text fields, if they contain the same information then the checkbox, via AS is told to be selected. (Heres the problem);
Heres the code:
Code:
runCode_btn.onPress = function() {
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
if (success) {
//point to the first node with information
var track_xml = data_xml.firstChild;
//loop through each node
while (track_xml != null) {
//print out each node
test1 = track_xml.toString();
//point to the next node
track_xml = track_xml.nextSibling;
//Runs my code
//Define the contents of two text fields located in the movie
textOne = data_xml.firstChild.childNodes[3].firstChild;
textTwo = data_xml.firstChild.childNodes[5].firstChild;
trace("data_xml.firstChild.childNodes[3].firstChild = " + data_xml.firstChild.childNodes[3].firstChild);
trace("data_xml.firstChild.childNodes[5].firstChild = " + data_xml.firstChild.childNodes[5].firstChild);
/*dummyYes = data_xml.firstChild.childNodes[5].firstChild;
dummyNo = data_xml.firstChild.childNodes[6].firstChild;
dummyMaybeEmail = data_xml.firstChild.childNodes[3].firstChild;
dummyMaybeFax = data_xml.firstChild.childNodes[4].firstChild;*/
//Checks between the two text fields for a match
if (textOne == textTwo) {
trace("It is selected!" + textOne + " " + textTwo);
check_fax.selected = true;
} else {
trace("Ir is NOT selected!" + textOne + " " + textTwo);
check_fax.selected = false;
};
}
} else {
trace("error reading file");
}
delete data_xml;
};
data_xml.load("XML/dummy2 - email.xml");
};
After you read the code, you'll have noticed the trace commands I stuck in there.
They send this to the output panel:
Code:
data_xml.firstChild.childNodes[3].firstChild = 1
data_xml.firstChild.childNodes[5].firstChild = 1
Ir is NOT selected!1 1
So as far as I can see, it reads the XML file with no problems, it loads the text fields with no problem. But for some reason the IF statement refuses to recognize that both the XML nodes contain the same information.
If I alter the code like so:
Code:
textOne = 1;
textTwo = 1;
Then the IF statement works. It sees that the two text fields are identical in content, and the checkbox is selected.
So whats wrong with the Data from the XML file?
I haven't a clue.
I tried converting from a string to a Numeral using:
Code:
newText = Number(textOne);
But that didn't work, it just produced "NaN" when traced.
I tried populating the XML file with text versus numbers, still no luck.
What came from the trace:
Code:
data_xml.firstChild.childNodes[3].firstChild = hi
data_xml.firstChild.childNodes[5].firstChild = hi
Ir is NOT selected!hi hi
The idea behind this app is that its an electronic form. The user fills it out, the information is then sent to a newly created XML file, months later the open the XML file in flash, and Flash fills out text fields and check and or unchecks Checkboxes based on the XML data.
CheckBoxes are mandatory.
But I don't see how I'll be able to use them if i can't create and condition statements based on the loaded Data.
I'd really appreciate some help and suggestions with this, I think I'm out of ideas.
Thanks
-Lem
Problem With Continue Statement And Label Statement
What am I doing wrong?
ActionScript Code:
var a = {
a:[1,2,3,4,5,6,7,8,9,0],
b:[1,2,3,4,5,6,7,8,9,0],
c:[1,2,3,4,5,6,7,8,9,0],
d:[1,2,3,4,5,6,7,8,9,0],
e:[1,2,3,4,5,6,7,8,9,0],
f:[1,2,3,4,5,6,7,8,9,0],
g:[1,2,3,4,5,6,7,8,9,0]
}
outerLoop: for(var i in a){
trace(i);
for(var j in a[i]){
trace(' '+j);
continue outerLoop;
}
}
Quote:
1039: Target of continue statement was not found.
Converting 'If Else' Statement To A 'switch' Statement
I am attempting to convert the following If statement to a Switch statement and I'm unclear as to the details of the execution of it. If someone could help me with this I would be very grateful. Here is the If statement followed by the shell of my attempted switch statement. TIA.
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
f (spotOne) {
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
} else if (spotTwo) {
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
} else if (spotThree) {
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
} else {
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
}
};
---------------------------------
(attempt at conversion to switch)
var spotOne:Boolean = true;
var spotTwo:Boolean = false;
var spotThree:Boolean = false;
var spotFour:Boolean = false;
btn.onRelease = function() {
var location:Number = ?
switch(location) {
case spotOne:
ball.slideTo(450, 100, 1);
spotOne = false;
spotTwo = true;
break;
case spotTwo:
ball.slideTo(450, 150, .5);
spotTwo = false;
spotThree = true;
break;
case spotThree:
ball.slideTo(100, 150, 1);
spotThree = false;
spotFour = true;
break;
case spotFour:
ball.slideTo(100, 100, 1);
spotFour = false;
spotOne = true;
break;
}
Labels
Hi i have a problem here.
I am trying to have 2 person kicking a ball to and thro each other.
I will have a button on each of the person, so that when u click on it, they will kick the ball.
How I do it, is have the two person and the ball all to be a mc.
On the button, when the person clicks onto it, if the ball timeline is at a certain frame, it will play, else it won't.
But I am having trouble referring to where the ball stops(the frame label).
on (release) {
if (ball.stop("onetwo") {
_root.person.play();
_root.ball.play();
}
}
Also do I did to follow a IF with an ELSE??
*********
One more thing. I was loading one movie into another, how can I have the actions still playing??
thanks
Sushi82
Labels
hi
is it possible for actionscript to know if a frame exists with a paticular label?? so lets say I have a label called "john" on frame 60, is it possible to check if the frame with label "john" exists or not?
thanks
phil.
Labels
can i name 2 frames (diffrent scenes) with the same name?
Labels Gone
using flash mx 2004 i had standard labels on my radio buttons. i then use this main movie inside another so i can have an external preloader. everything worked fine, but i must have changed something, because now when i test it, the labels dissapear. When I test the main movie they are still there. But using the preloader they are gone. and when the movie is tested they still work the same, the labels just left. any idea as to what caused this?
How To Add Labels?
Sorry for stupid questions.
But how to add labels on frames in Flash MX?
Preloading Using Labels
i know how to preload using labels, however, if you have labels in movie clips and not in the main movie, how do u target or select them when doing the If Frame is Loaded actionscript? it doesn't show up in the drop down menu. thanx
Preloading With Labels
I already know how to make preloaders however i want to make a preloader with percentage increases (25%, 50%, etc.) I can learn that from tutorials online but the method i want to do that is with labels. If the label isn't near the preloading movie, you do not have the option to select it from the dropdown menu when you select what label you want for the "If frame is loaded ()"
Now what i'm asking is, i need to kno how to identify labels that may be within other movie clips and scenes. I know to identify movie clips you use ../(instance name) instead of the usual /(instance name). how do you do it for labels?
Also if how i'm doing it is impossible, plz suggest another way. thanx
Magnetic Labels
I wonder if any one might know where i could get a tutorial for these magnet tags such like the ones below.
http://www.rawfibre.co.uk/
many thanks
Labels To Text To Get Url..
Ok. I should know the answer to this question, but I fail to know it, at least at the moment.
Ok, Here goes:
I have a text field that offers the user to insert text. Say I have a label that tells the user to input their email address or someone elses. Then they can click on a button to Send the info.
Ok? So. inother words the actionscript would look like:
mailto:?????
How can I get Flash to set the mailto: and the users text from the text field together.
??
Thanks
Chad
Frame Labels
Flash 5 Question: In a short .swf, I am placing frame labels on 1 track, however, each time I insert a frame label, it converts the previous frame label to the same label. If I then fix the one that changed, it then remains correct. What am I missing?
Thanks!
How Do I? - Text Labels
I see Flash sites where text will appear (Scroll on/Fade on) when the user moves the mouse over a button. It the Fades/Scrolls off when the user rolls out! How is this done?
Any help much appreciated!
Frame Labels
I am using a Mac - can frame label names have spaces or should i use an under _ score?
for example in
on (release) {
_root.gotoAndPlay("label in scene")
is it ok to have the spaces?
Add Labels To Listbox
can someone help me with dynamically adding labels to the listbox companents??
thanks for the help
riyan
Scenes And Labels
what are some way to link to a specific scene and a specific label within the scene.
Labels And Variables
I'm passing a variable which holds a frame label to a function which tells a movie clip to go to that frame label.
Example:
aLabel = "section1";
function launchLabel(whichLabel) {
gotoAndPlay(whichLabel);
}
launchLabel(aLabel);
Flash is not reading the variable whichLabel correctly. whichLabel is passed as a string, but the statement gotoAndPlay(whichLabel); is reading whichLabel as undefined. Is there a way for the method "gotoAndPlay" to call a label using a variable?
Thanks,
Craig
Frame Labels
is there a way to address a frame label like you would a frame number? I'm making a radio and its a living nightmare for me to use raw numbers to advance to the next track. right now I've got this for the next track button
if (_currentframe > 1 && _currentframe < 8659) {
gotoAndPlay(8660);
}
and so forth to advance tracks.... each track has its own lable though... like "Song1" and then "Song2" . What I would like to do is say something like:
if (_currentframe > "Song1" && _currentframe < "Song2" - 1) {
gotoAndPlay("Song2");
}
how can I do that? Or if there is a better method can someone please tell me? this has been driving me nuts.
thanks in advance
--Metalguy
BarChart: Where Are Those Labels?
When you use the component BarChart and move the mouse over one bar you get a label that says:
Label: the label
Value: 50
I´m trying to edit that to tranlate "Label:" and "Value" but cant find where is that. Can someone help me?
Thanks!!!
Linking To Labels?
Is that possible? For example can I add an action to a button saying on release, go to a frame labeled HOME?
Thanks for your help.
Frame Labels
how do i add frame labels in MX....
stoopid ytes but i need to know thnx!!
Dynamic Labels
I'm trying to create a dynamic timeline without using labels.
Right now I have a series of labels counting up the timeline (next1, next2, next3, and so on).
I have a button with a "keypress" function following up the timeline referencing those label.
on (keyPress "<Space>") {
gotoAndPlay("next"+forward);
_root.square = 0;
if (forward<70) {
forward++;
}
Is there a way to make a dynamic label system that will creat it's own numbers and order? It's killing me to have to relabel those numbers in order to have my button follow along.
---- Frame Labels ----
hi hi,
can I use frame labels in actionscript?
Because I did like this ("infostop" is the name of the label):
on (release) {
if (_currentframe=="infostop") {
loader = 1;
gotoAndPlay ("infostop"+1);
}
}
and it doesn't work........
any solution?
Setting Labels
Hey,
I am trying to set a label to like a frame or w/e and as you can see in the attached file, it says to get it to say onFrame and all that but I can't get that. Where do you right click and add the action to get that. I keep getting AtFrame and it not workin! Help PLease!
Creating Labels
Already so far so good. I am reading " Sama Teach yourself Flash MX Actionscript in hours".
Flash has a neat feature to create labels, by using names instead of frames so if you need to move something you dont have to rewrite the script, but it doesn't tell me how to create labels.
Can someone help me with this or know of a good source to get the information?
Section Labels
Hi all,
I have made a map using flash and swift 3d. When a user rolls over a certain hotspot it makes the movieclip underneath play its sequence to make it look like a 3 shape rises from the map so they know where they are. What I want to do is when the user rolls his mouse over the hotspot they get a line from the mouse and at the other end of the line they get a word telling what the section actually is.
Could anyone gove me any indication as to how I could achieve this and how the actionscript could look.
Thanks Pixelmagik
Frame Labels.
Hi Peeps,
Trying to work out how to use frame labels in if statements. Is it possible?? I got something like this, but duh it dont work!! :
if (movieclip._currentframe < movieclip._("framelabel")) {
play();
}
Any ideas? I've never used frame labels like this and I got it all wrong. Maybe theres an easier way to do it so any help would be really good. I dont want to use frame numbers as i've got a lot of moving around to be done.
Cheers.
Steven.
Prevframe - Can This Be Done With Labels?
i have a scrolling text box with up and down arrows...code looks something like this:
on (press) {
_root.textclip.prevFrame();
gotoAndStop("1up");
}
on (press) {
_root.textclip.nextFrame();
gotoAndStop("2down");
}
instead of moving up and down just one frame or a certain # of frames...(nextframe (+ 5))...i want to move to the next and prev labels within the movieclip...is there an easy way to do this?
thanks
How Do You Make Labels
how do i make labels on a layer so that i can make goto commands to go to different labels? you know, the labels that have a little red flag icon. i've been searching through the flash help and can't find anything.
Rollover Labels?
Hi, i think i have seen a post for what i want before but i cant find it, so sorry guys for asking again.
I have 4 little pics..squares.
what i want to do is for, as you roll over each of them a little label pops up...but i can remember the little label attaching itself to the mouse and only comes up when its on the image and moves about attached to the pointer as long as its inside the area.
make sense?
thanks!
Labels Or Numbers In MC?
Hi,
thank you for reading this.
I am using frame labels for button actions in a movieclip. I tried with frame numbers and that doesn´t work. No problem with labels though.
I have seen here on the board that this is common. Now I´m just curious: does somebody know Why? Does Macromedia consider this a problem?
regards
ik.
New To Scenes And Labels
Ok, so I have made a bar that loads at the beginning of my movie using actionscript.
where do i go from here?? I know that I have to create scenes for different parts of my site but i dont know how to go about doing it!!!
May seem very simple but i need help with this to create my website.
How do i set up the scenes and labels that the actionscript recognises in the timeline e.g
a scene for "about me"
a scene for "my blog"
a scene for "art"
you get the idea, i want to have buttons that i have made on the first frame(the one displayed after the intro) link to other parts of my website.
I would appreciate all help email me at
shanekillian18@eircom.net
thanks
Scenes/Labels
Hi.
I am trying to do a very basic slideshow display in flash. the way it is set up is there is an initial menu page, where the user chooses a category to view the slides of, they click on the button, and the slide show begins. within the slide show, there are next/back buttons which cycle through the show.
functionality:
the menu page buttons, when pressed, jump the flash movie to a label within a seperate scene.
the next/back buttons jump to labels with that scene.
the code:
//the next button-
on (release) {
if (currentImage<totalImage) {
gotoAndStop(scene+"Load"+(currentImage+1));
} else if (currentImage==totalImage) {
gotoAndStop(9);
secondLoop = false;
}
}
//all this does is compare the current
//image to the total number of images,
//and then moves forward from there.
//any added complexity is for aesthetic
//reasons. the code is dependent on
//the variable "currentImage" being set.
//each label (i.e. scene1Load2) has an //action in the first frame to set the
//variable "currentImage".
currentImage = 2;
--
the problem:
The code works fine, the slideshow works fine unless the scene with the slideshow is not the first scene in the scene list. So all of my functionality works up until the point where i add the menu page, and then, no matter what is on that page, the code to set the "currentImage" variable no longer triggers when i use the next/back buttons. I have tested this rather extensively, and am certain that everything works when the slideshow scene is first in the list, and the variables no longer set if it is not. This seems to me to be most certainly a bug, but i am hoping that someone has run into this before and has a workaround that does not involve placing the whole movie in one scene, or creating seperate movie clips for each page.
thanks,
jkl
Frame Labels?
i really have looked everywhere, and i cannot for the life of me, figure out how to create a frame label!! pleeeease help!!!
-glam st. glam
p.s.
i'm using flash mx 2004
Frame Labels
I am working a project (already developed) which has many frame Labels. all with hard coded links in the buttons (ie gotoAndPlay "LabelName") is there an easy way where I can use something like nextFrameLabel previousFrameLabel to jump along and back through the timeline?
Or does anyone have a better method?
Frame Labels Please Help
Hi there, I can't seem to get anyone to help me! I have my site right? now each page is a Scene. (I know I know, I shouldn't use scenes) Everyone tells me that I should use Frame labels, thats fantastic, but when I try to go make them I don't even know where to start so my site will work. I'm going to throw this computer out the window pretty soon....please help...Ive been trying to make these links work for three days now.
Component Help: Labels
Learning as I go along here...
I need to create a solid color background behind a label, but I can't figure it out. I tried using styles, but I don't know the property name. I tried "backgroundColor", "bgColor", and several other variations with no luck. I tried getting the width of the label, but its the same width as I had placed it on the stage. I set it to autoSize left, but my assumption was wrong that it would set its width property to the width of the text as a normal textfield would.
So I ask you, what is the best approach to this?
[MX] Frame Labels
I am trying to follow this tutorial:
http://www.flashkit.com/tutorials/In...-532/more3.php
Which will create scrollbars on my flash website.
My problem is that when it asks me to put in a frame-label of 'load' it seems to label frames 1 and 2, not just 2. Am I missing something or does this always happen? My concern is that I asks me to make more frame labels soon after 'load'.
Also, when I add ActionScript, why is it when I click Frame 2, the ActionScript from Frame 1 is there? Should there not be a blank field for Frame 2?
Thanks.
Labels/actionscript
If anyone can help, I want to write some actionscript that will make a button go to a label i have named 'introduction', i want this to happen once the button has been clicked.
Any ideas how to do this?
Frame Labels
hi, is there any way to tell what frame label a movie clip is currently on, or can you only use the numeric _currentframe?
Help With Actionscript & Labels
Hi,
I am pretty much a nub in Flash & Actionscript.
I am working on a website in flash. As you can see in the code below I created a button. When the button is pressed I used an "if" function about the count.text
If count.text = 0 then I want the movie to play the scene labeled "sunbreak" and then play the label "about".
And I want that if the count.text doesn't equal 0 then it plays "about" directly without playing "sunbreak" first.
I thought I wrote it correctly, but I guess I didn't. Because when the button is pressed, it's like "sunbreak" got played really really fast and then "about" plays. I think that "sunbreak" starts playing and then "about" starts playing before "sunbreak" completes it's animation.
This is what I need basically:
If you press the about button you will get "sunbreak" followed by "about".
If you press the news button you get "sunbreak" followed by "news".
This happens for all the buttons UNLESS "sunbreak" was already played, which in that case, if you press (for example) the news button it will play "news" without playing "sunbreak".
PLEASE HELP!!!!
[F8] LoadMovie To Go To Labels
Hello,
I am trying to load external swfs and make them go to labels within the external swf. It's not working. Below is my code. Any suggestions would greatly be appreciated.
Thank you.
Code:
on (rollOver) {
this.largerview.gotoAndPlay("over1");
}
on (rollOut) {
this.largerview.gotoAndPlay("out");
}
on (press) {
this.largerview.gotoAndPlay("pressdown");
}
on (release) {
this._parent.container.loadMovie("swf/largephotos.swf,bp1");
}
Frame Labels Help
In a previous post I asked how to "unload" a particular scene when another scene was called into play. It seemed a bit unpractical, so instead I have tried using frame labels. Sounds easy enough right?
ARRRGH!
So I've assigned the Instance Name that the clip itself is under "Pictures", and have labeled the frame "hb" So the actions that I have applied to the button as seen above, should play the clip, but it doesn't. The interesting thing is, it will play text if I place some on the "description" layer, just not the 'graphical clip itself. What's going on??
Frame Labels
Can you not have a frame label using numbers?
I have a button going to a frame label and when I use words, it works but when I change it to numbers (which is want to use (years)) then it doesn't.
It doesn't make sense as to why it won't take numbers.
[CS4] Frame Labels
Am amending a flash file that worked perfectly in CS3.
On amending and testing in CS4 all of the frame labels in particular scenes cannot be found. They are all on the timeline but when testing the swf I get:
ArgumentError: Error #2109: Frame label testLabel not found in scene testScene.
at flash.display::MovieClip/gotoAndPlay()
at test_fla::MainTimeline/test_click()
If i replace with frame number it works. If I change back to frame label I get same error.
Anyone else had this problem and fixed it?
|