ActionScript 2.0 :: Use Arrays As Function Parameters?
Nov 29, 2010
Something like[code]...
Since I have to loop through all of them. I can convert them to an array inside the function, but it would save me 10 lines if I could just enter them as an array in the function parameter (as I have 10 variables 1-10...)
View 4 Replies
Similar Posts:
Jun 23, 2009
is it possible to store a list of params needed for a function in an array and then use that in a funciton call?
[Code]...
or something like that?? Prob have to iterate the array but how do i get the params into the function call? Is this even possible?
View 6 Replies
Sep 3, 2010
I'm having some trouble passing parameters with a function that is itself being passed as a parameter.In my application code I'm instancing that class five times:they are buttons in a menu.In that class, I've got an onRelease handler that does a number of things when a button is released, one of which is to invoke a function that is defined in the application level of the code.My problem is that I don't know how to send the function parameters.In my StandardButton class I have:
class StandardButton extends MovieClip
{
/* define properties */[code]..........
The function is successfully being "sent" to the StandardButton class, but without any parameters.How can I send parameters to the class instance with the way I've got this architected.
View 7 Replies
Jul 6, 2011
Curious question:Take this function:
function something():Array
{
var ar:Array = [];
[code]....
View 2 Replies
Nov 7, 2011
Seems like in AS3, I can in theory, delare arrays that can only contain certain data types:
private var my_array:Array.<String>;
produces this error:
1199: type parameters with a non-parameterized type
however
private var my_vector:Vector.<String>;
is just fine. Is there a way of making this work with an Array?
View 4 Replies
May 8, 2009
How do I make some parameters of a function optional?
For example in the function below, how do I make para3 optional?
function someFunction(para1:int, para2:int, para3:String){
}
View 3 Replies
Aug 13, 2009
I have some functions that have mouseEvents for their param and I am wondering how those can be use without the param. Meaning those functions where set up to work with buttons, but how can call those when I don't have a button to call them? Here is an example of one of the functions:
function forward(e:MouseEvent):void
{
ns.togglePause();
[Code].....
View 4 Replies
Oct 13, 2011
So say I have a function that has some number of optional parameters but I don't like to write the function more than once. Instead just use for loop or such to iterate the parameters through and give them to that function.
Here's a raw scetch:
ActionScript Code:
// stylesheet for lines
var params1 = {
thicknes: 1,
[Code].....
View 2 Replies
Feb 3, 2006
way to say the same in just a few line of code? 25 lines of code people
[AS]menuAS = function () {
//TIOCCHA
menuBar.menu01.menu01_btn.onRelease = function() {
[Code]....
View 6 Replies
Apr 7, 2009
i am loading an image with a loader, and in onComplete function i would like to call calculateRatio function and pass it Loader.content.width and Loader.content.height so it can compare it with the current stage width and height and resize image proporcionally to fit the screen. how would i go about passing that parameters?
[Code]....
View 4 Replies
May 12, 2009
I have a hard time getting this
Code:
var whichXML:String = "category1";
loadFirstTime(whichXML);
function loadFirstTime(whichXML:String):void {
XMLLoader = new URLLoader();
XMLLoader.load(new URLRequest(whichXML + ".xml"));
}
View 1 Replies
Apr 16, 2010
I'm having a problem with a menu that is loaded from a xml file. I want to control the onRelease action for every button in the menu from one XML file, but I can't seem to get it to work... The buttons in the menu each have to call a different function with parameters which are declared in the flash file. The trace output shows the right function call, but it just won't fire the function.
This is an example of one of the nodes from my XML file with the function as node attribute:
PHP Code:
<locatie menu="LOCATIE )" label="LOCATIE" functie="showTextpage(myObj.locatie, CurrentProject)"> <image></image> <text></text> </locatie>
And this is my AS which loads the XML and sets up the menu:
PHP Code:
[Code].....
View 5 Replies
Mar 4, 2004
{Flash MX 2004 Pro}
[Code]...
The above does not work. Infact the function is not even called. How can I pass parameters to such functions. I dont wanna do the following:
[Code]...
View 1 Replies
Feb 26, 2009
Code:
function enableButtons():void
{
for (var i:uint=0; i<40; i++)
[Code]...
I have 40 buttons on the stage. Their names are contained in the Array musicGrid. What I'm trying to do with this code is attach an EventListener to each button so that it will call the function mgMouseBehavior with a parameter to identify the button. For example, I want the button at musicGrid[0] to call the function mgMouseBehavior(0). I want the button at musicGrid[32] to call the function mgMouseBehavior(32), and so on.
However, if you try to add parameters to mgMouseBehavior in the addEventListener, for example:
Code:
musicGrid[i].addEventListener(MouseEvent.CLICK, mgMouseBehavior(i));
Then you get Error 2007: Parameter listener must be non-null. How would I accomplish what I'm trying to do?
View 2 Replies
Aug 3, 2009
Well, I've got a problem, I don't know how to pass 2 parameters to a function by a aHref
called :
function derouler(num):void{
num=num.text; // rre la valeur de l'event
[code].....
View 3 Replies
Mar 11, 2010
I'm trying and it doesn't seem to like it. I'm guessing it's not possible?[code]...
View 5 Replies
Jun 27, 2010
I am trying to to attach a function with parameters to the timer but it says "unrelated type function" is there any way to get around this??
code example:
var redoTimer:Timer = new Timer(50);
redoTimer.addEventListener(TimerEvent.TIMER, saySomething("helloo"));
redoTimer.start();
this wont seem to work but is there a way to pass on arguments???
View 2 Replies
Aug 17, 2010
I'm attempting to write a performance testing function that can take any function, run it X times and spit out how long it took that function to run in AS3. I've got it working just fine if a function doesn't take any parameters but it comes up with an error otherwise.Here's the code:
public static function testFunction(targetFunction : Function, object : Object, ... parameters)
{
[code]........
View 1 Replies
May 15, 2009
I created a function to handle the size of a talk bubble for a chat application based on what's being loaded into the movie clip I want it to scale it's height that is. I have it working when like this
Code: Select allif (!gabChatBox.gabOp1.text == "") {
Tweener.addTween (gabChatBox.talkBubble,{height:200, time:1, transition:"easeOutElastic"});
}
[code]....
I am assuming that I must pass some sort of parameter over to the other function that is calling the resizeGabHandler()
View 2 Replies
Jan 19, 2012
I want to create some functions similar to how GreenSock's tweening class works.With the optional parameters by name in brackets. {}[code]I get this error: "Parameter initializer unknown or is not a compile-time constant."Pretty sure it's the "Parameter initializer unknown", but I don't know what to do about it.
View 8 Replies
Mar 4, 2004
{Flash MX 2004 Pro}
[AS]
myMovieClip_mc.onPress = foo(true);
function foo(state:Boolean) {
Do something
}
The above does not work. Infact the function is not even called.How can I pass parameters to such functions.I dont wanna do the following:
[AS]
myMovieClip_mc.onPress = function(true) {
//
}
View 1 Replies
Nov 21, 2006
Here I've got this bit of code that works alright, but I would prefer to have the parameters that are being sent through myTween.tweenMe(_text, 40, 300, 150, 100, 4000) originate instead with the call to tweenerIt. The problem seems to be that the tweenerIt function needs to receive the e:Event parameter, which is some sort of 'behind the scenes' type of thing that I don't fully understand. If I try putting ... _text.addEventListener(MouseEvent.MOUSE_DOWN, tweenerIt(_text, 40, 300, 150, 100, 4000) and then something like.. private function tweenerIt(param1, param2, param3, etc..., e:Event):void, it doesn't work.
Code:
_text.addEventListener(MouseEvent.MOUSE_DOWN, tweenerIt);
}
private function tweenerIt(e:Event):void {
[Code].....
View 5 Replies
Jan 25, 2007
I'm building an app with transitions out of each page. I'm using the code below to store references to a function and parameters for that function to use. Is this the best approach though?
[Code]...
So, basically, the photo_btn is writing the references and variables, telling the transition to play, when it reaches the end, it calls the function that's stored in the __func ref and uses the parameters. I'm doing it this way because I have a bunch of nav buttons that all call different functions, and this is the only way I could figure out to get transitions to play and then call the desired function at the end.
View 1 Replies
Jan 21, 2008
When assigning a function to onEnterFrame, for ex. onEnterFrame = someFunction, you do not include the brackets or the script will not run properly. my question is then, how can you assign a function to onEnterFrame while specifying parameters for that function? I tried onEnterFrame = someFunction(param1), but the function will only execute once.
View 3 Replies
Jan 28, 2008
Here is the code that doesn't work:
Code:
myInterval = setInverval(open(3), 1500);
function open(n) {
clearInterval(myInterval);
this["item"+n].play();
}
I have also tried calling a function from setInterval which in turn calls a function with a parameter...also didn't work!
View 1 Replies
Aug 12, 2010
How can I set default values for the parameters of a function in AS2? I am trying the common way but it doesn't work...
Code:
private function myFunction (param1:Number = 3,
param2:String = "a string",
param3:Boolean = false, etc ....):Void
{
....
}
View 2 Replies
Jul 2, 2011
I am creating some sort of interactive background and at is current state of development the master constructor function have like 15 parameters that need to be put in. I can add at least 6-8 more and make it really flexible, but I start to wander if this will be such a good idea. I am not sure that the general people that I am developing this class would like to type so many parameters before using it to full potential. So there is only 2 must enter parameters and like 13 that you may want to change or leave the original values. My question is if there is some common practice about this? Is it to many or no? Just for idea this is the function at this point (working ok):
Code:
new Maker(textTest,15,150,200,2,8,3,5,0.3,1.5,4,360,0.003,30);
View 14 Replies
Jul 23, 2009
Look at the simple code below:
Code:
stage.addEventListener(MouseEvent.CLICK,traceMe);
function traceMe(evt:MouseEvent)
{
trace ("hello world!");
}
What if I want to pass a parameter to the traceMe function? There is a way to do that?
View 2 Replies
May 9, 2009
Consider the function below:
function personal(Name:String,age:int,city:String):void{ trace(Name+" is "+age+ " years old and lives in "+city+ ".")}
The parameters can only(???) be passed in the order they are declared in the function as
[code].....
View 13 Replies
Jan 29, 2010
I am attempting to get Flash - Javascript communication working using ExternalInterface.addCallback, using code found at http:[url].... I am trying to pass parameters into Flash using a javascript function, but it only works if I insert a 'window.alert' line into the code. Once I click OK, the parameter str is passed into Flash ok. The function is:
function sendToFlash(str) { if (str=="tools"){ window.alert(str); getFlashMovie("richFunctionality_corp").sendTextToFlash(str);[code]....
If I remove the window.alert, str isn't passed into Flash. Is this a browser speed thing? A value menu is passed out of Flash using getURL("index.php?pageID=239&menu=tools"), i.e. the page reloads and a php script sends the appropriate str value to the sendToFlash javascript function based upon the value of menu.
View 5 Replies