ActionScript 1/2 :: Using Variables: Statement Must Appear Within On Handler

Jun 30, 2010

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");}

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Statement Must Appear Within On Handler?

Jan 29, 2010

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".

View 1 Replies

ActionScript 1/2 :: Statement Must Appear Within On Handler

Mar 12, 2009

I keep getting the "statement must appear within on handler" error when I try to add a gotoAndPlay event to my button...

View 3 Replies

ActionScript 1/2 :: Statement Must Appear Within On Handler?

Mar 20, 2012

I am getting

Symbol=page5, layer=Layer 1, frame=1, Line 1Statement must appear within on handler my action in actionscript is
 
getURL("http:url.....)

View 5 Replies

ActionScript 2.0 :: Statement Must Appear Within On/onClipEvent Handler?

Jan 4, 2009

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.

View 9 Replies

ActionScript 2.0 :: Statement Must Appear Within On Handler Error?

Sep 1, 2010

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].....

View 1 Replies

ActionScript 3.0 :: SW1 Change Handler - IF Else Statement Not Working

Nov 21, 2011

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] .....

View 5 Replies

ActionScript 2.0 :: Back Button - Statement Must Appear Within On Handler

Oct 22, 2003

This is what I get in the output window:
Statement must appear within on handler
back_button.onRelease =function () {

View 6 Replies

ActionScript 2.0 :: Error: Statement Must Appear Within On/onClipEvent Handler

Jan 16, 2008

[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]...

View 3 Replies

ActionScript 2.0 :: Button Script (Statement Must Appear Within On Handler)?

Oct 22, 2003

This is what I get in the output window: Statement must appear within on handler back_button.onRelease =function () {

View 7 Replies

ActionScript 2.0 :: Calling External .SWF - Error Saying "Statement Must Appear Within On/onClipEvent Handler"

Sep 18, 2009

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?

View 7 Replies

ActionScript 3.0 :: Pass Variables To Event Handler?

Jan 15, 2008

I have 3 buttons which will do basically the same thing(2 fade when one is moused over). I have it working but was wondering if there was a cleaner method instead of using a switch function within the handler.

Here's my code:
Code:
btn1_mc.addEventListener(MouseEvent.MOUSE_OVER, menuOver);

[code]....

View 7 Replies

ActionScript 3.0 :: Returning Variables From Event Handler Functions?

Jul 13, 2009

Look at my code below

import fl.transitions.Tween;
import fl.transitions.easing.*;
var id:Number;

[Code]....

The variable id which is declared globally is changed in the function goNext. I need the variable to retain the value, but it gets reset as the function is not returning. I tried the return method but that's not working either.

View 14 Replies

Flex :: SOAP Variables In Network Monitor But Not Making It To Event Handler

Aug 13, 2009

I am querying a 3rd party web service and not all the data seems to be making it to the event handler. When I view the request/response in the Network Monitor I see a collection of data objects each containing two string variables (name, url) and two arrays (counts, breakdown). When the result handler receives the data and I view it in debug mode, the collection of data objects each only contains one string variable (name). What happened to the other string var (url) and both arrays (counts, breakdown)? what would cause this since it seems to becoming corrupt before it reaches the event handler but after it is received by the network? Is this most likely an IDE issue?

View 1 Replies

ActionScript 2.0 :: Way To Add Variables In An If Statement?

Jul 15, 2009

I'm about to start a game/quiz project where the user must click several buttons, one after another (though not in any special order) to answer a question:[code]Is this the right approach and way to add variables in an if statement?

View 1 Replies

ActionScript 3.0 :: Multiple Variables In A For Statement?

May 7, 2009

I'm trying to declare a few variables in a for statement using the variable in the for statement. In older flash versions I would use something like this.

Code:
for(a=0;a<10;a++) {
_root["variable"+a] = "Some text "+a;

[code].....

View 3 Replies

ActionScript 3.0 :: Checking Several Variables In An If Statement?

Sep 20, 2010

I've just been searching the internet for some code to check several variables in one big If Statement, I just wanted to double check here whether the code I found is correct! Is it right to type it like this?

[CODE].....

View 2 Replies

ActionScript 3.0 :: Declaring New Variables Within A Switch Statement?

Oct 10, 2009

does anyone know if declaring new variables within a switch statement (inside of case: break actually creates new variables inside those switch statements, or are the variable declarations moved to the top of the function when compiled?

i know that when declaring new variables inside a for or while loop, the compiler declares those variables at the beginning of the function. is it the same for if or switch statements?

View 3 Replies

Data Integration :: Checkbox Statement Using Variables

Aug 24, 2006

Using Component Inspector, I can control input dynamically. But I can't find a way to control checkboxes.

[Code]...

View 5 Replies

Action Script 3.0 :: Flash - IF Statement For Variables?

Mar 27, 2012

Im building a sample pad type instrument for a project, i have four channels for four different instruments the interface has four buttons to select the instrument, when the button is selected the image should be green but when another instrument is selected it should go to the second frame of the movie clip which is a red button to signal them instrument is off.

Line 23 i added a conditional statment for the variable associated with the channels it doesnt spit out any errors but also doesnt change the image when i click another button anyone know where im going wrong

//import flash stuff
import flash.events.MouseEvent;
import flash.display.MovieClip;

[code]....

View 2 Replies

ActionScript 3.0 :: Conditional Statement For Multiple Variables

Oct 27, 2009

I have a conditional statement (if) that I am trying to use contingent on multiple variables being true. So the AS I have right now is:

[Code]...

But when I run that I get the following error message: "Error 1050: Can not assign to a non reference value" What do I need to change so that once 1,2 and 3 have been visited visitComplete is set to true?

View 3 Replies

ActionScript 3.0 :: Run An If Statement Based On The A Variables Datatype?

Apr 7, 2009

I am trying to run an if statement based on the a variables datatype

var theArray:Array = ['element1','element2'}];
var theString:String = "I am string";
trace(gettype(theArray));
// In php gettype() is what I use to get the type. Is there a similar function in as3?

View 2 Replies

ActionScript 2.0 ::Variables In If Statement Change From Original Automatically?

Jan 23, 2005

I am having problems with the

getcoord = xycoordMap[x][y].split(":");
xcoord = getcoord[0].toString();
ycoord = getcoord[1].toString();
xcoord0 = xcoord + "";
ycoord0 = ycoord + "";

code... as you can see in the code I converted three times just to verify that I was working with strings. What happens if you run this script, the variables xcoord0 and ycoord0 magicly change in value when they are used in the IF statement (see the traces). What is going on?? what am I doing worng?? Is there an issue with my 2d Array?

[Code]....

View 3 Replies

ActionScript 3.0 :: Write The Conditional Statement For Two Variables That Could Have A Range Of Values?

Mar 24, 2010

I am attempting to create what I call an 'On Air' rotator for a radio station.  I would like to pull in an image file for each program when it is on air.  I have the following AS 3 code that seems to work:

var now = new Date();
var day = now.getDay(); // Returns integer between 0 and 6
var hour = now.getHours(); // Returns integer between 0 and 23

[Code].....

The weekday programming is the same every day.  We have some programs that are three hours in length.  I would like to cut down on the number of statements I write.  I am unsure how to  combine the weekdays and have a range of hours in one conditional statement.  Will the following work?

if (day >= 0 && day <= 4 && hour >= 6 && hour <= 10)

I'm attempting to express the condition "if the day is Monday through Friday and the hour 6 am to 10 am"

View 5 Replies

ActionScript 3.0 :: Flash Loaded Variables Breaks Switch Statement?

Jul 19, 2010

I've got a little script that scales a video to the stage. The scaleing function has a switch statement to indicate what kind of scaling to apply.If I declare the case value of the switch statement internally all is fine. However if I load this value from an XML doc, even though the trace indicated the value has loaded, the switch never fires.

Code:
/stage variables
var sH:Number;
var sW:Number;
var _contentHolder = new Sprite();

[code]....

View 2 Replies

ActionScript 2.0 :: Make A Simple SWITCH Statement With Button._name As Variables?

Jun 18, 2007

I want to make a simple SWITCH statement with Button._name as variables for CASE

so i got this code:

Code:
Button.addListener(_root);
_root.onRelease = function() {

[Code]....

View 2 Replies

ActionScript 2.0 :: Accessing Variables - If-statement Has Been Activated, _global.var1 Is Still 0 When I Trace It In Frame2?

May 25, 2004

I am making a jigzaw and when all the pieces are put in the right place, another movie clip will be played.All pieces are buttons placed in different movieclips. The movieclips are then placed in scene 1.

In frame 1, I've written
_global.var1=0;

In frame 2, I've put movieclip1, and in movieclip1 I've placed button1, with the following actionscript:

on (press) {
startDrag ("_root.movieclip1");
}[code]..........

However, when the piece is in the right place, and the if-statement has been activated, _global.var1 is still 0 when I trace it in frame2.

View 3 Replies

ActionScript 2.0 :: First Requirement Of The If Statement When Type In The Proper Input And Go Straight To The Else Statement

May 14, 2009

Having a few problems with what I thought was a simple if statement. Here is the code:

[Code]...

I can't quite figure out the small problem with the code. It seems to just bypass the first requirement of the if statement when I do type in the proper input and go straight to the else statement.

View 7 Replies

ActionScript 1/2 :: Execute Code In Previous If Statement If Second If Statement Is Executed?

Aug 31, 2011

if (variable == 1){
//code
//Execute this code.
} else if (variable == 2) {
//code

[Code]...
 
I dont want to copy the code from the first into the second and the first and second into the third.
 
My mind isn't working and there is probably an extremelly simple way to get this working.
 
I know I could used functions but for some reason it stops the instance referencing working: _root["bullet"+j] doesnt work in a function.

View 7 Replies

ActionScript 2.0 :: Loading Data From XMl File And Uses It To Run An If Statement. If Statement Fails?

Oct 10, 2008

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) {

[code]....

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.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved