ActionScript 3.0 :: Write A Function That Is Used By Multiple Buttons And Accepts A Variable?

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


Similar Posts:


IDE :: One Function, Multiple Buttons

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

ActionScript 3.0 :: Multiple Buttons With Same Function

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

ActionScript 2.0 :: [FMX] One Function For Multiple Buttons?

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

ActionScript 2.0 :: {FMX} One Function For Multiple Buttons?

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

ActionScript 3.0 :: Abstract Multiple Buttons To Use The Same Function?

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

ActionScript 1/2 :: Single Function For Multiple Buttons?

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

Actionscript 3.0 :: Multiple Buttons Referring To The Same Function?

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

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

ActionScript 3.0 :: Have Multiple Buttons And Edit Them All In A Single Function

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

ActionScript 3.0 :: Re-usable Function Triggered By Multiple Buttons?

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

ActionScript 3.0 :: Make 1 Variable For A Textfield That Can Be Used In Multiple Function?

Mar 6, 2011

Some might know by know that I am working on a school project.But my knowledge of AS3 is not so big.My game is doing what it is supposed to do (for now).But the place where I declare (or something.It now looks like this:

Code:
public class game extends MovieClip
{

[code]......

View 2 Replies

ActionScript 3.0 :: Multiple Buttons Call Same Function To Link To Unique URLs??

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

Flex :: Incrementing A Global Variable In A Function Which Is Called Multiple Times?

Oct 31, 2010

I am trying to make a simple mp3 player using flash. The songs are loaded using an XML file which contains the song list. The following code is inserted into a new keyframe.

import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.*;
import flash.events.MouseEvent;

[code]...

The problem over here is in the nextSong() function. I am unable to preserve the value of currentIndex. Although I am incrementing currentIndex every time the function is called, but the value remains unchanged.

View 1 Replies

ActionScript 2.0 :: Multiple Targets - Make A Function That Runs On Mouse Click On Either Of The Buttons

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

ActionScript 2.0 :: Write A Function To Move An Object And Then Call That Function On A Clip Event?

Jan 29, 2003

is it possible to write a function to move an object and then call that function on a clip event for instance

function (bounce){
script;
script;
}

and then call it by saying

on(mouseOver){
this.bounce;
}

View 2 Replies

Text Input That Accepts Number Only?

Nov 17, 2009

Need a code that only accepts numbers. Upon inputting, the code must check if it is number, if not, it must remove the entered key or not enter it at all

View 6 Replies

ActionScript 2.0 :: Using One Variable To Write To Another

Dec 3, 2011

I need to have one variable contain the name of another variable so I can write the actual value using either variable.

On my main timeline I have this code:
var globalvariable = "blank";
On a movieclip I have this code:
on (press) {
var testsend = name._root.globalvariable;
testsend = "IT WORKS!";
trace(_root.globalvariable);
}

I'd like the trace to read "IT WORKS!" but it's always "blank". The reason for this is that I have a controls options page where users can change their key binding for the various controls of a game. There is a list of the actions in the game with a field for the currently assigned keyboard shortcut. When they press that field, it's a button that pops up a keyboard graphic which has buttons on it for every key. Clicking one of those buttons should assign that keyboard equivalent to the corresponding field.

So I want to have something like this actually work:
Click the MoveFowards field and click "Spacebar" on the keyboard graphic and now _root.Moveforwards has a value of "Spacebar".
Click the Jump field and click "Spacebar" on the keyboard graphic and now _root.Jump has a value of "Spacebar".
Click the Shoot field and click "Spacebar" on the keyboard graphic and now _root.Shoot has a value of "Spacebar".
So I need to pass the name of the variable to the keyboard graphic so that it outputs to the correct global variable and writes its output to the correct field.

View 3 Replies

ActionScript 2.0 :: Detecting When User Accepts Privacy Pop-up?

Jan 28, 2009

Is there a way to detect when the user accepts the Privacy Pop-up?

Basically, I'm using the microphone to record a voice message. I'd like to start a countdown timer that tells the user how much time they have to record their voice.

I start the countdown timer on the same event that I call nsPublish.attachAudio(microphone), and the countdown starts immediately, even though the user sees the privacy pop-up.

View 1 Replies

Actionscript 3 :: Dynamic Class That Only Accepts A Given Type?

Aug 18, 2011

Is it possible to make a dynamic class in AS3 only accept dynamically created properties if they're a given type?For example, I may only want Sprites to be allowed. So take this quick example class:

public dynamic class Test extends Object{}

And a few quick lines to get an idea of what I mean:

var test:Test = new Test();
test.something = 32; // error
test.something = "party hats"; // error
test.something = new Sprte(); // works

Maybe using the proxy class/namespsace there's a way to manipulate whatever is run when creating variables dynamically?

View 1 Replies

ActionScript 3.0 :: Text Field That Only Accepts NUMBERS

Apr 1, 2009

I've tryed to make a textField only accept Numbers. I've embeded only numbers between 0-9 but I can still add letters.

View 6 Replies

ActionScript 2.0 :: Write Multiple Password?

Jan 18, 2006

is there a cleaner and more efficent way to wright this. i need 20+ different passwords. client wants to keep to htm and php no mySQL.

password = inputName
if (password == "pkc") {
inputStatus = "Access granted!" ;[code].....

View 4 Replies

Actionscript 3 :: Flash Cs5: Set A Variable Using A Function, Then Read That Variable From A Different Function

Jan 29, 2012

I have a public variable and I am trying to set it, then read it from a different function:

public var str:String;
public function DailyVerse()
{
function create() {

[Code]....

My trace results says null. Why does it not give me "hello"?

View 1 Replies

ActionScript 2.0 :: Previous/Next Buttons - Write Code?

Aug 7, 2009

Is it possible to write code that so when you hit a "next" button, it tells a movie clip to move so far each time it is hit? Same as with the "prev" button moving the opposite way.

View 1 Replies

ActionScript 2.0 :: Write A GotoAndPlay With The Addition Of A Variable?

Nov 25, 2009

So I've defined my variable:_global.current = 1;And below i am accessing an MC called 'carousel_holder', which has an MC named 'bar' and inside this MC is a final MC named 'bar1'.So ive tested my path and can hard code it fine, so its not a paths issue but i think my syntax is incorrect:_root.carousel_holder+".bar"+current.gotoAndPlay(" start");

View 4 Replies

ActionScript 1/2 :: Write / Read An External Variable?

Jul 9, 2009

I currently have a flash video player and I want to add some code that will update a variable in an external .as or .txt file. I then want to be able to pull this variable into a different .swf when required.
 
My variable I want to create will be CurrentVideo and it needs to be a number e.g. _global.CurrentVideo = 2

View 1 Replies

ActionScript 3.0 :: Write A For Loop For These Variable Declarations?

Mar 28, 2010

I want to simplify my coding of the below code: 
 
var printImage1:MovieClip = new PrintImage1();var printImage2:MovieClip = new PrintImage2();var printImage3:MovieClip = new PrintImage3();var printImage4:MovieClip = new PrintImage4();var printImage5:MovieClip = new PrintImage5();var printImage6:MovieClip = new PrintImage6();
  
I tried everything I could think of but it still gives me compiling errors.

View 5 Replies

ActionScript 2.0 :: Write A If Statement That Will GotoAndPlay According To That Variable?

Sep 22, 2005

In my movie I load a swf to a movieclip with this code


PHP Code:

 _root.ImageViewer.loadMovie("deneme.swf"); 

Now can I do this? before calling the swf named deneme. When I press a button If I attain a number to a global variable with this code

PHP Code: on (release) {_global.myVar = 5;gotoAndPlay("CloseUpAnimation");} 

Can I read this variable from the swf which I load into my movie?If I can read how can I write a If Statement that will gotoAndPlay according to that variable?

PHP Code:[code]...

View 4 Replies

ActionScript 2.0 :: Write To A Global Variable When In Specific Frame

Jan 27, 2009

When the value of _root.mc1._currentframe is 10 I want the value of _root.mc2._currentframe to be written (sent or changed) to a variable which I can use in mc1. So I want to be able to use this variable in different clips but I do not want it to be changed until the playhead in mc1 is in frame 10. However I do want the variable to be valid even if the playhead is not in frame 10.[code]

View 2 Replies

ActionScript 3.0 :: Flash - What's The Difference When Write A Temporary Variable

Nov 11, 2011

I would like to know what's the difference when I write a temporary variable like this (these are just examples): version1

[Code]...

What's wrong and right? Currently I write it like version 2 and I'm not sure if I should change it to version 1. I know most developers write like version 1 but I'm a little bit confused because I am totally unaware about version 1. If I use version 1 does that mean that my value is stored explicitly in a temporary variable that is cleared in every cycle?

View 3 Replies







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