Flex - Passing Optional Arguments (rest) Through To Another Method That Takes Optional Arguments?
Feb 3, 2010I have a "format" method that works in a similar manner to the C# String.Format method, with the following signature:
[Code]...
I have a "format" method that works in a similar manner to the C# String.Format method, with the following signature:
[Code]...
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 RepliesI'm revisiting some old code that filters XML, but this could easily apply to the parameters of a method (the way I'm using it, it essentially is). This is a problem I feel like I run into a lot and don't know a good way around this. So the problem is that I've got 3 arguments. They're all optional. I want to see which ones are presents and test if their values based on which ones are present (sorted according to likelihood):
[Code]...
Let's say I have a function in a class with two required parameters and two optional:
Code:
public class Person extends Sprite {
private var haveToWork:Boolean;
private var hoursOfSleep:Number;
private var gotANewVideoGame:Boolean;
private var gotAHotDate:Boolean;
[Code] .....
All of that setup for this question: on the second call of the areYouHappy function, how do I keep the gotANewVideoGame variable from having a false value assigned to it?
I need to override the call method from NetConnection class, the signature of the method is:
[Code]...
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?
I need to pass some value, say 'name=john', from html to actionscript.I am now using AC_FL_RunContent as;
AC_FL_RunContent(
"src", "newFile",.... );
here the movie is mensioned as 'newFile'.. how do pass the value 'name=john' to the actionscript code.what I need is something equivalent to "newFile.swf?name=john".
Is it possible to use javascript to call a method in as3 and pass in an object argument?This would act as a setter in some sense.
View 4 Replies I have a movie clip that contains several movie clips, only one of which should be shown at a time. Which one is shown, depends on what buttons the user selects.Having trouble with the syntax for passing the argument in a button to the function that controls the tweening of the clips. (When I hard code the references into the function, it works, so I know the basic function is ok).There's a clip called 'slide1_mc' which contains various MC's to be shown based on user selection (in this case, using 'system' clip as the first one already showing). Here's the code in the parent clip of that item:
Code:
var currSection = slide1_mc.system_mc;
function changeSection(newSection):Void {
TweenLite.to(currSection,.3,{_yscale:200, _xscale:200, _alpha:0});
[code]....
Here's one of serveral buttons that will control the content to be seen:
The code in the button is:
Code:
var changer = slide1_mc.software_mc;
smallButton.onPress = function() {
_parent.changeSection(changer);
};
So - the initial part of my function works so I know my 'external' initializing of "currSection" is working (that clip is zooming/fading out)... but then the clip that I want to fade in isn't doing anything.
i have been playing with the Zend Tutorial - and all works fine... however, stuck on something that i found quite easy in amfphp/as1&2
In AS3 - i am using NetConnection and i want to pass arguments to my php function
The first function i show here works fine....
inMyPhp...
Code: Select allpublic function getTutorials()
{
$result = mysql_query("SELECT * FROM testTable");
$t = array();
[Code].....
i have a music jukebox, with ten buttons. in the first keyframe, of the main timeline, a put a function that will be used for every button to load the mp3 to play. The problem, is that when i pass the arguments on each button to call the function, the "filme" and "som" arguments are lost.
here is the function:
function carregaSom(filme, som, url, msg1, msg2, tempoComeco){
_root.createEmptyMovieClip(filme, 1)
som=new Sound(filme);
[Code].....
Is it possible to pass arguments "by reference" instead of "by value". I know it's possible in almost every programming/scripting language I came across until today, but I didn't find any hint for doing it in Actionscript For those who don't know what "by reference" means: If you want to pass a Number to a function, say
Code:
var mynumber:Number = 5;
calculate(mynumber);
and you change the value of the argument inside the function, e.g.
[code]....
then the call to calculate normally does NOT change the value of mynumber because you have passed mynumber "by value", which means the value of mynumber has been copied to the num argument. This means mynumber is 5 all the time.Now sometimes u want to be changing arguments given to a function inside the function, and this is where u will normally use references. Passing mynumber "by reference" would mean that after calling calculate the value of mynumber will be 6...I know complex Objects like MovieClips are passed by reference. But how to do it with simple DataTypes like Number, Boolean etc.?
In my database i have a field called "live", and i only want to grab entries in a table that have "live" set to "1"
This is what i have tried, but it doesn't work....
InMyPhp...
PHP Code:
public function getTutorialsLive($live)
{
$result = mysql_query("SELECT * FROM testTable WHERE live = '%s';", $live);
[Code]....
You can do this:
PHP Code:
public function (args ...)
To take in any number of arguments. Is it possible to then give the content of that args array to a new function:
PHP Code:
public function bla (args ...){
pleh( changeArrayIntoArgs(args) );
}
So that that would be the same as just passing arguments manually. lets say bla got 3 arguments:
PHP Code:
bla(v,vv,vvv);
So that bla then executes:
PHP Code:
pleh(v,vv,vvv);
I am fairly new to AS3.
vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OVER, mcIn(vancouverMC));
vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OUT, mcOut(vancouverMC));
function mcIn(mcName:MovieClip):void{
mcName.gotoAndPlay("in");
mcName.ringMC.gotoAndPlay("on");
} function mcOut(mcName:MovieClip):void{
mcName.gotoAndPlay("out");
mcName.ringMC.gotoAndPlay("off");
}
Why this is Not Working?
tell me why this doesn't work?
vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OVER, mcIn(vancouverMC));
vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OUT, mcOut(vancouverMC));
function mcIn(mcName:MovieClip):void{
[code]......
I've drawn a pretty button in Flash and given it the Class name PausePlayButton. It extends PlayerController, which allows it to toggle on and off and control whether a MovieClip is playing or not.When I instantiate it, I want to pass a reference to the MovieClip it controls into the contructor so that PlayerController has access to the MovieClip's public methods. However, I can't pass a reference into the constructor of PlayerController, unless I can pass it into the constructor of the symbol itself and call super. But where is that constructor? How do I give the button a reference to another object?
View 1 RepliesHow to pass boolean arguments to a function[code]On the stage i have all the MC - screenX, alarmsX, criticalX, majorX,warningX, redX, orangeX, greenX.But i get errors:Scene 1, Layer 'Layer 1', Frame 1, Line 171119: Access of possibly undefined property visible through a reference with static type Boolean.for each of the MC.
View 9 RepliesI just started using object pooling and I have some problems with passing arguments. I made class "Circle" which needs 3 arguments when instanced and I try to push it into the pool.
[Code]....
I have four NetStream objects that receive cuepoints from different videos. I'd like to define one function for them all instead of using four inline functions and I'm stuck with syntaxHere's the code:
Code:
ns1.onCuePoint = callCuePoint;
ns2.onCuePoint = callCuePoint;
[code].....
Say I have an array with 4 string elements that are 4 different urls. On the stage I have 4 movieclips that I want to have listen for a CLICK event. When the user clicks a button, the navigate to one of the 4 urls.I can loop through the buttons and add and event listener to each:
Code:
private function applyPlankLinks():void {
for (var i:uint = 0; i<numberOfPlankBtns; i++) {
[code].....
Knowing only a method name, I want to parse a page of AS3 code to extract the arguments of that method.
thus given
[Code]...
I'm having trouble with the constructor for a custom Class tied to a library MovieClip.
Say I have a MovieClip in my library named Circle, which is tied to the class com.shapes.Circle . I want the Circle class contstructor to take 2 arguments, xScale and yScale:
public function Circle(xScale:Number, yScale:Number) { }
However, if I try to call that from in code, for example Circle ball = new Circle(3.14,2.0); , I always get an "Incorrect number of arguments. Expected 0" error.
Is it possible to have a custom class tied to a MovieClip that can take arguments, or does Flash not allow this? I'd asked about this before and thought I figured it out, but from looking at it now I apparently hadn't figured it out and had resorted to a sloppy workaround; I'm hoping to fix it now.
Is there any way to pass an argument to a function being called by a ContextMenuItem?The effect I want would be what one might expect from this pseudocode:
Code:
var cm = new ContextMenuItem("Start Alt", set_row_style('start_alt_here'), separatorBefore=true, enabled=true, visible=true);
Which obviously doesn't work, or I wouldn't be asking.So far I've tried using the captions as a basis for a switch condition, which works.
Code:
function set_row_style(obj, cm) {
switch (cm.caption) {
case 'start_alt_here' :
...
But I'd rather not use an arbitrary string as part of a function.The only other option I see is using a listener for each ContextMenuItem, then calling the function with its arguments from there.Is there any more direct a way to pass an argument to a function from a ContextMenuItem?
I want to have an array, where each value is a function, where each function also has a set of arguments.
What is the correct syntax for setting a value of an array as a function?
Lastly, how do I pass arguments into the array's value?
Code:
var funcA = new Function(a:Number, b:Number){return a + b};
var funcB = new Function(a:Number, b:Number){return a - b};
var funcC = new Function(a:Number, b:Number){return a * b};
[Code].....
Is it possible to pass variable as arguments for a function? I wish to update a boolean variable via a function, by passing the name of the variable to the function, like so:
Code:
function ENVSegment(curSegment:Boolean, nextSegment:Boolean) {
curSegment = false;
nextSegment = true;
} var attackSegmentIsRunning:Boolean = false;
var releaseSegmentIsRunning:Boolean = false;
[Code] .....
Much shorter, and easier to understand. Also, less repetition of the same blocks of code over and over...
How do I accept multiple arguments in a custom method? Like:
Proxy(101, 2.02, "303");
function Proxy(args:Arguments){
Task(args);
}
function Task(var1:int, var2:Number, var3:String){
// work with vars
}
I'm trying to define interface in which one method (initPage) needs to have different arguments in every implementation. How can I do this? Using ...args for me is not good, because I'm loosing strong type checking.[code]
View 6 RepliesI'm an AS3 noob who is trying trying to get more comfortable with passing arguments into functions.why when the following code is all in one AS3 file as seen below it works and draws the purple square...
package{
import flash.display.*;
public class Main extends Sprite{[code]............
Flash CS5 gives me an error message 1137 saying that it was expecting only 1 argument in the code line --> Fill(square_commands, square_coord);I need to pass the arguments square_commands and square_coord into the function in the second AS3 file?
This AS3 function works for normal methods and getter methods:
public function MyClassTestAPI(functionName:String, ...rest):* {
var value:*;
try {
[Code]......