ActionScript 2.0 :: Apply A Function To Multiple Buttons?
Nov 19, 2008
this is a REAL basic one for you: This is my script:
count = 0;
btn_01.onRelease = function() {
if (count<=20 && this._currentframe == 1) {
_root.count += 1;
this.gotoAndStop(2);
[Code]...
Instead of applying it to just one button I want to apply it to many on the stage, how do i add the names of the buttons to the function? I tried separating with commas but no luck
View 2 Replies
Similar Posts:
Sep 29, 2009
completing the code to get a return value from JavaScript to flash, but all the code was in a frame. My issue is I need to apply this code to multiple buttons, and then have them navigate to the appropriate frame. I thought I could put some of the code on the buttons themselves, or possibly I could call each button and keep all the code in frame one.....the external interface call function and the button functions....btn1, btn2; etc......I am not to verse in code and need to know what and how the best way to do this would be.
[Code].....
View 16 Replies
Apr 12, 2009
How would I apply my existing function that involves calculating the x and y position of a specified movie clip, to multiples of movieclips. MY MOVIECLIPS on stage are
Code:
Ball_mc
Ball_mc2
Ball_mc3
MY FUNCTION is
Code:
function hitDetect(event):void {
var ballX:Number = (ball_mc.x-videoX)/sizeDif
var ballY:Number = (ball_mc.y-videoY)/sizeDif
[code]....
Should I use Arrays? Loop?
View 3 Replies
Apr 6, 2008
ive got a text resize function and i want to apply it to two buttons so they both execute the function.the function is..
_root.largeTextButton1.onRelease = function() {
resizeText(hometext,14);
}
and
_root.largeTextButton2.onRelease = function() {
resizeText(hometext,14);
}
is there anyway i can do somthing like...
_root.largeTextButton1 & largeTextButton2 .onRelease = function() {
resizeText(hometext,14);
}
View 8 Replies
Nov 16, 2008
I have three buttons. My goal is that each button will load and play a sound file from the internet. Here is what I have:
function loadPlaySnd(pSpecifier1:String):void {
arguments;
SoundMixer.stopAll();[code]....
Every Button I press goes to the same sound file. The best I can figure, is that the file I loaded the first time I pressed a button has been uploaded, and from there I cannot load another file over that variable when I try another button.
View 2 Replies
Jul 24, 2009
I have a group of 50 buttons (named Bottle01 > Bottle50) that I want to have the same code on. The code I want is to, when pressed, put the buttons individual name into a variable and then move to a point later in the timeline. I have just started using as3 as I need this to work through Air and have been googling all afternoo and have cobbled something together, but it doesn't seem to work that well. This is the code I have sofar which is probably very wrong:
[Code]...
View 2 Replies
Oct 22, 2004
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?
My code looks something like this:
buttons.belgium.onPress = function(){
map:scale_target = "250";
map_target = "-1050";
map:y_target = "-280";
[code]....
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?
View 2 Replies
Oct 22, 2004
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";
[code]......
View 2 Replies
Jul 16, 2009
I'm building a demo that has a keyboard in it. Obviously, people will type stuff with it and it will go into a dynamic text field. So I have a full keyboard (a movie clip named "keyboardStandard") made up of button symbols. That is placed in the same frame as the text field. Then I wrote this code, using the Q key ("keyQ"):
Code:
keyboardStandard.keyQ.addEventListener(MouseEvent.CLICK, addQ);
function addQ(ev):void {
enterPlayerID_txt.appendText("Q");
}
This works just fine, the Q goes into the text field. However, I sure as heck don't want to write 26 event listeners, then 26 more functions, even if it is copy paste. That's just gnarly. Plus, there are actually 3 keyboards - a numeric and special char one as well I need to handle.I seems passing a parameter from the event listener is not doable?
View 4 Replies
Feb 21, 2012
My problem is that I am trying to use the following functions on 10 different logo movieclips. Each logo movieclip has a popup up box (another mc) within its timeline with a description in. When I hover over the logo movieclip i want it to call the forward frames function and on hover out call the rewindframes function.
function forwardFrames() {
onEnterFrame = function () {
if (_currentframe != 15) {
nextFrame();
[code]....
View 4 Replies
Feb 20, 2009
I'm fairly new to AS3 and CS4, and I'm trying to figure out how to write code that isn't needlessly repetitive. I'm not sure exactly how to streamline it, or if that's possible in my case. My issue in particular is with buttons. I have 40 buttons that perform the same function with a single variable, so I'd like to figure out if I can accomplish that without writing 40 separate functions.This is the current version: http:[url]......Here's the full code, with the relevant part in the last commented section:
Code: Select all// Library button opens library
libraryButton.buttonMode = true;
libraryButton.addEventListener([code].......
It seems that something like that might work, but I don't know how to go about setting my variables up in an array or otherwise putting them in a state where an incremental statement could refer to them.The bigger issue, though, is whether I need to make a separate function for each button.Each button will do the same thing, just with one variable.When the user clicks a button, I want it to perform a function that will update text fields with text pulled from XMLList variables.Each button is given a unique identifier that corresponds to an index in the XMLList.So clicking the button just needs to establish that identifier as a variable n, so that the function can, for example, update the titleText text field with the text contained at titleList[n].
For the purposes of this example, let's just say that I want the mgInteraction function to trace the identifier (name, array index, or whatever) of the clip that's being interacted with (mg0/mg1/mg2/mg3). Is there a way to set this up to work with a single function, or do I need to create 40 unique functions, one for each button?The flash, if need be, is here:
http:[url].......
View 1 Replies
Sep 18, 2007
I have a single movieclip named button, and I want to use a "for" to multiply that movieclip, that way I can have multiple buttons and edit them all in a single function.
It would be something like this:
var _button = new button;
for(i=0; i<5;i++){
_button[i]:button = new button;
addChild(button[i]);
}
View 4 Replies
Mar 25, 2009
I am working on a presentation that has multiple scenes each having say 100 frames. Every 10 frames there is content on the stage, i.e. a 'slide'. There are left and right arrow buttons to take the user of the presentation forward and backward - much like a powerpoint presentation.Many of the 'slides' contain another button (instance name infoBTN) that can be rolled-over, and when this happens an info bubble pops up to display some information in the form of a graphic (instance name infoBubble).This operation works fine for one button, but I don't really want to have to call a new function and variable name and have new instance names on each subsequent frame that features a similar button with an identical operation.
how can I call the function just once and re-use it over and over again? There will only ever be one button of this nature on a given frame,This is the working code I have on the timeline for this particular frame:
Code:
// INFO BUTTON MOUSE EVENT
var fadeIn:Tween = new Tween(infoBubble, 'alpha', Regular.easeOut, 0, 1, 0.75, true);
[code]........
View 9 Replies
Feb 11, 2009
i want to write a function that is used by multiple buttons and accepts a variable when it is called by a given listener..
ActionScript Code: this.fileBTN.addEventListener(MouseEvent.MOUSE_OVER, menuSet("fileMenu"));
function menuSet(what:String){
trace(what);//should trace back "fileMenu"
}
View 7 Replies
Feb 11, 2011
So, I have tons o' buttons that each need to link to unique URLs, and I'd like to minimize coding as much as possible. The code below works, but I will have to do this about 50 times.Can I associate the URLs with the instance names of the buttons and then reuse the same function?In the event you didn't already guess, I'm a newbie to AS3
cap_mc.CapTeam_btn.addEventListener(MouseEvent.CLICK, capPage);
function capPage (evtObj:MouseEvent) { trace("clicked") var url:String = "http://www.mydomain.com"; var request:URLRequest = new URLRequest(url);
[code].....
View 8 Replies
Apr 24, 2006
I have 4 buttons with instance names: 'alfa', 'bravo', 'charlie' and 'delta'. I want to make a function that runs on mouse click on either of the buttons. I tried this, but could remember exactly how it should look:
[Code]...
View 12 Replies
Feb 18, 2004
is there a way to refer to all movie clips on the stage or apply a function to all movie clips without applying the function to all manually?
View 3 Replies
Oct 6, 2007
I am writing this code on a bunch of buttons and was wondering if there was a way I could apply some sort of generic thing like move the button 2spaces away. ? Instead of defining exactly where they go on x and y.
[Code]...
View 2 Replies
Mar 21, 2011
I'm having a bit of a problem with a basic game I'm making where I want to have a number of animals which bounce around the stage.. I can't seem to get the code to apply to more than one of my movieclips using a loop.. if I try to apply vx and vy to the individual movieclips then nothing happens.. for now I have the ten movieclips on the stage but only one whichbounces around.. I have managed to get all of them to move but they each stay in their own area of the stage, but I'd like each to bounce around the stage and not interfere which the others movement.
public function Bounce() crosshairs = new Target(); addChild(crosshairs); init(); private function init():void
stage.scaleMode =
[code].......
View 2 Replies
Aug 6, 2011
I have two MovieClips onscreen, and I want to apply the same mask to both. I set the the masks using
mc1.mask = mymask;
mc2.mask = mymask;
Only mc2 receives the mask. How can I set the same mask for two different MovieClips without having to resort to putting them both in a single MovieClip?
View 2 Replies
Dec 26, 2010
im trying to use a use a code segment that makes something avoid the mouse. My issue is the code requires that iff i have more than one object that i want to avoid the mouse than i need to make a new set of variables for the second object and pretty much copy the code than change the variable names. Thats all great and dandy but i have a couple hundred very small objects that i need to avoid the mouse. is there any way to maybe apply the code to each object with an onclipload maybe?
ActionScript Code:
import flash.events.Event;
stage.addEventListener(Event.ENTER_FRAME, fun);
function fun(event:Event) :void {
[code]....
as you can see the object i want to move requires its own variables and 2 if statements. and i REALLY dont want to have to copy/paste that code over 200 times and make a new set of variables for each object. maybe i could apply the code to the object itself ? but than what would i name the variables?
View 7 Replies
Nov 21, 2011
I'm kind of new to AS3 and I created a blur effect for 6 text object. I got the result I wanted, but I thought there has to be a better way of doing this. When a mouse is over a text, other texts get blur. Now, I had only 6 object what if you have 10s of objects on the stage.[code]...
View 0 Replies
Apr 11, 2007
say i have a method "btnClick", and i have 5 buttons: btn01,btn02,etc.. how do i apply this method/function to the 5 buttons through code? here is what i am trying to do(this is just pseudocode):
Code:
MovieClip.prototype.btnClick = function(img){
this.onRelease = function(){
open(img);
[Code].....
View 6 Replies
Jul 14, 2009
I have a show I'm trying to create, I need to put the navigation buttons on different places on each frame due to content.
Code:
on (release) {
prevFrame();
}
or
Code:
on (release) {
nextFrame();
}
and
Code:
on (release){
gotoAndplay("Scene1")}
I can get the symbols that I'm using as buttons to work in the first and second frame, but they will not work after that. Each frame has a
Code:
stop ();
Action applied to it.
I have tried: copy and pasting the same symbol into multiple frames, dragging new symbols into multiple frames, creating folders for each frame and dragging new symbols into those folders then onto a frame, and I'm still not having luck. This presentation is set up to run in Flash 9 with Bottom up loading order and ASP2
View 1 Replies
Oct 15, 2011
I want to know how can I get the videos from IP Cam and store on the Flash Media Server then clients can see the videos from the browser.
what kind of software and technique I have to use ?
View 4 Replies
Aug 31, 2010
Is there a way, in ActionScript 2, to set multiple properties for an exising movieclip in one command?
For example, is there a way to write something like this more succinctly?:
myMovieClip._x = 10;
myMovieClip._y = 10;
myMovieClip._alpha = 100;
[Code]....
View 3 Replies
Apr 1, 2011
I am writing a flash card game which slides the next card onto the stage when the user presses a button.There are 24 cards, and I have written a separate tween for each one... I think there is probably a more efficient way to do this. Here is what I have:
[Code]...
View 7 Replies
Sep 3, 2011
I need to add "_myThumb" to 4 container MovieClips. The problem is that it's only working for 1 MovieClip. What do I need to change?
var _myThumb:Bitmap;
var _myThumbData:BitmapData;
function createThumbs()
[code]......
View 1 Replies
Nov 2, 2011
I'm trying to apply a Move-Effect on multiple elements. They are moving all together but I prefer it in seqeunce.
<s:Move id="thumbMover" target="{thumb}"/>
private function addItemThumbs ( ) : void {
for each ( var item : ItemVO in _items ) {
thumb = new Thumb;
[Code]....
View 1 Replies
Mar 23, 2012
How to apply multiple filters in Adobe Pixelbender in Flash (=limited version)?
For example 3 different kinds of video displacement effects (1 displacement on the left, one on the right and one the top).I know, it possible to just copy paste the code multiple times, but this wouldn't be very elegant.
View 1 Replies