Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Question About A Function And Buttons



Hey everybody :-)

I have a little question regarding a clip I'm doing.
I'll simplify the whole thing just to make it easier for everybody
to understand what I'm asking.

I made 3 buttons, and in I wrote this code to make each button
pop up a trace message with the text "okay"


MC3.onRelease = function():Void{
trace("okay");
}

MC_button2.onRelease = function():Void{
trace("okay");
}

button1.onRelease = function():Void{
trace("okay");
}


and its working great, B-U-T what I want to do is to write a function that inside it I'll write the code and the function (using parameters) will know which button I clicked.

so I wrote this code:
(I wrote it as an example for clicking on MC3 button)


Clicked(MC3);

function Clicked(number:String):Void{
number.onRelease = function():Void{
trace(number + " okay");
}
}


what I thought would happen is that "number.onRelease" would change to "MC3.onRelease", but it didn't... so I guess it is impossible to use parameters instead Instence names.
so what else can I do to with functions to make this work???

THANLS ALOT!!!



FlashKit > Flash Help > Flash ActionScript
Posted on: 12-19-2004, 08:04 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Function For Buttons
i've got something like this (an action for button):


on (rollOver) {
tellTarget ("hint") {
// "hint" is a classic short help
//(small messagebox)
_x=170;
_y=205;
text_field = "...bla bla bla..";
_visible=true;
}
}
on (rollOut) {
tellTarget ("hint") {
_visible =false;
}
}

how can i convert that action script (for 1 button) into a function for 35 buttons (each of them must have a different size and shape)
have u got any idea?

One Function For Many Buttons
Instead of using one function for every button, I would like to make one function that can be called. I was trying to do this for another who was using several gotoAndPlay(); button. I feel certain there is a way to do this and I thought I had the sure way, but it doesn't work.

I put this code on frame1 of a simple movie with a simple button MC with an instance name of "but1." Can anyone say why this doesn't work? And for extra credit, can anyone suggest an alternate strategy?


Code:
function Go2Frame (F:String){
gotoAndPlay(F);
}
but1.onRelease = function(){
Go2Frame(Here);
}

How To Get Buttons To Function....
im making a simple flash website and i made my layout and my 3 buttons, i want each button to make a block of text appear when you click on them. sort of like going to another page but just like brings up the content....or makes if appear, if you will.

for example, when i click "contact" i want the contact info to appear, and when i click about, i want the about info to appear, etc....

ive made a nice fade in for everything for when the site first loads if that matters....

ive tried everything and still cant get it to work, im working in flash CS3...

any solutions?

4 Buttons -----> One Function
hi guys,
i've 4 buttons in the main root...
and if any of them clicked tell mc_main to gotoAndPlay("mainon").
mc_main is a movie clip contains from 20 frames if any buttons clicked it's appear. and if i click on it .
.. it disappear.
it's ok for one button but if i clicked 2 or 3 buttons before click
on it.
so i create this function

