Problem On Button Script (Statement Must Appear Within On Handler)
This is what I get in the output window: Statement must appear within on handler back_button.onRelease =function () { can anybody help on this? what is wrong?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 10-22-2003, 02:02 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dymanic Text Box Scroll With Button, Statement? Handler?
put your up_btn in, pull your up_btn out, put your up_btn in, then you shake it all about...
...and that's what it's all about.
i need help. really. I have up and down buttons. I have a dynamic text field with "scrollable" checked. I need the actionscript to make the buttons do their thing with the text.
let's say I have a dynamic text instance name of textytext_txt
let's say I have button intances of uppers_btn and downers_btn
what do I put where?
i have tried this two ways and niether of them are any good. One: trying to apply actionscript directly to the button. Two: applying actionscript to an actions layer.
i'd prefer to do this in the actions layer and let the buttons just do their thing without adding any script to them. possible?
also, can someone describe what the following are and how they are applied? 1. Statement 2. on handler 3. vaseline
hay thanks if y'all can help out a noob.
*s
Statement Must Appear Within On Handler
I'm trying to make a button that connects to a website, I've applied the get url handler to the button but 'statement must appear within on handler' is the output i keep getting.
I don't know hoe to phrase it to put it into the handler. Could anyone please help?
Statement Must Appear Within On Handler?
Ok i have a small problem with this. I'm trying to make a play button which i've done before, but for some reason it isnt working. The error i'm getting is:
**Error** Scene=Scene 1, layer=Button, frame=1:Line 3: Statement must appear within on handler
py_btn.onRelease = function (){
Also this is probably important, but my scripting is:
code: py_btn.onRelease = function (){
gotoAndPlay("", 1);
};
I've tried coping and pasting the script from a program that has a working play button in it. Just so this doesn't come up later. Yes i did change the instance name.
I'm also using flash 8 and AS 2.0
I really do not know whats wrong right now. It hsa worked in the past i'm a bit confused now. Any help would be Appreciated. Thanks.
Why Always Statement Must Appear Within On Handler
appears in my output window ???
I try to give 2 functions to button : 1 to animate it 2 to play an external swf...
Here is a part of the code :
on (rollOver) {
_root.mouse_over_picture1 = true;
}
on (rollOut) {
if (_root.currMovie == undefined) {
_root.mouse_over_picture1 = fstartlse;
}
_root.currMovie = "myportfolio";
container.loadMovie("myportfolio.swf");
}
if (_root.currMovie != "myportfolio")
if (container._currentframe >= container.midframe) {
_root.currMovie = "myportfolio";
container.play();
}
THANKS
Statement Must Appear Within On/onClipEvent Handler
Statement must appear within on/onClipEvent handler
This is the error I get when trying to utilize Flash 6's movie clip event properties... my code that I place on a movie clip:
this.onRollOver = function () {
this.over = true;
}
this.onRollOut = function () {
this.over = false;
}
"over" is a variable, obviously. Shouldn't this work?
[F8] Statement Must Appear Within On/onClipEvent Handler
I am very new to Flash and am taking a class on line. I am working with a reflection and have named my instances reflections, and set bitmap caching.
I am using a text book, and following the steps and still get this error.
Any suggestions?
This what I am entering in action-forms
**Error** Scene=Scene 1, layer=reflection, frame=1:Line 1: Statement must appear within on/onClipEvent handler
refection.setMask(mask);
Total ActionScript Errors: 1 Reported Errors: 1
Statement Must Appear Within On/onClipEvent Handler
Hi,
i am running actionscript in flash cs3 and i am getting this error message
Code:
Statement must appear within on/onClipEvent handler
can anybody help please?
the actionscript i am running is
Code:
onEnterFrame = function(){
f.onRollOver = function(){
f.stop();
}
f.onRollOut = function(){
f.play();
}
}
Thanks a lot in advance
Statement Must Appear Within On/onClipEvent Handler
Hello. I have an MP3 player built into my presentation but when I go to test my movie the following 3 AS errors come up. My code is below as well. Could someone assist me in finding out where my problem is?
Thank you very much for any guidence. :)
**Error** Screen=presentation, layer=bg overlay lines, frame=1:Line 1: Statement must appear within on/onClipEvent handler
volumeDragging = false;
**Error** Screen=presentation, layer=bg overlay lines, frame=1:Line 2: Statement must appear within on/onClipEvent handler
function playNewSong() {
**Error** Screen=presentation, layer=bg overlay lines, frame=1:Line 16: Statement must appear within on/onClipEvent handler
mp3Player.onLoad = playNewSong();
Total ActionScript Errors: 3 Reported Errors: 3
volumeDragging = false;
function playNewSong() {
clearInterval(soundDuration);
mp3Player.mySound.position = 0;
mp3Player.mySound.duration = 0;
mp3Player.progressBar._width = 0;
mp3Player.mySound = new Sound();
mp3Player.mySound.onSoundComplete = playNewSong;
randomSound = random(4)+1;
mp3Player.mySound.loadSound("bgSound"+randomSound+".mp3", 1);
soundDuration = setInterval(durSong, 1000);
function durSong() {
mp3Player.progressBar._width = Math.round((mp3Player.mySound.position/mp3Player.mySound.duration)*31);
}
}
mp3Player.onLoad = playNewSong();
Statement Must Appear Within On/onClipEvent Handler
Here's my code on my main timeline; and it makes each movie clip (A, B, C, D, E) 'glow' when mousing-over.
Why do I keep getting this error message?
Thanks
Attach Code
stop();
import flash.filters.GlowFilter;
ar = [A, B, C, D, E];
for (var z = 0; z<ar.length; z++) {
ar[z].onRollOver = rollover;
ar[z].onRollOut = rollout;
ar[z].onRelease = release;
}
function rollover() {
this.swapDepths(0);
this.filters = [new GlowFilter(0x666666, .50, 7, 7)];
}
function rollout() {
this.filters = null;
}
Statement Must Appear Within On/onClipEvent Handler
Funny, in one swf this comes out as "this script contains no errors".
In another swf, it's endless "Statement must appear within on/onClipEvent handler" error messages. Anyone want to take a stab at as to why?
Quote:
this.onEnterFrame = function(){
this._parent.container_mc.myTextFieldInstance.html = true;
if(rewind == true){
prevFrame();
}
}
this.onRollOver = function(){
this._parent.attachMovie("bigPeacock","this._paren t.picbox_mc", 1);
this._parent.container_mc.myTextFieldInstance.text = "About Us, Contact us";
rewind = false;
play();
}
this.onRollOut = function(){
this._parent.attachMovie("clear","this._parent.pic box_mc", 1);
rewind = true;
_parent.container_mc.myTextFieldInstance.text = " "
}
this.onRelease = function(){
gotoandplay(50);
}
stop();
Statement Must Appear Within On/onClipEvent Handler
Hi Guys, I'm creating a site with a vertical scroll xml photo gallery. When i run it I get the following errors would anyone be able to help
Quote:
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 2: Statement must appear within on/onClipEvent handler
function loadXML(loaded){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 20: Statement must appear within on/onClipEvent handler
xmlData = new XML();
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 21: Statement must appear within on/onClipEvent handler
xmlData.ignoreWhite = true;
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 22: Statement must appear within on/onClipEvent handler
xmlData.onLoad = loadXML;
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 23: Statement must appear within on/onClipEvent handler
xmlData.load("images.xml");
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 26: Statement must appear within on/onClipEvent handler
previous_btn.onRelease = function(){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 29: Statement must appear within on/onClipEvent handler
next_btn.onRelease = function (){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 34: Statement must appear within on/onClipEvent handler
p=0
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 35: Statement must appear within on/onClipEvent handler
this.onEnterFrame = function(){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 48: Statement must appear within on/onClipEvent handler
function nextImage(){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 59: Statement must appear within on/onClipEvent handler
function prevImage(){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 68: Statement must appear within on/onClipEvent handler
function firstImage(){
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 76: Statement must appear within on/onClipEvent handler
function picture_num(){
My Code is
Quote:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//Preloader
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
//nextimage function
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
//Previous Image funtion
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[1], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 7;
tscroller.onEnterFrame = function() {
if ((_root._xmouse >= thumbnail_mc._x ) && (_root._xmouse <= thumbnail_mc._x + thumbnail_mc._width)) {
if ((_root._ymouse>=(hit_down._y - 20)) && (thumbnail_mc.hitTest(hit_down))) {
thumbnail_mc._y -= scroll_speed;
} else if ((_root._ymouse<= 120) && (thumbnail_mc.hitTest(hit_up))) {
thumbnail_mc._y += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._y =(target_mc._height + 2)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
It would be awesome if someone could help me out thanks
Statement Must Appear Within On/onClipEvent Handler Error
I have the following on a movie clip:
onClipEvent (load) {
btn1_btn.onRollOver = function() {
myScreen_mc.gotoAndPlay(2);
};
}
onClipEvent (load) {
btn1_btn.onRollOut = function() {
myScreen_mc.gotoAndPlay(1);
};
}
btn1_btn.onPress = function() {
getURL("index.html");
};
onClipEvent (load) {
btn2_btn.onRollOver = function() {
myScreen_mc.gotoAndPlay(6);
};
}
onClipEvent (load) {
btn2_btn.onRollOut = function() {
myScreen_mc.gotoAndPlay(1);
};
}
btn2_btn.onPress = function() {
getURL("index.html");
};
onClipEvent (load) {
btn3_btn.onRollOver = function() {
myScreen_mc.gotoAndPlay(12);
};
}
onClipEvent (load) {
btn3_btn.onRollOut = function() {
myScreen_mc.gotoAndPlay(1);
};
}
btn3_btn.onPress = function() {
getURL("index.html");
};
onClipEvent (load) {
btn4_btn.onRollOver = function() {
myScreen_mc.gotoAndPlay(18);
};
}
onClipEvent (load) {
btn4_btn.onRollOut = function() {
myScreen_mc.gotoAndPlay(1);
};
}
btn4_btn.onPress = function() {
getURL("index.html");
};
onClipEvent (load) {
btn5_btn.onRollOver = function() {
myScreen_mc.gotoAndPlay(24);
};
}
onClipEvent (load) {
btn5_btn.onRollOut = function() {
myScreen_mc.gotoAndPlay(1);
};
}
btn5_btn.onPress = function() {
getURL("index.html");
};
and it gives the following error when running:
Scene=Scene 1, Layer=Layer 9, Frame=1: Line 12: Statement must appear within on/onClipEvent handler
btn1_btn.onPress = function() {
Scene=Scene 1, Layer=Layer 9, Frame=1: Line 26: Statement must appear within on/onClipEvent handler
btn2_btn.onPress = function() {
Scene=Scene 1, Layer=Layer 9, Frame=1: Line 40: Statement must appear within on/onClipEvent handler
btn3_btn.onPress = function() {
Scene=Scene 1, Layer=Layer 9, Frame=1: Line 54: Statement must appear within on/onClipEvent handler
btn4_btn.onPress = function() {
Scene=Scene 1, Layer=Layer 9, Frame=1: Line 68: Statement must appear within on/onClipEvent handler
btn5_btn.onPress = function() {
can someone help me pls
Error: Statement Must Appear Within On/onClipEvent Handler
I'm getting this error Scene=Scene1, Layer=Layer 3, frame=1, Line1
Statement must appear within on/onClipEvent handler
shape.swapDepths(_root.getNextHighestDepth());
i'm using this code:
shape.swapDepths(_root.getNextHighestDepth());
//shape is a movie clip
stop();
this.attachMovie('bcPlayer','bcPlayerInstance',this.getNextHighestDepth());
//bcPlayerInstance._xscale = 75;
//bcPlayerInstance._yscale = 75;
bcPlayerInstance._y = -50;
bcPlayerInstance._x = -5;
//bcPlayerInstance is a movie clip
please help anyone knows what i'm doing wrong
Error: Statement Must Appear Within On/onClipEvent Handler
[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) {
this._yscale += 10;
}
}
function shrink() {
if (this._yscale > 100) {
this._yscale -= 10;
}
}
function doRollOver() {
if (this != activebtn) {
this.onEnterFrame = grow;
}
}
function doRollOut() {
if (this != activebtn) {
this.onEnterFrame = shrink;
}
}
function doClick() {
activebtn.onEnterFrame = shrink;
delete this.onEnterFrame;
this._yscale = 200;
activebtn = this;
}
function init() {
for (var mc in groupinfo) {
groupinfo[mc].onRollOver = doRollOver;
groupinfo[mc].onRollOut = doRollOut;
groupinfo[mc].onRelease = doClick;
}
}
init();
Any ideas?
What Does It Meen When It Says "Statement Must Appear Within On/onclipevent Handler?
**Error** Scene=seperate, layer=Layer 21, frame=15:Line 1: Statement must appear within on/onClipEvent handler
stop();
**Error** Scene=knowledge, layer=Layer 5, frame=1:Line 1: Statement must appear within on/onClipEvent handler
stop();
whats up with that, what does it meen when it says "Statement must appear within on/onclipevent handler?
Error: "Statement Must Appear Within On Handler"
I created some text and converted it into a Button symbol.
When the button is pressed this ActionScript should execute to open a JavaScript launched popup window in a browser.
Code:
var jscommand:String = "window.open('http://www.adobe.com','win','height=200,width=300,toolbar=no,scrollbars=yes');";
getURL("javascript:" + jscommand + " void(0);");
When compiling the SWF, I get the Error: "Statement must appear within on handler"
I get this error for both the first and second line of code.
ANy ideas?
"statement Must Appear Within On Handler"?
Hello, all...
I'm trying to build the simple sound control from the Flash MX help, but the thing isn't working at all. I've attached the ActionScript I'm using.
Here's the output I'm getting:
"
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on handler
_root.speaker.stop();
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Statement must appear within on handler
song = new Sound();
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 3: Statement must appear within on handler
song.attachSound("beck_loser");
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 4: Statement must appear within on handler
_root.playButton.onRelease - function() {
"
Sorry, but I'm stumped and I know this is a friggin' simple thing to make work. Any suggestions?
Thanks in advance.
Button OnRelease Handler From Xml
I have a menu that is generated dynamicaly from an XML-file. But I have a problem with assigning eventHandlers to the buttons dynamically.
here's the code:
Code:
...
var SubItems = xmlDoc.childNodes[0]
...
for (var j = 0; j <= SubItems[i].childNodes.length - 1; j++)
{
duplicateMovieClip('subItem', 'subItem' + j, 20+j);
newSubMc = this['subItem' + j];
newSubMc._x = intSubX+5;
newSubMc._y = intSubY+ 17.3*j;
//set the text
newSubMc.subItem = SubItems[i].childNodes[j].firstChild.nodeValue;
//set the action for the button
newSubMc.subItemBut.onRelease = function () {SubItems[i].childNodes[j].attributes.action }
}
the weird thing is that trace(SubItems[i].childNodes[j].attributes.action) returns: _root.canvas.remove();,
so the node is actually being read into flash.
If I replace SubItems[i].childNodes[j].attributes.action with something like _root.textVar = 'test' it also works.
But when I use the xml node it just doesn't...
Anyone?
Button Handler Never Runs
I currently have a new button that seems okay (over behavior shows correctly), but the .onRelease handler never hits a breakpoint on the first statement. I tried the following experiment on an old working button and I can't understand what I observed. The working button is defined on the whole timeline, i.e., it appears on frame 1 in a layer that has keyframes only on frame 1 and the last frame. The button handler is in Active Script on frame 1 in a separate actions layer. The script applies for the whole timeline too. Now if I take frame 1 of the buttons layer and move it to frame 5 so the button does not appear until frame 5, geez, the button handler never runs. What is happening?
I tried the above experiment cuz the new button I can't get to work does not appear at frame 1, even though its handler is in that script that is on frame 1 (like the documentation tells you to do - gather up all your code into a single program on frame 1 in an actions layer.) However, making this new button start on frame 1 (by moving its starting frame back to 1) did not make it work.
Another property of my non-working button is that it is in a layer folder. Moving this layer out of the folder made it work. Is there some restriction that buttons can't be in a layer folder - I'm using Action Script 2?
Button Event Handler?
ok, i'm having some trouble setting up the links in my flash file.
this works:
Code:
// profile
profile.btn.onRollOver = function() {
profile.gotoAndPlay(1);
}
this doesn't:
Code:
function rollUp(item) {
item.gotoAndPlay(1);
}
profile.btn.onRollOver = rollUp(profile);
i'm not really sure what's up. i've taught myself actionscript just by messing around with different ideas, but the function is so simple i'm thinking it has to do with how i'm trying to trigger it?
i want to use the rollUp function because all the buttons have the same rollover effect and if i ever change the frame count, i'll only have to update the rollUp/rollDown numbers once instead of each button's onRollOver and onRollOut.
Execute Several Statements Within One Button Handler?
Hi,
On click of a button, test.swf should load in the flashplayer and the x- and y-position of the mc "window" (which is situated in test.swf) should be set to 120 and 230.
I tried this:
on (release) {
loadMovieNum ("test.swf", 6);
_root._level6.window._x = 120;
_root._level6.window._y = 230;
}
test.swf is loading into level 6 but the window mc on test.swf doesn't change it's position.
It seems that flash cannot refer to a movie that has been just loaded in the player within the same Event Handler.
Does anyone know what to do about that?
Thanks!
mink
Button Inside Movieclip With Handler - What To Do?
Hi,
I have a movieclip button with animation on mouse over and mouse out, and with buttons/links appearing when you do mouse over. As I got a handler on the movieclip, the buttons in the movieclip don't respond. I guess I'm supposed to use hitTest or something like that, but how do I do it? I want to achieve the same effect as the buttons on this website:
http://www.gimlet.se
Thanks for your help!
Button Event Handler Won't Work?
I'm trying to create a dynamically generated (duplicateMovieClip) menu system. I load thumbnail images from a text file into each duplicated copy but as soon as I load the images all of the other properties and variables of the clip disappear.
Is there a way around this? Also I can't get the button event handler to work on the duplicated clips. Any suggestions?
messageURL = _root.login + ".txt"
setUpMenus = function() {
counter=1
while (typeof(myNavVars["photo"+counter]) == "string") {
if (counter>1) {
duplicateMovieClip(thumb1, "thumb"+counter,counter)
this["thumb"+counter]._x = this["thumb"+(counter-1)]._x + 110
}
loadMovie(myNavVars["photo"+counter]+".jpg", this["thumb"+counter])
this["thumb"+counter].slideNum = myNavVars["photo"+counter]
this["thumb"+counter].contentFile = myNavVars["photo"+counter]+".jpg"
this["thumb"+counter].onRelease = function () {
_root.imageNum = this.slideNum
loadMovie(this.contentFile, _root.imgHolder)
}
counter++
}
}
myNavVars = new loadVars()
myNavVars.onLoad = function() {
_root.menu.menu.setUpMenus()
}
myNavVars.load(messageURL)
Change Handler Event On Button
Hi there,
I am newbie with flash and actionscript. According to a tutorial, I started with on creating a simple quiz. I realized the tutorial was in coded in Flash MX and I use the Flash 8 version.
I am trying to add a change handler on a button. The tutorial says, I need to add the value in the Parameters, but unfortunately the Flash 8, does not have Change Handler. Is there another way to get around it? How would I script a handler on the button?
Here's the code I have on my 'Start Quiz' button, there are no errors but it doesnt do anything.
on (change) {
trace(startQuiz);
}
Thanks!
Define Button Handler For Movie Clip
In my movie I create a dynamic menu using the "attachMovie" method. Now I need to add a button handler for each of the buttons I have added. I am not sure how to do this. So I could use some help. Below is my code for attaching the movieclip.
Hmm.... I am not sure whats up, it doesn't appear to be posting all my code...
Code:
//////////////////////////// START FUNCTION INFO ////////////////////////////////
function info(myVar) {
MyLoadVars = new LoadVars();
MyLoadVars.load("CdTypes/"+myVar+"Campaign.txt");
//////////////////////// LOAD MENU NAMES ///////////////////////////////////////////////////////
MyLoadVars.onLoad = function(success) {
if (success) {
var labels_array = new array();
// create an empty array
///////////////////// LOAD MENU OPTIONS ////////////////////////////////
if (this.MakeoverOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("WEB SITE MAKEOVER");
}
trace(labels_array[0]);
/////////////////////////////////////////////////////////////////////////////////
if (this.WildCardOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("WILD CARD");
}
trace(labels_array[1]);
//////////////////////////////////////////////////////////////////////////////////
if (this.BusinessToolsOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("WEB BUSINESS TOOLS");
}
trace(labels_array[2]);
//////////////////////////////////////////////////////////////////////////////////////
if (this.WebTrainingOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("WEB AND CD TRAINING");
}
trace(labels_array[3]);
///////////////////////////////////////////////////////////////////////////////////////
if (this.MarketingOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("INTERNET MARKETING");
}
trace(labels_array[4]);
/////////////////////////////////////////////////////////////////
if (this.WebHostingOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("WEB SITE HOSTING");
}
trace(labels_array[5]);
/////////////////////////////////////////////////////////////////
if (this.CardOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("THE 1:1 CARD");
}
trace(labels_array[6]);
/////////////////////////////////////////////////////////////////////
if (this.newsOn0 == 0) {
//make button inactive; don't attach movie clip
} else {
//make button active
labels_array.push("NEWS");
}
trace(labels_array[7]);
///////////////////////////////////////////////////////////////////
labels_array.push("CONCLUSION");
trace(labels_array[8]);
//////////////////////////////////////////////////////////////////////
labels_array.push("HOME");
trace(labels_array[9]);
///////////////////////////////////////////////////////////////////////
// loops for each item found in "labels_array", attaches "btnMC" from the library,
// populates "tf" with the values and places the mc's below each other
for (var i = 0; i<labels_array.length; i++) {
_root.attachMovie("btnMC", "btn_"+i, i);
with (_root["btn_"+i]) {
tf.text = labels_array[i];
_y = _height*i;
}
}
} else {
// someTextField displays that the text file couldn't load. duh... :)
//someTextField.text = "Text file could not be loaded!";
}
};
}
A Minor Button Event Handler Problem
Salam friends,
I,ve a problem concerning button event handlers.
There,re six buttons on the stage i.e main timeline's first frame.I,ve to controll two movieclip instances via these buttons.
On frame one of my actions layer I,m inserting this code to control movieclips via button instances.
first_btn.onRelease = function() {
first_mc.run();
};
When I test my movie this error displays:
"**Error** Scene=Scene 1, layer=Assets, frame=1:Line 7: Statement must appear within on/onClipEvent handler
first_btn.onRelease = function() {
"
It,s strange that my movie,s working as expectedly.I,m confused about error messages dislayed in the output panel.
Any help from any actionscript 'guru' would be a great obligation.Thanks.
Overriding Button Event Handler Method
Hi all. New to Actionscript here (I'm using Flash Professional 8 on a Mac, and ActionScript 2.0).
I've got several buttons on the stage (instance names man_btn, tree_btn, dog_btn) and I'm explicitly overriding each button instance's event handler as follows (this code is in frame 1 of my "Actions" layer):
// Rollover animations
man_btn.onRollOver = function() {
playRollOver(this);
}
tree_btn.onRollOver = function() {
playRollOver(this);
}
dog_btn.onRollOver = function() {
playRollOver(this);
}
As you can see, the same rollover behaviour is being applied to all 3 buttons. This code works but it's obviously written poorly as I'm repeating code. I'd like to know how to rewrite the above code such that I can define this rollover behaviour once, and have it applied to all 3 buttons, without explicitly defining this behaviour for each button instance. I'm guessing I should be creating a class of some sort that extends the Button class, and then I override that subclass's onRollOver function, and make my 3 button symbols from this class?
Please note that man_btn, tree_btn and dog_btn are instances of 3 *different* button symbols that I have defined using Flash 8's visual tools (as opposed to me creating them through ActionScript code).
Thanks in advance for any assistance - it would be much appreciated.
BTW this is my first post to this forum so I hope I have provided all the necessary info.
Cheers! :-)
Risko.
Button Event Handler Newb Question
Hi,
I am having a trouble with th basic understanding of button event handling
A very simple scenario is:
create a new file.
create two layer named ACTIONS and Button.
on the ACTIONS frame 1 add code:
myButton.onRelease = function() {
trace("myButton has been clicked");
}
on the Button layer in frame 5, drop in button instance with an instance name myButton.
now i am confused why this simple thing isnt working
without having to rely on using the older on(release) syntax on the button itself.
thanks for any help!
~mark
Assigning Event Handler Code To Button Instances
Hi
I'm trying to assign separate code to each instance of a button that I am attaching to a movie.
I'm going along the lines of:
code:
largeimgurl = "photos/large" + thumbfilename[i];
hots = "hotspot" + thumbnumber;
this["thumbnailholder" + thumbnumber].attachMovie("hotspot",hots,this["thumbnailholder" + thumbnumber].getNextHighestDepth()); //attach button
this["thumbnailholder" + thumbnumber][hots].onRelease = function()
{
_root.mainImage.loadMovie(largeimgurl);
}
The above code is in a loop. However, it doesn't seem to be working - e.g. when I test the movie the same image loads in mainImage no matter what button I click. Thanks for your help.
Class File+ Button Event Handler+ Im Stuck
Hi.
I've got a function in my fla file that creates a button for each item in an array ["mics1", "mics2" etc...]
I wanted the onRelease of each button to attach a specific movie clip to the stage (mics1_btn attaches mics1_mc, mics2_btn = attaches mics2_mc etc..)
In the for loop of my fla I have:
var pressy:PressButton = new PressButton(this[b+"_btn"], b);
where b is the result from the array. Then my class file looks like this:
class PressButton extends MovieClip {
function PressButton(aButton, prefix) {
aButton.onPress = function() {
trace(prefix);
this.attachMovie(prefix+"_mc", prefix+"_mc", this.getNextHighestDepth());
};
}
}
The class file works and my trace brings up the correct prefix, however, the movie clip does not attach. Is this the wrong way to do it or is it just not possible?
Please help cos my brain cant take it anymore...
Event Handler Works With Button, But Not Movie Clip...why?
So I am trying to get my head around event Listeners. When I use this example on a button it works fine:
but when I add the same listener to a movie Clip on the stage with an instance name of "box", it does not work. Is there something basic I am missing?
Attach Code
var buttonListener:Object = new Object();
buttonListener.click = function(eventObj:Object) {
trace("click");
};
mybutton.addEventListener("click", buttonListener);
Convert Button Event Code To A Function AND 'if,then,else' Statement On A Button Even
mac os X
flash mx 2004
Hi
Can anyone please help me convert the following code from a button event into a function:
on (press) {
paypal = new LoadVars();
paypal.cmd="_cart";
paypal.item_number= myVB2;
paypal.item_name= mvVB;
paypal.upload="1";
paypal.business="ady@atinybitofgod.com";
paypal.currency_code="USD";
paypal.amount= myVB3;
//paypal.handling ="2.00";
paypal.send("https://www.paypal.com/cart/add=","_blank","post");
}
My plan is to have 5 of these (obviously named differently and with slightly diff. values for the variables) and then on a single button's (press) i will have an 'if,then,else' statement, which will call one of these 5 functions depending on the value of another variable in my movie.
is this possible??? I have been spending 2 weeks now posting on numerous threads trying to find a workaround for a different problem, with no joy..so the above is my *hopeful* solution... please ask me if i haven't explained anything clearly enough.....
Thanks so much for your time and any help you might be able to offer...
kindly with crossed fingers,
Cheska
(ps...if you want to try and help my initial problem, you can visit http://www.atinybitofgod.com/kids/paypal.html and see all my code and my swf and the rror i get from paypal when i try to send three variables that reference other variables in my movie.....BUT...since i have had no joy and think that ive tried most peoples suggestions, i'd really like to try to figure out this new 'function' and 'if then else' thing on my button...if that's even possible).
Designer Tries Code - Needs Basic Help (a Multiple Button Event Handler Function)
I know this is most inelegant and I'm wondering if there is an easy way to clean this up rather than repeating it 12 times. These are invisible buttons controlling movieclips underneath.
How would I write a function that would take care of all of them, given that the instance names of each object contains the same numeral within each set of methods?
(A fair number of eyes roll skyward about now - I'm a newb)
// button event handler methods
//------------
if (b1_mc._currentframe<4) {
b1_btn.onRelease = function() {
_root.gotoAndPlay("s1");
};
b1_btn.onPress = function() {
b1_mc.gotoAndStop(3);
};
b1_btn.onRollOut = function() {
b1_mc.gotoAndStop(1);
};
b1_btn.onRollOver = function() {
b1_mc.gotoAndStop(2);
};
}
//------------
if (b2_mc._currentframe<4) {
b2_btn.onRelease = function() {
_root.gotoAndPlay("s2");
};
b2_btn.onPress = function() {
b2_mc.gotoAndStop(3);
};
b2_btn.onRollOut = function() {
b2_mc.gotoAndStop(1);
};
b2_btn.onRollOver = function() {
b2_mc.gotoAndStop(2);
};
}
//------------
if (b3_mc._currentframe<4) {
b3_btn.onRelease = function() {
_root.gotoAndPlay("s3");
};
b3_btn.onPress = function() {
b3_mc.gotoAndStop(3);
};
b3_btn.onRollOut = function() {
b3_mc.gotoAndStop(1);
};
b3_btn.onRollOver = function() {
b3_mc.gotoAndStop(2);
};
}
//------------
if (b4_mc._currentframe<4) {
b4_btn.onRelease = function() {
_root.gotoAndPlay("s4");
};
b4_btn.onPress = function() {
b4_mc.gotoAndStop(3);
};
b4_btn.onRollOut = function() {
b4_mc.gotoAndStop(1);
};
b4_btn.onRollOver = function() {
b4_mc.gotoAndStop(2);
};
}
//------------ etc....
IF Statement On Button
IF statement on button
hello,
i have a movie clip like this:
frame 1 - stop
frame 2-5 - fade in menu
frame 5 stop
frame 6 - show text A, stop
frame 7 - show text B, stop
etc, etc
frame 50-60 - fade out
my buttons:
BUTTON1:
on(rollover)
{
_root.mc1.gotoAndplay(2);
}
on(rollout)
{
_root.mc1.gotoAndplay(50);
}
BUTTON2:
on(rollover)
{
_root.mc1.gotoAndplay(10);
}
on(rollout)
{
_root.mc1.gotoAndplay(50);
}
how can i do an IF statement that says "wait a few frames to see if the person is mousing over the second button, if so, don't do fade out, go to appropriate frame (of Text) for that button.
hope that's clear enough ! thanks in advance
Help On An If/then Statement On Button
Hi:
I am on a deadline for Monday morning and I just can't seem to figure this out. I am doing a coloring book that has a hyperfiction story with it. The idea is that when one part of the coloring book is colored one of 2 given colors, then it will go to the scene that corresponds with that color. I have the "fill zone" of the image set as a button inside of a movie clip (it was done by a tutorial for a setRGB coloring book). Here is the actionscript I have so far:
on (press) {
color = new Color(this);
color.setRGB(_root.fillColor);
delete color;
}
on (release) {
if (_root.fillColor == 0x000066) {
gotoAndPlay("evil_witch");
} else if (_root.fillColor == 0x003300) {
gotoAndPlay("wolf");
}
}
I have tried everything on the on (release) code to make it register. But, my question, i guess, is that I have a color being chosen by clicking on a "color button" then clicking on a "fill button" with the desired color. Are there any suggestions as to how to script this and make it work? the "evil_witch" is an instance name of another frame.
Thank you in advance for your help!
MC As Button And If Statement
I´m using a MC as a button with "if" statement to determine where the movie should play next but it´s not working.
don´t know what I´m doing wrong.
Thanks for any help
Here is the fla.
If Statement For One Button Use
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?
If/Else Statement On A Button
I have a movie instance in my frame which I named 'helpmenu'. I tried to make code that would allow a user to control the visibility of the menu. I'm able to get the menu to disappear by pressing 'h', but I can't seem to figure out how to make it reappear. I placed the coding for this action on the X box in the top right corner since the keypress function only works on a button:
-------------------------------------------------
on (keyPress "h") {
if ("0") {
setProperty (helpmenu, _alpha, "100");
} else {
setProperty (helpmenu, _alpha, "0");
}
}
-------------------------------------------------
Here is the current version of the file with the above code at work:
http://members.aol.com/Carddass/movie1.swf
I can't tell if it's a syntax problem or just the wrong coding altogether. I tried following a tutorial that explained if/else statements, but I couldn't seem to get it to work for my particular case. Maybe it needs a Variables? Thanks in advance!
-Cardy
Button, Radio Button And If Statement
I'm using actionscript 2 for this. I've got a button named submitButton and two radio buttons. The instance names of the radio buttons are Predefined and Custom. I want to be able to send a user to a frame named custom if Custom is checked and to a frame named predefined if Predefined is checked. Because I followed a tutorial found on this site I also got a textarea. Later I will remove that textarea but I found it good to see whether the radio buttons sent the correct information or not. This is the code i'm using:
// save a reference to the timeline that contains the form
myForm = this;
// create a listener object for the submit button
submitButtonListener = new Object();
// submit button listener, click handler method
submitButtonListener.click = function ()
{
// find the selected radio button in the group
var selectedRadioButton = dicegroup.selection;
// store the label of the selected radio button
var selectedRadioButtonLabel = selectedRadioButton.label;
// compose and display the message
statusMessage.text = "You are " + selectedRadioButtonLabel;
}
// make the submit button listener listen for click events
submitButton.addEventListener("click", submitButtonListener);
if (selectedRadioButtonLabel==Predefined) {
this.gotoAndStop("predefined");
}
else if(selectedRadioButtonLabel==Custom){
this.gotoAndStop("custom");
}
I've been trying for about 13 hours now so all help would be much appreciated.
If Statement To Create Button? Or Something Like That
hi i was wonderin if there is any if statement that could tell if the mouse was positioned within a movie clips height and width, like a rolover for a button. I would use a button but I have a button beneath a button on a lower layer and that causes probs. If not is there any way 2 disable a button thru actionscript without placing it in a movie and settind it to invisible?
thanx
If/Else Statement On A Button, Else Not Working
Hey all, once again another very simple problem which has the potential to drive me completely loopy!!
Here's the code
PHP Code:
on(release){
if(mainBulk.one.frame==1){
mainBulk.one.gotoAndPlay(1);
lineOne.gotoAndPlay(16);
lineOne._visible=false;
}else{
mainBulk.one.gotoAndPlay(16);
lineOne._visible=true;
}
}
Basically (I know its bad practise to put the code on the button but it's just what I've done this time around) the if statement seems to work absolutely fine, but for some reason the else statement doesnt work!! I even tried it with else if, but still that doesnt work!! Any ideas?
Cheers
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...
Two Actions For Button/if Statement Help?
Hi. First post. Pretty new to as. Not sure if this should be in the beginner section so apologies in advance if this is a tired subject. I have looked over countless tutorials to no avail. This seems like it should be really easy but am having trouble locating anything definitive.
So here we go...
I have a button in an swf that, when clicked, goes to a frame label in a separate swf. This frame label has code that controls loading the external swf's into a container. What I am trying to achieve is having all the swf's work like an internet browser with the buttons in the loaded swfs. Forward/backwards/etc.
Here's the code on my forward button:
on (release) {
_root.site_mc.gotoAndPlay("home");
}
This loads the next swf in the sequence. Now what I want to do - from this swf "home", I want to be able to click it's back button and go to the previous swf, but, at the last section (marked with a frame label) instead of frame 1.
So basically I need something like this, but, have no idea how.
on (release) {
_root.site_mc.gotoAndPlay("task.swf/framelabel=part3);
Thanks to anyone who can give me some help/ideas.
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.
Sound Button If/Else Statement..
Hey All!
I'm having a problem with a stop/play button. Basically as the site opens, sound starts playing; but should the user decide to stop the sound, I've made a button for that.
But I want the same button to be able to start the music again, if it is stopped.
(It's basically a movieclip-button, with some animation.)
So, I actually want the same button to perform two separate commands.
So I was thinking in terms of an if/else statement. But I don't know how to set it up.
Any help would be appreciated.
Here's my code:
stop();
mySound = new Sound();
mySound.loadSound("Loop1.mp3", true);
mySound.onSoundComplete = function() {
mySound.start(0, 999);
}
if (mySound.loadSound("Loop1.mp3", true)) {
this.Sound_btn.onRelease = function() {
mySound.stop();
Sound_btn.gotoAndPlay("_stop");
} } else {
this.Sound_btn.onRelease = function() {
mySound.start(0, 999);
Sound_btn.gotoAndPlay("_play");
}
}
But, as you might've figured out, the "if statement" doesn't work, so it skips right to "Else" gotoAndPlay("_play"); And starts the sound from the beginning.
What I'm basically looking for, is an if statement that tells Flash if the music is playing or not. I thought it could be accomplished by using the loadSound/isStreaming statement in the if variable, but obviously that would also cause problems if the sound had already been loaded.
I've searched this forum for posts with the same issue, but I couldn't find any answers to this question.
I hope someone can help me out.
Thank you.
Stig
Flash If Else Button Statement
Hello everyone
Despite using Flash for a couple of years now I am still a relative newbie to Actionscript 2.0.
I 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;
} else (xpos = -396){
trig.xposnew = -627;
}
}
however when I click the button nothing happens
Thanking everyone in advance for their help
Cameron
Making A Button Tell What Mc It Is On To Do An IF Statement....ITS SIMPLE I JUST CANT
i have a background that tweens up on a click of 5 different buttons.....(so i have 5 backgrounds respectfully)
the problem i have is that i dont want the background im on to just bleep of and the second start to tween up....
i want the backgound im on to tween down and then have the backgound that i just clicked on the tween up....
it sounds really simple, but i just cant think right now...
thanks for helping....
IF Statement In A Button / Jumpin Scenes
If any1 out there can help you have no idea how much i would appreciate it. My problem is gettin the game to jump to the correct scene, as i have a button and once clicked it should jump to either scene 5 or 6 depending which option the user has chosen from the menu. Only problem being at the moment it is not following the if statement and jumpin striaght to scene 6.
Ive uploaded part of the files here as the whole program is quite big.The part of the file im having problems with is in SCENE 2.
I just need the "click here to play game" button to work (i.e. jump to the correct scene)
cheers
x
CoopZ
|