ActionScript 3.0 :: Refer To Numerous Buttons With One Function?
May 17, 2011
Probably a misleading title. I meant function, not name ><I have a number of colour buttons in a custom made colour Picker. Each one has a name likecb0000FF, cbCC3333 etc, corresponding to the hex value. I'm having to make a function for each button like this though:Actionscript Code:else if((cb99CC00)==e.target) return;Is there a way to have only ONE else if function, such as Actionscript Code:else if((cbNNNNNN)==e.target)return;Basically referring only to the "cb" and then any combination of 6 random numbers = N?
View 1 Replies
Similar Posts:
Sep 18, 2009
I have this function that I want to apply to 10 different MovieClips that are on the stage by using an array. I wrote the array, I just need to know how I can apply the array to the function. [code]...
View 3 Replies
May 25, 2009
I need to create a new xml from within a function, then refer to it outside of that function.example:
Code:
function xmlIt(array) {
var results_xml = new XML();
[code]......
View 3 Replies
Mar 12, 2012
I don't know what basic knowlege i missing here.I have two compiler error and don't know what to do about it.First says ") or , expected"Secondly "The class or interface 'BitmapData' could not be loaded."
Code:
listener.onLoadInit = function(mcTemp[i]:MovieClip) { // ") or ," expected
mcTemp[i]._visible = false;
[code].....
View 3 Replies
Mar 13, 2009
I have found the following code and modified it.
Code:
// Drag a piece of garbage.
rubbish_mc.onPress = function() {
this.startDrag(false); }; // When the garbage is dragged over the trashcan, make it invisible.
rubbish_mc.onRelease = function() {
this.stopDrag(); // Convert the slash notation to dot notation using eval.
if (eval(this._droptarget) == trash_mc) {
rubbish_mc._visible = false;
change_score(); } };
My question: I have numerous movie clips for the rubbish. Is there a more elegant way of calling them than repeating the above lines with rubbish2_mc, rubbish3_mc etc.
View 2 Replies
Apr 18, 2002
I have created a Flash 5 Movie which contains numerous input fields.The variables assigned to some of these fields have been converted into numeric format using the Actionscript command Variable =Number(Variable)
View 4 Replies
Jun 10, 2010
How do you refer can i refer to a Internet url in actionscript 2
View 4 Replies
Nov 20, 2009
I am putting together a simple flash anim - and pretty much have about 25 buttons that I need to fade in and out on rollover. I seem to remember there is a way to apply the same function to all buttons - as long as the over and out state labels within the mc are the same.
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
Nov 24, 2008
I'm having trouble getting classes that refer to each other to compile:
package People {
class Pairing {
var Father:Person;
var Mother:Person;
[Code]...
View 3 Replies
Dec 4, 2003
Is there any way to refer to a certain layers x value, or visibility, or any of those? And if not, what is usually done to preform an action on a whole layer? Should I just make a new symbol out it?
View 2 Replies
Sep 3, 2004
How do i refer to an array name inside an array?[code]...
Now i need something like stuff=array1[3]; (this makes an array called stuff which is a copy of array2, hopefully) and then myvar=stuff[3] (which is "succes").. get it?
View 4 Replies
Nov 23, 2007
Is it possible to have one xml doc for more than one swf, so that i would only need to edit one xml doc as opposed to 12?
View 4 Replies
Dec 4, 2003
Is there any way to refer to a certain layers x value, or visibility, or any of those? And if not, what is usually done to preform an action on a whole layer? Should I just make a new symbol out it? And what effect does groups have in actionscript?
View 2 Replies
Mar 9, 2009
What I have is a series of buttons created via attachmovie based on XML nodes. I want to make sure all buttons are all clicked. What I have below is the onRelease of the button and I need to put my checkDone function in there because of the XML onLoad function. What I am struggling with is how to check if each has been clicked. Typically I would just do like but1==true but that does not seem to work.
_root["but"+b].onRelease = function() {
function checkDone(whichbut) {
done = true;
[code]....
View 2 Replies
May 11, 2010
I've got 2 buttons. I need it to function like radio buttons. When one is clicked I need the other to automatically be invinsible.
if echeck_mc is visible I need echeck_mc to be invinsible. If I'm doing this wrong (marked in red) how should this be coded.
this.check_btn1.onRelease = function() { _root.glv_mc.rotate_mc1._visible = !_root.glv_mc.rotate_mc1._visible; _root.ltab_mc.echeck_mc._visible = !_root.ltab_mc.echeck_mc._visible; if (_root.ltab_mc.echeck_mc._visible = true) { _root.ltab_mc.tcheck_mc._visible = false; }};
View 3 Replies
Oct 5, 2010
I have the following scenerio, a main.swf which loads swfs on top, code below
stop();
var Xpos:Number = 0;var Ypos:Number =0;var swf:MovieClip;var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("swfs/home.swf");
[code].....
View 7 Replies
Oct 11, 2010
One of the things that I love about AS 1/2 is with scrpt assist on, the ability to click a box and assign an action to a button (over, rollout, rollover, click, etc.). With action script 3, at least in CS4 that interaction isn't there and you have to write the code.I'm wondering if in CS5 there is that ability with AS3? Am I the only designer who misses this function.
View 1 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
Mar 1, 2011
I am using isdown method but i am also familiar withe switch and case i already made the KeyObject.as and the human.fla[code]...
View 0 Replies
Jun 7, 2011
I have 30 buttons on the stage each with a different instance name.
ActionScript Code:
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
btnArray = [h1_btn, h2_btn, h3_btn, h4_btn, h5_btn, h6_btn, h7_btn, h8_btn, h9_btn];
for each (var btn:*in btnArray) {
btn.addEventListener(MouseEvent.CLICK, checkClick);
btn.buttonMode = true;
[Code] .....
Not all of them only a snippet. Is there a short way of doing this. The only prob is each function will have a completely different piece of code in it eventually doing different things. I have 20 mc with 30 btns in each.
View 9 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
Aug 14, 2007
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.[code]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?
View 1 Replies
Oct 5, 2009
function clicked(e:MouseEvent):void {
if(a == 0){
Tweener.addTween(circle, {scaleX:5, scaleY:5, time:0.5, transition:"easeOutElastic"});
Tweener.addTween(circle, {x:middleX, y:middleY, time:0.5, transition:"easeInOutBounce"});
a = 1;
}else if(a == 1){
[Code] .....
The addEventListener will be in a forloop and applied to all the circles that are created. But how do I have the function apply itself to all the circle(s). How do I send an "circle" array as an argument or whatever it's called to that clicked function.
View 10 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
Dec 12, 2008
I have balls (...sounded pervert) that are created by duplicateMovieClip, yes, they spawn, but right on top of each other, and I don't seem to be able to do anything to them, I tried ball+i.onEnterFrame = function(){} typed in several different ways ("ball"+i, ["ball"+i] etcetc...) And I just couldn't find How to refer to them. i'm trying to spawn them to random positions and make them move in random directions (got the moving part already coded but like I said I can't name them -> can't use it atm.)
Short version: How to refer to balls that are created by duplicateMovieClip?
View 2 Replies
Oct 1, 2009
I have a container movie which loads another movie into a Loader object which then gets added to the main timeline. The loaded movie has a main class which controls all the other classes in that movie. The container movie has one other element - a scrollbar which scrolls the loaded movie (which is longer than the container) up and down.
When content changes in the loaded movie I need to pass a message to the scrollbar. If I trace parent.parent.parent from the init() function of the loaded movie it traces [object MainTimeline]. My scrollbar, sBar is a direct child of the main timeline, but tracing parent.parent.parent.sBar doesn't work So how can I pass a reference to the scrollbar to the loaded movie? Here's the code in the container movie:
PHP Code:
var ldr:Loader = new Loader();
var sBar:Scrollbar;
ldr.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
[code]....
View 3 Replies
Mar 16, 2010
I have an array that movieclips are added into depending on the users actions. When they are added to the the array, they are also added to the display list of another movieclip on the stage.I'm trying to refer to them later so I can remove them from this movieclip's display list, but I can't work out the wording.[code]
View 2 Replies
Jun 7, 2010
I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this: obj.x = stage.stageWidth / 2; I get a message that I Cannot access a property or method of a null object reference
View 4 Replies
Jul 15, 2010
I am using the load movie from my main file (main.swf) as:
mc_zoom.loadMovie("detail.swf");
I then have a loader as a movieclip with the detail.swf
when the movie (detail.swf) is loaded the preloader I am trying to make/set the play to go:
_root.gotoAndStop(2);
But this does not work - it works locally but when used with the main file (main.swf)
View 5 Replies