ActionScript 2.0 :: Set Default Values For The Parameters Of A Function?
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
Similar Posts:
May 5, 2011
How can i make a function that changes the value of variables that are passed into it. For example:
[Code]....
I want the example above to add 5 to the variable pie1 (or whatever variable is passed in) and change pie2 to the cosine of pie3. Hope this makes sense :P
View 5 Replies
Apr 12, 2010
In C you can pass a reference to a data item as a parameter to a function. then within the function you can write to that address thus passing back a value to the caller. Can you do anything similar in AS3?
I know you can use the return statement but I want to return a status by that mechanism plus a value in a parameter.
View 10 Replies
Feb 11, 2009
I'm trying to set up some default parameters that are functions.
ActionScript Code:
public function makeButton(buttonUp:Function, buttonOver:Function = this.defaultButtonOver, buttonDown:Function = this.defaultButtonDown, buttonOut:Function = this.defaultButtonOut) {
[code].....
View 2 Replies
Apr 16, 2011
quick question:Is there a better way to do this?
public class ribbon extends Sprite {
private var fallAmount,taper;
public function ribbon(FallAmount=50,Taper=0.2){
fallAmount=FallAmount;
taper=Taper;
}
View 2 Replies
Sep 18, 2009
[code]will this represent possible performace increase instead of writing like so:[code]
View 1 Replies
Feb 21, 2011
I am using a Field Container to enter a new Contact information, and I would like to populate some of the fields with values.
I can do this for normal fields like Phone and LastName, but ti does not work for lookup fields like ReportsTo and Account.
This is th code I am using:-
var acc:DynamicEntity = new itemClass("Contact");
acc.Phone="8888";
acc.LastName="Nieddu Srl"
acc.ReportsTo ="0012000000RsJYb"
acc.Account="test"
_createFieldContainer.render(acc)
Is there any way to populate a lookup field with a default value when the field container is called?
View 1 Replies
Aug 24, 2009
If you have a function that accepts a parameter of Point type, how do you assign a default value?
PHP Code:
setPosition(position:Point =(0,0)){
}
I tried (0,0), (x:0, y:0) {x:0, y:0} and none worked... anyone know the correct way?
View 3 Replies
Dec 7, 2009
I want to create an HBox component; for example HLBox that behaves exactly like an HBox but has as default width and height 100%.
View 1 Replies
Dec 28, 2010
how to set default property values for objects that are being created in a loop.
In the example below, these propeties are the same for each object created in the loop: titleTextField.selectable, titleTextField.wordWrap, titleTextField.x
If you pull these properties out of the loop, they are null because the TextField objects have not been created, but it seems silly to have to set them each time.
var titleTextFormat:TextFormat = new TextFormat();
titleTextFormat.size = 10;
titleTextFormat.font = "Arial";
[Code]....
View 4 Replies
Sep 3, 2011
I've run into an extremely odd problem. I'll give a code example to start. This is the superclass Building.
Code:
public var allowsEnemyMovement:Boolean = true;
public var information:String = "";
public var buildingName:String ="";
[Code]...
Now here's the odd part. Only SOME of the variables defined in the superclass do this. the variable information, buildingName and health all will take the default value from the super class. But the variable defenseValue will take its value from Factory's constructor. What am I doing wrong here? I would like to keep default values in the superclass so that I don't end up with null pointer errors later just in case.
View 3 Replies
Feb 18, 2009
I created code based on a site I found that puts the XML into CSV's, here is the code:
var myXML:XML = new XML(); // instance of XML Obj.
myXML.ignoreWhite = true;
myXML.load(config.xml)
[Code].....
So after all of that, my question is, if that one tag XML file that I gave an example for has 100 or so lines, is there a way to call it without having to know the line it is on so you don't need to put the array value in all of the time?
View 5 Replies
Jun 16, 2009
I have an xml with an xml-schema. The xml-schema defines an abstract complex type with 2 optional attributes that have default values. Then I have several complex types that extend the base one. And finally nodes of the types defined.So I load the xml and when I parse each node, the optional attributes are not present at all.I've tried fooling around with the namespaces, even[code]...
No luck. Something similar was being experienced by this guy on codingforums, but that was like 5 years ago. Same is happening to me with firefox 3.0.11 - the xml is shown without the default attributes.For now I'm setting the default values in code, but isn't there a way to make them available from the xml-schema?[code]...
View 3 Replies
Jun 13, 2011
This code seems to compile fine in the IDE, but the command-line compiler (SDK 4.5 mxmlc.exe) reports "Parameter initializer unknown or is not a compile-time constant."
package {
public class Constants {
public static const CONSTANT : int = 0;
[Code].....
View 1 Replies
Sep 14, 2010
I am creating a game in Flash 8 with AS 2 and i have few questions to ask.First of all, i am stuck for 2 days at creating a Laser Beam from tower to the target.I searched all internet for solutions but i can't really find one, so i'll try posting questions myself..First i tryed to create and effectHolder into which every laser beam was created, because it seems i can create only one line in each movieClip.[code]This was triggered eveytime it had a target.With every tower that fired a laser i created it was getting more lag, so i tryed selfdestructing after few time.[code]The problem is that i didn't know how to pass the coordonates of the tower and the target to the MovieClip so it knows where to create the line.[code]how to create that line ("laser beam") for each tower, without lagging so much.
View 11 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
Mar 18, 2010
I want to create a simple component in as3, cs4. There are 2 problems I cant solve:
1.)I can't get the default parameters "loaded" in the class for the component so lets say if I have w = 10 in the parameters how can I refer to it in the code?
2.) How can I get the tool with which I can set which corner of the component should stay the same : it looks like this in the default
flash button component
theLinesTool.png (11.82 KiB) Viewed 290 times
View 2 Replies
Dec 23, 2009
i have a function that receives a function as a parameter. example:
function foo(bar:Function):void() {};
how can i set a default value for the function to be an empty function so the user will not have to paste a function as a parameter ?
View 1 Replies
Sep 27, 2006
I'm having my first go at creating a custom component that lays out items in a grid. I have made a selection of inspectable properties accessed though getter/setter methods. Some of these parameters are dynamic, and change when the user resizes the component or changes another linked value. Is it possible to make the parameters panel update with the new values when a change takes place. Without this, the user will not have accurate feedback on the values stored in the component. Does anyone know if this is possible (or difinitely impossible)?
View 1 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
Mar 10, 2010
After dragging many MovieClips/Components onto the stage, how can I generate a report (or display on screen)by listing the names,parameters, values of all the movie clips/ components dragged on the stages?
View 5 Replies
Feb 7, 2009
Lets say I want to call a function with an optional Object, how do I write that?If it was a String or a Number or some simple data type it would be:
Code:
function foo(s:String="Sample String", n:Number=100):void{}
But anything I try with an Object just throws an error. For example...
Code:
function foo(o:Object={x:10, b:10}):void{}
...makes the compiler barf, and so does every other version of this I've tried.
View 2 Replies
Jun 30, 2009
Is it possible to set up a Class to have a Default Parameter as a new function? An example of Default Parameters:
Code:
function sayHello(somebody:String = world):void {
trace(hello, +somebody);
}
If so, what is the syntax for it?
View 3 Replies
Mar 3, 2011
Does anyone know what is the syntax to use for a function's default parameter when it's a Vector? You can easily create a default value for an int or Number or even an Array, but what about a Vector?
View 2 Replies
Oct 19, 2009
How do I put in an array as a default argument for a function ?eg
Code:
test();
function test(_arr:Array = new Array(0xFF0011,0x112233,0x000000))
[code]....
View 2 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
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