ActionScript 2.0 :: Store References To A Function And Parameters?

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


Similar Posts:


ActionScript 3.0 :: Store A List Of Parameters Needed For A Function In An Array And Then Use That In A Function Call?

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

ActionScript 3.0 :: Arrays Store References Of Other Arrays?

Dec 27, 2009

I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.

View 7 Replies

ActionScript 3.0 :: AddEventListener Function References Child In Movieclip. How Do I Stop This?

Jun 28, 2010

I built a custom designed checkBox. The movieclip is in the libary and dragged onto the timeline of my .swf. I'm using CS4 & AS3. I'm using procedural AS3 instead of OO AS3.The checkbox movieclip has a child movieclip inside of it so I can apply a drop shadow filter to some of the graphics .When I put an eventlistener on the custom checkbox it works fine but when I try to reference the checkbox movieclip inside the eventlistener function, the event.target.name is referring to the child movieclip (just a graphic with a drop shadow filter).From my reading it looks like the function propogates down to the child movieclip but I don't want it to do that.How do I reference the parent movieclip? or

B. stop the eventlistener from propogating down to the child movieclip?

I tried using stopPropagation(); but it didn't stop the function event.target.name from trickling down to the child movieclip.Here's what AS3 looks like.The trace statement displays "step3_mc.cbEmail_mc.instance25"instead of what I need "step3_mc.cbEmail_mc"

step3_mc.cbEmail_mc.addEventListener(MouseEvent.CLICK, fnc_cbClick);step3_mc.cbAgree_mc.addEventListener(MouseEvent.CLICK, fnc_cbClick);
function fnc_cbClick(event:MouseEvent):void  {[code]....

View 2 Replies

ActionScript 1/2 :: Pass Parameters Along With A Function That Is A Parameter To Another Function?

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

ActionScript 3.0 :: Store A Function Constructor In An Array?

Feb 14, 2009

Is it possible to store a function constructor in an array? I tried, but getting an error for example, say this is my function:

functiom openPages():void
{
trace("pages open");
}

and my array:

var myArray:Array= new Array(openPages);

View 7 Replies

ActionScript 3.0 :: Using An Array To Store Function Names For Use Later?

Sep 15, 2011

I am writing my quest .as files for my RPG that I am making. At the present moment I am having issues with certain commands and how best to accomplish them. This pertains to my conversation system that I have in place. Currently, the conversations are stored as an array, with each index in the array representing a different "page" of the conversation. Now for my quests, at the end of each conversation (the last index in the array), I want a certain function to occur (receiving the quest, updating the quest, completing the quest). So my thought is to have a separate array with the same number of elements as the conversation array, and when the conversation text is updated to reflect the next page, it also will access the function array with that given index, and therefore only on the last page of the conversation will the function be executed.

Code:
var a:Array = [func0, func1, func2];
function func0():void{
trace(0);[code].....

Now my question is this, when is the code actually executed? When it is placed within the array, or when it is accessed with the for statement?

View 3 Replies

ActionScript 2.0 :: Store The Result Of Calculation Of Function, In Variable Outside It?

Nov 11, 2005

I ve a bit of missunderstood about functions: as i read the functions works:

basically 2 types:
named (can be lonely)
unamed (need and object)

- can i define a function wherever i want? ( _root, MC...) and call it from everywhere?, before or after i created it?

- if the variables of a function are local variables of that function. How can i store the result of a calculation of the function, in a variable outside it?

View 9 Replies

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

ActionScript 3.0 :: MouseEvent Parameters In Function?

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

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

ActionScript 3.0 :: Add Parameters To Function Dynamically?

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

ActionScript 2.0 :: Passing Parameters To A Function

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

ActionScript 3.0 :: Passing Parameters To A Function?

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

ActionScript 3.0 :: How To Pass Parameters To Function

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

ActionScript 2.0 :: Call A Function With Parameters From XML?

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

ActionScript 2.0 :: Passing Parameters To The Function

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

ActionScript 3.0 :: Passing Parameters To A Function From Within An EventListener

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

ActionScript 3.0 :: Passage Parameters By Href To A Function?

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

ActionScript 3.0 :: Add Parameters To An Event Listener's Function?

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

ActionScript 3 :: Give A The EventListener A Function With Parameters?

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

Flash :: Passing Parameters To A Function Reference?

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

Actionscript 3.0 :: Pass Tweener Parameters To Another Function?

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

Actionscript 3.0 :: Creating Function With Optional Parameters

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

ActionScript 2.0 :: Passing Parameters - Function Is Not Even Called?

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

ActionScript 2.0 :: Send Parameters To Another Function Through AddEventListener?

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

ActionScript 2.0 :: Assigning Function To OnEnterFrame With Parameters?

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

ActionScript 2.0 :: Pass Parameters To A Function From SetInterval?

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

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

ActionScript 3.0 :: Acceptable Number Of Parameters Per Function?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved