ActionScript 3.0 :: Optional Parameters For A Function?
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
Similar Posts:
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
Jan 30, 2004
I have this function:
Code:
MovieClip.prototype.changeColor = function(mode, kl, kh, rl, rh, gl, gh, bl, bh) {
}
How can I make all parameters optional except the first one?
View 8 Replies
Feb 24, 2007
Im coding in AS3, and i want to make a class that will recieve optional parameters, but i dont know how to identify these parameters as optional.
I tried writing
Code:
public function mydate([language:String]):void{
like Adobe identifies optional parameters, but it doesnt work
View 6 Replies
May 18, 2010
I'm creating a slideshow where each slide can have:- a video or a still- 1 audio track or many (up to 3)- 1 button or many (up to 3)I was thinking that each slide can be it's own object, and then I would pass the video, audio, buttons, etc., into it as parameters:
package
{
import flash.media.Video;
[code].....
View 2 Replies
Nov 19, 2009
I want to add things to the display list, some will have event listeners and some not. Is it possible to make an argument optional so it doesn't throw an error if it's not there when calling the function?
View 2 Replies
Jul 17, 2005
lets say i define a function...
function myFunc(para1, para2, para3){
blah.. blah..
}
but i want para3 to be an optional parameter... can i do it..?
example..i will either use myFunc(var1, var2); or myFunc(var1, var2, var3); when calling myFunc function...
View 1 Replies
Jul 21, 2009
im trying to pass in an optional argument into a function. The datatype of this needs to be an object... however, im not getting very far. I know i can do this....
[Code]....
View 3 Replies
Jan 18, 2010
I'm using FlashBuilder 4 beta2. My base class has a function foo():
protected function foo(s:String, z:String=null): void{}
Literally "foo" so that there's no chance I'm stepping on a built-in method. I am getting an
"Incompatible override" error when attempting to override the method in a subclass:
override protected function foo(s:String, z:String=null): void{}
Does the optional parameter do something "behind the scenes" that makes it illegal to override the method?
View 1 Replies
May 16, 2009
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var animTween:Tween;
[Code].....
I have figured out the following: Well, as you see the function moveStuff accepts three arguments, namely:
objectdurationeasingWhen easing has a default value, I get an error. But if it doesn't have a default value, then it works fine, the code would look like so then:
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var animTween:Tween;
[Code].....
View 5 Replies
Feb 3, 2010
I have a "format" method that works in a similar manner to the C# String.Format method, with the following signature:
[Code]...
View 3 Replies
Aug 25, 2009
How do I make the color array, dColors, an optional parameter?[code]It gives me a "1047: Parameter initializer unknown or is not a compile-time constant."I've tried a bunch of different ways, but all I get are compile errors.Don't forget to drop a colorpicker control in to your library if you copy out the code.
View 2 Replies
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
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
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
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
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