ActionScript 2.0 :: Button Script (Statement Must Appear Within On Handler)?
Oct 22, 2003This is what I get in the output window: Statement must appear within on handler back_button.onRelease =function () {
View 7 RepliesThis is what I get in the output window: Statement must appear within on handler back_button.onRelease =function () {
View 7 RepliesThis is what I get in the output window:
Statement must appear within on handler
back_button.onRelease =function () {
I have been asked by a local web development company to code some flash banners for use with there banner ad site they are doing. I have been sent a banner to add the actionscript and also the actionscript as well. What I have is a fla doc with a button that covers the whole banner. Then on the banner I have this actionscript:-
this.masterButton_but.onRelease = function(){ if (root.Hyperlink != null){ getURL(root.Hyperlink); }else if(root.clickTag != null){ getURL(root.Hyperlink); }else{ getURL("http://www.greatrun.org/Events/Event.aspx?id=3"); } }
When I test it the compiler errors and says in the description "Statement must appear within on handler".
I keep getting the "statement must appear within on handler" error when I try to add a gotoAndPlay event to my button...
View 3 RepliesI am getting
Symbol=page5, layer=Layer 1, frame=1, Line 1Statement must appear within on handler my action in actionscript is
getURL("http:url.....)
I would like to use variables in my flash app. The app is quite simple, has many buttons, and on each of those buttons I have a simple script: on-rollover and on-release. For both actions I use the same value, which I want to put in a variable. The following script results in an error message: Statement must appear within on handler. When I have to declare the variable inside the on-handler, I have to declare it twice, which makes it useless as I have to enter the value twice. How can I get this working?
country = "uk"
on (rollOver){ gotoAndPlay(country)}
on (release){ getURL("/"+country+"/", "_self");}
I am just learning Flash. I'm using Flash CS4, However I am using Actionscript 1.0/2.0. I have a main page with just simple buttons, and such. My question is, I need to load a swf within my main page. I have a sqaure in the center of my page that I want to load a swf in. I made a rectangle using the rectangle tool, and converted the rectangle into a symbol so that actions may be placed within it. I want to load a file called News.swf within the rectangle. I can't find any code to do this that doesnt have compiler errors.
I found one code: News.loadMovie("News.swf"); when I put just that in the Actions field, and I export the movie I get the error: Statement must appear within on/onClipEvent handler
I just want to load News.swf in the actions tab within a symbol.
novice AS coder, trying to get a simple flash form to submit data to a php script, then get data back from the script.the "send" button has this code:
on(release) {
//assign user-input value to lv property called years
lvOut.years = years.text;
[code].....
sw1 = text input
asw1 = text input
My problem is that is sw1 when I put in "188" it gives me "28.73" instead of "209.43". If I put in "2" it gives me "28.73" instead of "21.78". So it really doesn't work. My other "If" "Else If" statement works.
Code:
protected function sw1_changeHandler(event:TextOperationEvent):void{
// TODO Auto-generated method stub
if (sw1.text <= String ( Number("18.325")) && sw1.text >= String ( Number("1"))){
(asw1.text = String ( Number("21.78")));
} else if (sw1.text <= String ( Number("24.83")) && sw1.text >= String ( Number("18.326"))){
[Code] .....
[FlashCS3-AS2.0]i'm getting continuous errors of: ''Statement must appear within on/onClipEvent handler''On one .swf the script is working fine, but on 3 others im gettin 9 error messages on each.
I have entered the script on the 'Frame' on every scene, including the one that worked.Heres the script:
var groupinfo:Array = [intro, menu, modern, street, freestyle];
var activebtn:MovieClip;
function grow() {
if (this._yscale < 180) {
[code]...
I am trying to call an external .swf and it does not seem to be working. I have read a few other posts with no luck. I have a small calendar that flips and at the bottom i have a link to another. So i put an empty MovieClip on the following frame. the button directs me to the empty frame where a pre-loader should start, but nothing happens. here is the code i last tried:
[Code].....
I am getting a compiler error saying "Statement must appear within on/onClipEvent handler" I am also trying to link back to the original .swf from the loaded .swf would anyone know how to do that?
i'm trying to use if statements but can't get this thing to work i want to check if another button is visible on release of a button to determine what action to be taken.the 'gotoAndPlay("firstscene",1)' is just there as an outcome, will be changed later. anyway this is the code i've got on the button i'm pressing. blobyellow2 is an instance of a button blobyellow is it because it's an instance that it's not working?
[Code]...
edit: sorry forgot to put what's wrong with the code. it acts as though the statement is correct no matter if it is or isn't.
I've created a button (type: MyButton) with two child, a text (TextField) and a image icon (type: MyIcon). Then I've append an eventlistener mouse_click on my button. As soon as I click on the text, the e.target on the handeler function is recognized of MyButton type. Otherwise, if I click on the image icon (child of button) the e.target is MyIcon type, instead of MyButton. How can I prevent this? I need all click to be recorded on the button, where I've stored some attributes I need on handler function.
View 1 RepliesIt used to happen in AS2.0 as follows :
my_Mc.onPress = function()
{
trace( this)
}
//output :
[my_Mc Movieclip]
[Code]...
I seem to be having a recurring problem attaching events to a button i have created within 2 other movieclips.I get the following error:TypeError: Error #1009: Cannot access a property or method of a null object reference.So it looks like it can't find the button, in order to attach the event listener. The question is why? I am attaching a similar event to a button on the main timeline and that works fine. So it looks like a scope issue, but I am referring to it properly.
code below:
ActionScript Code:
import flash.net.navigateToURL;
[code].....
I need a few pointers on how to create multiple buttons programmatically with different event handlers, or rather: differently parametrized event handlers. My real use is a bit more complex, but it comes down to this: I need a button that can delete itself upon getting clicked.
var Buttons:Vector.<Button> = new Vector.<Button>;
var newButton = new Button;
var int = Buttons.push(newButton);
[code].....
How do I get a button event handler to refer back to the main timeline from within it's movie clip inside another movie clip?
View 1 RepliesI am looking for a way to programmatically dissassoicate the click handler function from a button on my mxml component through actionscript code.
Something like what older actionscript let you do,
mybutton.click = null;
I have the following codes,
for (i=0; i<answerArray.length; i++) {
var myOptionButton1:spark.components.RadioButton = new spark.components.RadioButton();
myOptionButton1.label = answerArray.getItemAt(i).Answer_Choice;
[code].....
I am trying to figure out a way for an action script to change the background color of a particular button state.
I have a puzzle graphic. As the mouse moves over the pieces of the puzzle, the colors change. When the mouse clicks on the puzzle piece I want them to permanently change. However, I cannot figure out how to access the bgcolor property of a button state object, such as the up state.
I have what seems to be a simple task, yet I cannot seem to figure it out. I am busy creating a project in ActionScript 3, and while I am fairly fluent in ActionScript 2, I am being stumped a bit here.
I have a simple dynamic text field inside a button object. This text field has the name of txt_title. I have attached event handlers to change the alpha of the buttons when they are hovered over, however I also want to change the value of the text field within the button, when hovered over. My event listener looks like follows:
[Code]...
I created a screen(calculator) with bunch of buttons,i can handle button event with one handler.But i want to know that can we do a one handler for all buttons......likein java
we can perform the task of perticular button by like this
if(event.source=="button1")
{
}
[code].....
I have written some actionscript:
ActionScript Code:
stop();
/* QUESTION */
question1_txt.text = "Question 1. 'question goes here'.";[code]....
but the functions dont work in the way they should.instead of only working when a button is pressed, it automatically takes effect.
I'm trying assign two functions to one button. The first click does a loadMovieNum to level 1. The second click will unloadMovieNum on level 1. So the first click loads a movie, the second click unloads it. Pretty basic.
I'm guessing it's a simple if statement, but I don't know how to go about it.
Anyone want to take a stab?
How do you script a Pause of X Seconds on X Frame and also on that frame have a button release statement that can take you forwards or take you backwards, elsewhere in the timeline - Without affecting the 'Pause' statement... therefore not mucking up the timeline and causing it to jump around at the end when all catches up?I take it once a pause has taken place - a button that can take you elsewhere, if clicked on - does not Cancel the initial pause and therefore lies my problem?
View 3 RepliesI have a button which controls the horizontal movement of a movie clip and next to it I have a button, if the user clicks the button once it moves up half way and when they click it again I would like for it to move up the rest of the way.This script has been applied to the button
on (release) {
if (xpos = 0) {
trig.xposnew = -396;
[code]....
I have a flash movie that plays through automatically pausing on each frame for a set amount of seconds.
I used the following code to pause the movie which works 100%:
stop();
var interval:Number = setInterval(
function():Void {
[Code]....
But now i have several buttons on the movie as well, now what i want to happen is that when any one of the buttons is clicked it should ignore the above piece of code and not pause on the frame but stop on the frame.
'm trying to write an if/else statement for a mc button that says if mc is on stage don't attach it, else attach it.
View 5 Repliesi have 9 images. the one that loads in is based on the number established by the variable loopCount, which increases by 1 each time the main movie loops. Based on what value loopCount has at the time, i want a matching button to appear. For example:
loopCount has the number 5 assigned to it this time around image 5 loads in button 5 needs to load in to match. i am guessing its some simple if statement, but i am at a loss. here is my attempt at the code:
[Code]...
I am having a problem using an if statement in a button. What I want to do is go to a frame dependent on which frame we are already on. For example if I am on frame one and I press the button the first time it will take me to frame five, if I then press the button a second time the actionscript detects we are on frame five so goes to frame ten and so on.
ActionScript Code:
on (release) {
gotoAndPlay(5);
if (currentframe == 5) {
gotoAndPlay(10);
} else if (currentframe == 10) {
gotoAndPlay(15);
} else if (currentframe == 15) {
gotoAndPlay(20);
}}
When I first press the button it takes me to frame 5, the second time I press it goes to frame 10, but when I press after that instead of going to 15 it takes me back to 5 then 10 then 5 then 10 etc and is stuck between going from 5 to 10 and back again.