ActionScript 2.0 :: Passing Additional Arguments To Function?
May 20, 2008
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].....
View 4 Replies
Similar Posts:
Aug 19, 2009
I am trying to pass an additional arguments to my listener function, like this[code]...
View 8 Replies
Apr 28, 2006
hboxvar.addEventListener("mouseDown",dosomething(3 43));
hboxvar.addEventListener("mouseDown",dosomething(1 23));
hboxvar.addEventListener("mouseDown",dosomething(1 2342));
public function dosomething( somenumber:Number ):void {
//do something here
}
I try to do above function but I need to pass variable from hboxvar but not from inside function suggested by macromedia.
any one frustated with this way of passing multiple parameter which depends on what to pass in flex 2 using addEventListener ?
[URL]
Passing additional parameters to function listeners You can pass additional parameters to function listeners depending on how you add the listeners. If you add a listener with the addEventListener() method, you cannot pass any additional parameters to the listener function, and that listener function can only declare a single argument, the Event object (or one of its subclasses).
View 9 Replies
Oct 8, 2009
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.
View 0 Replies
Apr 8, 2009
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].....
View 1 Replies
Apr 8, 2009
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]....
View 1 Replies
Jul 20, 2010
How 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 Replies
Feb 10, 2009
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?
View 1 Replies
May 20, 2007
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].....
View 1 Replies
Jun 24, 2011
I'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?
View 2 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
Mar 14, 2012
I have a menu which is created from an XML file. I'm using LoaderMax to grab the data and do the magic:
[code]...
View 1 Replies
Jun 9, 2009
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".
View 1 Replies
Jun 17, 2011
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
Dec 31, 2002
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].....
View 1 Replies
May 12, 2005
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.?
View 3 Replies
Jul 14, 2009
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);
View 3 Replies
Nov 11, 2009
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?
View 2 Replies
Nov 11, 2009
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]......
View 3 Replies
Jul 15, 2010
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 Replies
Feb 22, 2011
I 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]....
View 4 Replies
May 8, 2009
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].....
View 2 Replies
Oct 30, 2011
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.
View 12 Replies
Sep 24, 2008
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...
View 1 Replies
Feb 28, 2008
I have this code but I cannot work out how to fill in function parameters based on an array and it's length, see line 7
[AS]
import com.robertpenner.easing.Cubic;
MovieClip.prototype.framesTimeout = function(func:Function, frames:Number, args:Array) {
[code]....
Is it possible to call a function and fill in the parameters based on an array and it's length?
View 1 Replies
Jan 28, 2009
I have already created a custom mouse event which seems to work fine. It is simply a mouse event which passes an additional sound object. The problem is I am passing this event to another class which checks for collision of a movie clip with another and if true it adds the sound to an array. What I think is happening is a type conversion problem between my customEvent and the MouseEvent. [code]...
View 3 Replies
Jul 6, 2011
I got a huge problem trying to color objects that are flying around in my space game. When I shoot and hit them - the affected enemies shall blink. The graphics are pre-rendered (i.e. there's an rotation array and function where the degrees and their appropriate rotation for the objects are stored / calculated for better performance).
So - my idea was to enhance that rotation function with a functionality for additional coloring; but the colored AND rotated objects shall be stored apart of the normal rotated objects. To accomplish this I made a nested array: in row one there are 360 rotated graphics of one object and in row two there are 360 graphics of a rotated and colored object.
[Code]...
View 1 Replies
Sep 21, 2010
i have a question i have a primary and secondary function which i want it to be dynamic so i can get the user to enter in six to seven different or as many as required argument parameters for my primary function
[CODE]...
View 5 Replies
Jan 1, 2010
I'm designing a game that uses this function;
function moveBars(Bl:Number,Gr:Number,Or:Number,Ye:Number)
{
blueBar_mc.scaleX += Bl;
greenBar_mc.scaleX += Gr;
orangeBar_mc.scaleX += Or;
yellowBar_mc.scaleX += Ye;
}
When moveBars is called, the length of the 4 colored bars change to indicate how the player is doing in different areas of the game, like so; moveBars(.1,-.2,.3,-.1)
My problem; I need to store the moveBars parameter arguments in XML like so;
<myArgs> .1,-.2,.3,-.1 </myArgs>
But I can't find the way to get those 4 numbers into the moveBars parameters from the XML doc. Is there a way to do this?
View 5 Replies
Sep 4, 2009
I have a component that I hand over a function
public var func : Function;
Now the function is a function that has parameters in its signature
public function myFunction(s : String) : void {
doSomething(s);
}
from my component I can call the function with
func.call();
how to invoke the function with its parameters?
View 1 Replies