ActionScript Code:
onClipEvent (load) {    function homeClick() {        if (mc_main._currentframe == 10) {            // i don't know what i've to write here        } else {            _root.mc_main.gotoAndPlay("mainon");        }    }}

it works greate but if the _currentframe ==10 what supose to happen

Function For Buttons
Is there a better way to write those code more clean?
Let's say I have several buttons and I want to write a nice function to manage them like that:

For example instead of using:

tab_option1.onRollOut = function() {
gotoAndPlay('transition');
};

tab_option1.onRollOver = function() {
gotoAndPlay('debut');

};

tab_option1.onRelease = function() {
getURL("...","...");
};


How about put them in an array and write a function to manage them instead to rewrite those code again...

Any examples?

4 Buttons -----> One Function
hi guys,
i've 4 buttons in the main root...
and if any of them clicked tell mc_main to gotoAndPlay("mainon").
mc_main is a movie clip contains from 20 frames if any buttons clicked it's appear. and if i click on it .
.. it disappear.
it's ok for one button but if i clicked 2 or 3 buttons before click
on it.
so i create this function

ActionScript Code:
onClipEvent (load) {    function homeClick() {        if (mc_main._currentframe == 10) {            // i don't know what i've to write here        } else {            _root.mc_main.gotoAndPlay("mainon");        }    }}

it works greate but if the _currentframe ==10 what supose to happen

Function For Buttons
Hi all I am creating a menu for a website I am doing 10 links so it will have 10 buttons, I can hard code each button like this:

// Button 1
// Button Label
link1.bar.txtlabel = "Home";
link1.onRollOver = function (){
link1.ball.play();
};
link1.onPress = function () {
link1.bar._y = 1
this.gotoAndStop(link1);
};
link1.onRollOut = function () {
link1.ball.stop();
link1.bar._y = 0;
};
link1.onRelease = function () {
link1.ball.stop();
link1.bar._y = 0;
};

but I would like to do a Function that holds that stuff in it so that I can use the code once as a template instead of doing it 10 times so if I wanna change anything I can do it just once. anyway here is the function I tried to do but it didnt rerally work:

function MenuLink(sLink:String, sTitle:String) : Void{

[link+sLink]bar.txtlabel = sTitle;

[link + sLink]onRollOver = function (){
[link + sLink]ball.play();
};

[link + sLink]onPress = function () {
[link + sLink]bar._y = 1
this.gotoAndStop(link + sLink);
};

[link + sLinkNum]onRollOut = function () {
[link + sLink]ball.stop();
[link + sLink]bar._y = 0;
};

[link + sLink]onRelease = function () {
[link + sLink]ball.stop();
[link + sLink]bar._y = 0;
};

trace("Link " + sLink + " Title: " + sTitle);
}

MenuLink("1", "One");
MenuLink("2", "Two");
MenuLink("3", "Three");
MenuLink("4", "Four");
MenuLink("5", "Five");
MenuLink("6", "Six");
MenuLink("7", "Seven");
MenuLink("8", "Eight");
MenuLink("9", "Nine");
MenuLink("10", "Ten");

it would be great if someone could help me :)

Thanks A Million Guys
Brian

How To Add Function To Duplicated Buttons
Hi all
How do I add a different action to duplicated mc which has button inside it? I am trying to do navigation, for that I am duplicating a mc five times..now I need to add function to it..so that I when user clicks it...I want different url to call.

those five mc buttons contains these script
on (press) {
doMyFunction();
}

I want click on:
mc1 = to get url
mc2 = to jump to frame 10 on maintime line or set property
and so on and on....
thanks a lot
PilotX

Function, Buttons Controling Mc's, Help?
I have buttons that control movieclips, i want all movieclips to goto hide, on a click and have just one show. how do i do this. The movie clips overlap on the stage but are in seperate layers.

this is what i have used in the past but is now giving me errors. the mc's and buttons are in the same timeline

function turnOff () {
_root.1amc.gotoAndStop("hide");
_root.1bmc.gotoAndStop("hide");
_root.1cmc.gotoAndStop("hide");
_root.1dmc.gotoAndStop("hide");
_root.1emc.gotoAndStop("hide");
}

i am also getting this error:
Scene=question1, Layer=actions, Frame=50: Line 4: ';' expected
_root.1amc.gotoAndStop("hide");

can anyone make sense of this??
help please!!!!

MC Buttons Controlling A Function... How Do I?
This problem is very much a case of me wanting to have my cake and eat it.

I'm loading in external .swf's to a main movie via the code below based in a root keyframe:


Code:
fscommand("allowscale", false);
stop();
but1.onRelease = function() {
nextMovie = "sub_about_02.swf";
cover.gotoAndPlay("close");
};
This, working in conjunction with an MC instanced as 'cover', allows the movie to be stored whilst there is a small transition over the top of the existing movie.

I have normal buttons instanced as 'but1' etc. and everything works a treat.

However, whilst it all works properly, I would very much like to add an extra element of eye candy by adding in the old classic MC buttons (using the old invis button with rollover/rollout/goto script assigned to it). Unfortunately, I can't seem get this to work - I am guessing it is something to do with multiple instance names causing confusion.

So my question is:

Is it possible to control the above function using an MC Button? If so, any suggestions on how it could be done?

If anyone could find the time to help me out, I would be most grateful.

Cheers

Double Function Buttons
How do you create a button that when pressed, it does one action, such as go to a frame, and when pressed again, go to another frame?

It has to be the same button, as it controls the playback of another MC.

Thanks

--iMat

Call Same Function From 2 Different Buttons In AS 2.0
How can i call the same function from two differnet buttons in Action Script 2.0?

This is the function that i want to reuse:

this.iMC_remote_mc.play_btn.onRelease = function(){
ns.play();
};

Respect for reply!

/ Johan

Buttons-rollover Function
i have 4 'buttons' on my page. they down have any 'down' functions, but they have rollover functions. they are set in a square, so when you roll over one what its supposed to do is enlarge so that it covers the other three and becomes a big square.

the problem i'm having is the roll over is not showing up on top of all the other buttons, rather its on top of some and behind others. i know i can bring the object to front, or create different layers, but i'm still going to have that problem with 3 out of the 4.

can someone tell me how i can fix this?

thanks so much!

Multiple Buttons One Function
I have multiple buttons that I want to add the same function to.
What is the correct syntax to do this???

ie:
Code:
(row1.butt,row2.butt).useHandCursor = false;
or:
Code:
row1.butt,row2.butt.onRollover=fucntion(){
MyGlowfunction()
}
without having to type out


Code:
row1.butt.useHandCursor = false;

row2.butt.useHandCursor = false;

row3.butt.useHandCursor = false;

row100.butt.useHandCursor = false;
(btw I need to have the hand cursor on some buttons else I would rid the hand cursor completely.)

Many cheers

[F8] Multiple Buttons One Function
I want to have 10 buttons on the stage btn_1 etc up to 10. Is it possible to have one function to detect the buton being pressed rather than a seperate MouseDown MouseUp etc for each button the code becomes massive I have tried using a for loop as in btn_i but it does not work any advice hints appreciated

OnRelease Function For Buttons
Why is it that my onRelease function is working for movie clips, but not for buttons?

Editing A Function For Buttons...
I have the following function, basically a whole lot of ohter things happens onRollOver and onRollOut but pretty sure it's here I need to edit. I have 5 mc's on the stage called 'btn1', 'btn2' etc... And this code...


Code:
numOfBtn = 5;
for (i=0; i<numOfBtn+1; i++) {
_root.buttonsHome["btn"+i].num = i;
_root.buttonsHome["btn"+i].originalY = _root.buttonsHome["btn"+i]._y; //stores original position
_root.buttonsHome["btn"+i].onRelease = function() {
//set the frameNum variable to the same as the number button you selected, i use it again in frame 9
frameNum = this.num;
trace("playhead should be sent to "+frameNum+" by btn"+this.num);
//start playing the movie
play();
};
As I said there is other bits and pieces that happen, but what i want to achieve is btn2, is actually just going to an external link, but at the moment I don't want it when pressed to play... Is there anyway to keep it as part of the function, but if btn2 is pressed NOT to play? Any help would be greatly apprecaited!

FullScreen Function In AS2 (Buttons?)
I'm currently doing a FullScreen command for a client using AS2. Functions are working but only as a contextual menu. I want to add two buttons as well. One that appears when you first see the .swf that when you click on it, it expands it to fullscreen mode. The other is for taking it back to normal viewing mode. Neither function is working and I can't figure out the fix. Here's my code if anyone can figure it out.


PHP Code:



import flash.geom.*;stop();normal_btn._visible = "0";feature._visible = "0";// functions to enter and leave full screen modefunction goFullScreen() {    // when going out of full screen mode     // we use these values    feature.savedWidth = feature.width;    feature.savedHeight = feature.height;    feature.savedSmoothing = feature.smoothing;    feature.savedDeblocking = feature.deblocking;     // Set the size of the video object to the     // original size of the video stream    feature.width = myVideo.videoWidth;    feature.height = myVideo.videoHeight;    feature.smoothing = false;    feature.deblocking = 0;     Stage["fullScreenSourceRect"] = new Rectangle(       feature.x, feature.y,        feature.width, feature.height);     Stage["displayState"] = "fullScreen";        fs_btn._visible = "0";    normal_btn._visible = "1";}function exitFullScreen(){   Stage["displayState"] = "normal";   fs_btn._visible = "1";   normal_btn._visible = "0";}// function to enable, disable context menu items, based on which mode we are in.function menuHandler(obj, menuObj){   if (Stage["displayState"] == "normal")   {      // if we're in normal mode, enable the 'go full screen' item, disable the 'exit' item      menuObj.customItems[0].enabled = true;      menuObj.customItems[1].enabled = false;   }   else   {      // if we're in full screen mode, disable the 'go full screen' item, enable the 'exit' item      menuObj.customItems[0].enabled = false;      menuObj.customItems[1].enabled = true;   }}// create a new context menuvar fullscreenCM:ContextMenu = new ContextMenu(menuHandler);// hide the regular built-in itemsfullscreenCM.hideBuiltInItems();// now, add the items to enter and leave full screen modevar fs:ContextMenuItem = new ContextMenuItem("Go Full Screen", goFullScreen);fullscreenCM.customItems.push( fs );var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen", exitFullScreen);fullscreenCM.customItems.push( xfs );// now, attach the context menu to any movieclip in your movie.// here we attach it to _root, (even though using _root is generally a bad idea,)// so it will appear if you right click anywhere on the movie._root.menu = fullscreenCM;fs_btn.addEventListener("click",goFullScreen);normal_btn.addEventListener("click",exitFullScreen);

Can Multiple Buttons Use The Same Function In AS3?
I have a function that is called by all buttons. In AS2 It would look like this:


Code:
function buttonClicked(which:String){

switch(which){

case"start":
PlayGame();
break;

case "toggleSound":
toggleSound();
break;

case "instructions":
gotoAndStop("instructions");
break;
}

}


In AS3 you attach listeners and pass the event, but I can't figure out how to know exactly which button called the function. Do I need a seperate function for each button? Or is their a way to pass parameters? Please help.

Loop To Set Function To Buttons
Hello, im having some trouble with these buttons. Whenever i run it, when i trace the variable in stopThis, it alwasy comes up with 25, no matter which button i press. Any ideas on how i could do this differently? Or what the problem with my code is.


ActionScript Code:
for (var i = 0; i<=25; i++) {
    _root["symbolName"+i].onPress = function() {
        startDrag(this, true);
    }
    _root["symbolName"+i].onRelease = function() {
        stopDrag();
        _root.stopThis(i);
    };
}

Multiple Buttons... One Function
Hi, please help me work this around.

I want to create several buttons (named b_1, b_2, etc), each one has its respective eventListener, but I want to point them all to one only function, this funtion will "trace" a number depending on which button was clicked.

Usually I would just use the switch/case method to "recognize" which button was clicked, but this time my buttons are created dynamically (based on the number of items on a changing XML list) so its a different quantity of buttons every time I run my movie.

Can anyone help me figure out a solution?

Same Function For Multimple Buttons...
Im creating several buttons (about 5) and on rollover I want them to have the same Tween function effect, but when i try and call the function it is not targeting the movieclip... i have used 'this' as the tweener target, but this is not working?

function rollover() {
trace("hit")
Tweener.addTween(this, {_alpha:100, time:0.2, transition:"easeInSine"});
}

bt1.onRollOver = function(){
rollover();
Tweener.addTween(this, {_alpha:100, time:0.2, transition:"easeInSine"});
}

any ideas?

Thanks

{FMX} One Function For Multiple Buttons?
Hiya,

I am building an interactive world map, and for ease of updating am slapping all the functions in a frame on the main timeline.

Say I have a the word "Belgium" with a generic button symbol underneith it (instance name of Belgium of course), and also the maps shape of Belgium, as a button labeled, say Belgium_Map , each requiring several functions for rollovers, movement etc, is it possible to simple write one expresion and apply it to both buttons?

Im sure, like most things that one gets stumped on, it is pretty simple, however Im not sure of the syntax...

My code looks something like this:

buttons.belgium.onPress = function(){
map:scale_target = "250";
map_target = "-1050";
map:y_target = "-280";
locations_target = "-250";
country="Belgium"
toptextfade.gotoAndPlay("fadein");
};

So can I apply it to my completly separate button with the path map.europe.belgium as well, without having to write out all that crap again for each, when they execute the same things?

Please help, as it will my make my thousands of pages worth of code a bit tidier!

Ill post it as open source once Ive finished aswell, as its pretty cool.

Cheers

Editing A Function For Buttons...
I have the following function, basically a whole lot of ohter things happens onRollOver and onRollOut but pretty sure it's here I need to edit. I have 5 mc's on the stage called 'btn1', 'btn2' etc... And this code...


Code:
numOfBtn = 5;
for (i=0; i<numOfBtn+1; i++) {
_root.buttonsHome["btn"+i].num = i;
_root.buttonsHome["btn"+i].originalY = _root.buttonsHome["btn"+i]._y; //stores original position
_root.buttonsHome["btn"+i].onRelease = function() {
//set the frameNum variable to the same as the number button you selected, i use it again in frame 9
frameNum = this.num;
trace("playhead should be sent to "+frameNum+" by btn"+this.num);
//start playing the movie
play();
};
As I said there is other bits and pieces that happen, but what i want to achieve is btn2, is actually just going to an external link, but at the moment I don't want it when pressed to play... Is there anyway to keep it as part of the function, but if btn2 is pressed NOT to play? Any help would be greatly apprecaited!

Using Animation Function With Buttons.
Hey!

What I'd like to create is a menu. Let's say, menu has 4 buttons. But instead of creating each a animation (which is the same for all of them) I'd like to create an animation function and use the function with the buttons. The question is how to create such function and integrate it with buttons. The animation function should contain onRollOver and onRollOut functions too for start. For animations I will use AS 2.0. mx.transitions.Tween.

All kind of help is awaited.

Thank You in advance

{FMX} One Function For Multiple Buttons?
Hiya,

I am building an interactive world map, and for ease of updating am slapping all the functions in a frame on the main timeline.

Say I have a the word "Belgium" with a generic button symbol underneith it (instance name of Belgium of course), and also the maps shape of Belgium, as a button labeled, say Belgium_Map , each requiring several functions for rollovers, movement etc, is it possible to simple write one expresion and apply it to both buttons?

Im sure, like most things that one gets stumped on, it is pretty simple, however Im not sure of the syntax...

My code looks something like this:

buttons.belgium.onPress = function(){
map:scale_target = "250";
map_target = "-1050";
map:y_target = "-280";
locations_target = "-250";
country="Belgium"
toptextfade.gotoAndPlay("fadein");
};

So can I apply it to my completly separate button with the path map.europe.belgium as well, without having to write out all that crap again for each, when they execute the same things?

Please help, as it will my make my thousands of pages worth of code a bit tidier!

Ill post it as open source once Ive finished aswell, as its pretty cool.

Cheers

Multi Function Buttons
i want to create a button that when you click it once one event happens you click it again and another thing happens and yet again you click and something else happens. i found a post about doubel purpose buttons that had this code
on(release) {
if (myVar == 1) {
myVar=0; fill in here;
}
else {
myVar=1; fill in other case here;
}
}

thats exactly what i want to happen but with 3 different outcomes. how can i change to code to allow this to happen?

Editing A Function For Buttons...
I have the following function, basically a whole lot of ohter things happens onRollOver and onRollOut but pretty sure it's here I need to edit. I have 5 mc's on the stage called 'btn1', 'btn2' etc... And this code...


Code:

numOfBtn = 5;
for (i=0; i<numOfBtn+1; i++) {
_root.buttonsHome["btn"+i].num = i;
_root.buttonsHome["btn"+i].originalY = _root.buttonsHome["btn"+i]._y; //stores original position
_root.buttonsHome["btn"+i].onRelease = function() {
//set the frameNum variable to the same as the number button you selected, i use it again in frame 9
frameNum = this.num;
trace("playhead should be sent to "+frameNum+" by btn"+this.num);
//start playing the movie
play();
};



As I said there is other bits and pieces that happen, but what i want to achieve is btn2, is actually just going to an external link, but at the moment I don't want it when pressed to play... Is there anyway to keep it as part of the function, but if btn2 is pressed NOT to play? Any help would be greatly apprecaited!

Buttons To Function Like Undo And Redo
Hello,

I was wondering if we could create buttons which could undo any previous action performed in the movie.

Is there any way to track all the commands or actions performed by the objects in the movie.

If we can get this then probably we can use these to either undo or redo those actions

can someone guide me with this

Animating Function Generated Buttons
below is some script which i am using to create a submenu, i have been trying to add to it to make the buttons 'slide out'
(i.e. one moving to the right into a position then generating the next button where the first stopped and sliding to a new position and so on..)

i've been trying to use the setInterval command with no joy and am wondering if im barking up the wrong tree.

can anyone point me in the right direction?

// generate submenu
function gensubmenu() {
_root.attachMovie("submenu_mc", "submenu", 2, {_x:50, _y:200});
for (n=0; n<_root.selectedCount; n++) {
_root.submenu.submenuItem.duplicateMovieClip("subm enuItem_"+n, n);
currentItem = _root.submenu["submenuItem_"+n];
currentItem.labelName = _root.selectedNames[n];
currentItem.frameName = currentItem;
if (n != 0) {
prevItem = _root.submenu["submenuItem_"+(n-1)];
currentItem._x = prevItem._x+(prevItem._width-prevItem._height);
}
}
_root.submenu.submenuItem._visible = false;
}

Function For Multiple 'loadmovie' Buttons?
hi

i have a bunch of buttons that load SWFs into my my main movie. All of the buttons have the same 'loadmovie' code except for the SWF filenames each loads. can i place a function in the timeline that does the loadmovie action for each but inserts the correct filename corresponding to the button pressed? this way i won't have to copy and paste the code over and over for each button. thanks!

HitTest Function Embedded In Buttons
I have a button. On mouseOver I have this button divided into 4 pieces, so in the OVER state of the button I have placed two movie clips, each supposed to link to a different file when clicked. The link is not working, though.

So the question is how do I properly script these two MC's, placed in the over state of the button, so that when they are clicked they link to the appropriate files. Thanks

Buttons Function Only On Main Timeline?
it seems that whenever I place a button inside of a MC and then place it on the mainstage, it never works.

once I take the button outside of the MC and just place it on the main timeline, it works. However, this can be mildly inconvenient to the organization of my movie.

why is this? is there a way to get it to work inside of a MC?

thanks.

Call Same Function In Multiple Buttons
Hi people,

I've got 60 keys.
In each key, I've got a button wich call a function wich is in _root
Example :
In key 1:
on (rollOver) { _root.myfunction(); }
In Key 2:
on (rollOver) { _root.myfunction(); }
etc...

I'd like not to write the same thing in each key...
How to please.....

Pierrot.

Buttons Inside Movie Function?
Hi,

i have what i think is a question which could be quite easy to answer for someone.

i have a movie clip with a button inside it. i am going to have to duplicate this on the stage about 20 times. each movie will have a name, ie. part1, part2, part3 etc etc. the button within will go to a respective labelled frame on the root, but i don't want to have to duplicate the movie in the library and put the code on each button in each movie.

is it possible to reference the name of the movie clip when i click the button inside it so it? for example, if i click on the button in "part1" it will go to a frame on the root labelled "part1".

i imagine the code on the button to be something like:

on (release) {
_root.gotoAndPlay(GET THE NAME OF THE MOVIE CONTAINING THIS BUTTON AND GO TO THE APPROPRIATELY NAMED FRAME);
}

I hope this makes sense.

All help much appreciated.

Mark

Function And Actionscript Buttons Help Needed
ok hey guys...I am having a problem with these actionscript buttons that are using function()

I have two movies... shell.swf which is my timeline. on the first frame i am loading another swf named framework.swf into _level100. the buttons i want to control the main timeline are inside the framework.swf in a mc called frame they are named next_btn and prev_btn

I have this code on the 25th frame of the shell.swf...

// _level 100 next/prev button script
_level100.frame.next_btn.onPress = function(){
this.gotoAndPlay("section_2_slide_1");
}


thanks for any help you an give me

Mike

Can't Get Buttons GetURL Code To Function
Hi all,

I am using Flash 8 Pro on Windows XP. The following code used to work on my previous version of Flash (MX), but seems to no longer function:

on (release) {
getURL ("javascript:NewWindow=window.open('Test.doc','new Win1','width=600,height=600,screenX=hh,screenY=yy, left=hh,top=yy,toolbar=No,location=No,scrollbars=N o,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);");
}

Can anyone tell me if there is a preference or setting somewhere that I should be changing to get it to work again? I've attached a .rar with the .fla. Many thanks.

Want To Change A Buttons Function From A Different Level
This is the code I am using on a level10 to try and change what a button does which is located on level100:

_level100.play_btn.onRelease=function (){
_level10.play();
_level5.play();
_level1.play();
gotoAndPlay("controlsOut");

}

this doesn't seem to work. Why not?

[F8]Function Not Working With Movieclip Buttons.
OK so my function just eases a movie clip across the stage on rollover. However it will only work when the script is on a actual Button not a Movie Clip.

Here is whats going on.

First Frame (Write the function)

Code:
function moveArrow(Xcoord){
this.onEnterFrame=function(){
arrow._x+=(Xcoord-arrow._x)/2;
}
}

stop();
Script on button (button is actually a movie clip)

Code:
on(rollOver){
this.gotoAndPlay("over");//over effect
moveArrow(180);
}
So that script works fine if the properties of my button are set to "Button" But it will not work if it is a "Moive Clip".

Is there away arrond this. I guess I could build "hit state" buttons and script around them but that would be a pain.

Any help would be great?

Apply One Function To Sequence Of Buttons?
I've created a function that loads the thumbnail that corresponds to the picture and it works fine;

function loadThumb(){
thumbLoader.loadMovie(this._name+"_t.jpg");
}

I have 200 buttons named sequentially (b1, b2, b3, b4 etc.)
Do I need to type out each button individually to apply the function, like this:

b1.onRollOver=loadThumb;
b2.onRollOver=loadThumb;

Is there a better and faster way to write this code?

Any help or ideas would be great.

Print Function Seems To Be Disabling My Buttons
I have a print function featured in my flash file. When I choose to print, all the button functionality that I have on my root timeline is somehow disabled. I have definately not use .enabled anywhere, so I cannot trace the problem.

The file can be found at:
http://www.munzamedia.co.uk/flashstu...tion_table.fla or http://www.munzamedia.co.uk/flashstu...tion_table.swf

Can anyone have a look and suggest why the buttons fail to respond after clicking on the print button?


Thanks,
Mark

Selected And Rollover Function For Buttons
Hi

Im trying to make a set of thumbnails in a gallery. I have, with some help, got my images loading into the movieclips and working with a basic rollOver and rollOut function.

What I need to figure out now, is how to create some interaction where, if a button is clicked it stay's in it's over state untill another button is clicked. At the same time I want all of the other buttons that are not selected to have a rollOver and rollOut function.

Here is the code I've got so far. I have set a varible named "select" and set it to = 0, on the root of my timeline.

So I am trying to change that varible value onRelease to establish if something is selected or not, but I haven't really got the logic sussed and how I am able to tell which button is selected and therefore which buttons should stay at frame 1 or have the rollOver and rollOut properties working at any one time.

PLEASE HELP!! If I can understand this it will help me soooo much.

Thanx. =0)



for(i=1; i <= 50; i++) {
loadMovie("images/thumbs/thumb"+i+".jpg", this["btnHolder"+i].inside);
this["btnHolder"+i].onRelease=function (){
_root.select = 1;
if (_root.cur == 0) {
trace("same pic!");
} else {
_root.fadeOut(0);
}
}

this["btnHolder"+i].onRollOver=function (){
this.gotoAndStop(2);
}

this["btnHolder"+i].onRollOut=function (){
if(_root.select == 1){
this.gotoAndStop(2);
}else if (_root.select == 0){
this.gotoAndStop(1);
}
}
}

Function Target Path, And On Many Buttons.
Hi!

I´ve got 2 problems. To get my functions work on my buttons, I need to place the function AS in the same MC as the buttons (menu). I´m shure it´s not the path I got wrong... How can I place all my function script in a *.as or at least on a action layer in the _root, and reach them from my buttons.

Second problem. On my menu buttons I use some rollOver and rollOut, same on each buttons, but different onRelease. As it is now I need to write the same functions for every button to make it work. How can I use the same function script for every rollOver and rollOut, but using different onRelease?

Many thanx for helping me!
Sundance Kid

Cannot Get Buttons Inside Movie To Function Help
this is an action script for a scrolling photo nav I made and it works perfect but none of the buttons work

I made a movie called scroller, inside I made each photo a button,
tring to assing button to another movie dont work, it just controls that scroller movie help



onClipEvent (mouseMove) {
xmousepos1 = _xmouse;
ymousepos1 = _ymouse;
if (xmousepos1>xmousepos2 && ymousepos1>-50 && ymousepos1<50) {
_root.scrollclip.nextFrame();
}
if (xmousepos1<xmousepos2 && ymousepos1>-50 && ymousepos1<50) {
_root.scrollclip.prevFrame();
}
if (ymousepos1<-50 || ymousepos1>50) {
play();
}
xmousepos2 = _xmouse;
ymousepos2 = _ymouse;
}

Call Same Function In Multiple Buttons
Hi people,

I've got 60 keys.
In each key, I've got a button wich call a function wich is in _root
Example :
In key 1:
on (rollOver) { _root.myfunction(); }
In Key 2:
on (rollOver) { _root.myfunction(); }
etc...

I'd like not to write the same thing in each key...
How to please.....

Pierrot.

Assigining Function To Mulitple Buttons
have 3 buttons on stage ( btn1,2,3 ).
how'd I assign (for example-onRollOver) an aplha function on all 3 of'em in the same function?

example of code ( but doesn't work ofcourse ):

ActionScript Code:
(btn1,btn2,btn3).onRollOver = function() {
    this._alpha = 10;
};

thnx,
hog!!~~

Using Buttons To Call Javascript Function
I am trying to get 4 buttons in a flash movie to call different javascript functions in my html page that load another flash movie into a <div> tag on the page.

Button 1 example:
The function I am trying to load is: showGallery();
this function is stored in a .js file correctly linked to the html page (via a <script> tag) that contains the flash movie.
I want the function to be activated when I click on the button (is it the press or release method?)

I am completely new to actionscript and I am very stuck on how to do this.

I know that my functions work correctly as I can activate them from my html page with success, how can my button make them work?

Please help me, I need to get this project finished and get paid!!!

OnMouseDown Function Loads All Buttons
I learned to make these simple but cool buttons on a tutorial last night, but the tutorial failed to complete the training by explaining how to make a down action and how to make that down action go to a hyperlink or two a different place on the timeline. I intuited the down action, which seems almost right - it just activates the down frames for all the buttons instead of just the one you are clicking.
View or download here:
http://jp-graphics.net/viewer.html

Here is the...
Action Script:
b1.onRollOver = over;
b1.onRollOut = out;
b1.onMouseDown = down;
b1.buttText.buttonText.text = "HOME";

b2.onRollOver = over;
b2.onRollOut = out;
b2.onMouseDown = down;
b2.buttText.buttonText.text = "PORTFOLIO";

b3.onRollOver = over;
b3.onRollOut = out;
b3.onMouseDown = down;
b3.buttText.buttonText.text = "ABOUT";

b4.onRollOver = over;
b4.onRollOut = out;
b4.onMouseDown = down;
b4.buttText.buttonText.text = "CONTACT";

function over() {
this.gotoAndPlay(2);
}

function out() {
this.gotoAndPlay(7);
}

function down() {
this.gotoAndPlay(17);
}

Kode's Enable Buttons Function
Howdy all. I tried to bump an old thread with a new question but it got buried too quickly so I thought I'd try a new thread with a (now) old question instead!

I am using this nifty little function written by Kode:

ActionScript Code:
var buttons = [_root.btn1, _root.btn2, ..., _root.anotherButton];buttonsEnabled = function (value) {for (var prop in buttons) {buttons[prop].enabled = value;}};// enable buttonsbuttonsEnabled(true);// disable buttonsbuttonsEnabled(false);

My button array is on my main timeline. On the main stage is a button that when pressed calls the function to disable the array (buttonsEnabled(false)). This seems to work - although when I do trace(buttonsEnabled) it just says "type Function" . . . ?

Anyway, it disables the button.

Now I do this so that I can load a content MC on top of the stage (and the buttons there) and load in an external swf. The content MC has a close button on it. When you click the close button I want the buttons on the main stage to be enabled so I call the function again (buttonsEnabled(true)). But it doesn't work at all. And a trace returns undefined.

Is this a scope problem?

Thanks for any help!

Copyright © 2005-08 www.BigResource.com, All rights reserved