ActionScript 1/2 :: Pass Function In XML?
Apr 14, 2011My question is can you write a function in an XML document and then load that XML document into Flash and call that said function?
View 5 RepliesMy question is can you write a function in an XML document and then load that XML document into Flash and call that said function?
View 5 RepliesI'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.
i'm new of AS3.i've a function in which i create some var like:var str_Foto_tn:String="";then i make a parse of a xml and i put a node value into my var.then i've another function that make a MC and addChild that MC on stage.. the name of that MC is my str_Foto_tn.But he can't see the var... how i can do?
View 6 Replieshow to pass in value to the function.I am using CS4 and AS2.This is my code:
attachMovie("platform","platform0",1);
platform0._x = 300;
platform0._y = 600;
platform0.onEnterFrame = a(0);
[code]...
I try to pass in this but it fail.
how I can pass a variable calculated in a function, to the stage.
View 9 RepliesI'm trying to make some tables. I have some movie clips:
cella1
cella2
cella3
[code]....
How do i pass variables in a function from swf to another swf?
View 4 RepliesIs there any way that you can pass a string to a function and use its value as the variable name you wish to change. For example.
Code:
var text:String = "Goodbye World";
function myfunction ( varToChange)
{
varToChange = "Hello World";
}
myfunction("text")
How do i pass the e:MouseEvent to another function??
[Code]...
I am a middle school teacher and a newbie in Flash Actionscript. I am trying to create a countdown timer for use in my class during tests. The start and pause functions work as required, but not the pause button. When I click on the pause button, the timer is reset to 0:00:00.[code]
View 1 RepliesHow can I pass a 'set' function as the Function Object argument of another function?eg:
public class IdModel
{
private var _id:String;
[code].....
I have a function call as shown here: ActionScript Code:c.draw(colorRead.population); In this function, I would like it to be able to print out population as part of the string for my toolTip. Note, what is in the parameter here may not be the case in every of the instance I need to create.
[Code]...
I'm sure this must have been covered 100's of times but I have searched and searched with no joy so... I'm trying to simply pass a value into a function using a MouseEvent, CLICK (the example below is just that an example not what I'm actually trying to do)[code]...
View 4 Repliesthis is a standalone AIR app which runs off of usb media to help people organize their personal information. there is an XML file in a separate folder which stores the name of a file that the user uploads to usb media (into yet another folder), in this case, the person's living will. getting the path to that file as it differs from mac to pc has been a challenge and i feel the only way around this is to give a conditional for the operating system (second function below).
My immediate goal below is to get the name of the file (VALUE) over to the openThisFile function so that "fileName" can be given a value appropriately in the second function code for mac. I can't figure out how to do this...Alternately, is there a way to manipulate "currentTarget.data.toString()"? I was thinking that could also help me... it has the full path to the file, which unfortunately does not work on Macs... for some reason it just can't locate the file (unless I'm missing something).
Quote:
public function handleLoadData(event:Event):void {
try {
propertyFilePath = path;
[code]....
How to display the correct digits. For instance, if the answer is 97%, I want the display to show 97, not 11. Please feel free to view the SWF or look at the FLA file to see[code]...
View 5 RepliesI'm just looking for clarification on the passing of a parameter and why/how it works.
In this example, it looks like you create a parameter to be passed in called 'evt', but I don't see it used anywhere in the function. [code]...
I'm having a little problem with how to use the argument sent to a function.I have this:
Code:
_root.onEnterFrame = function() {
setPanning(1);
[code].....
I was just wondering if it's possible to pass a variable from one swf to a function on another swf?
I have 2 containers on my main stage, each one loads an external swf, I want one to send a variable to a function in the other container.
I simply tried calling the function by doing _root.container2.fncTest("works"); just to see if it works
and in container2 I have
Code:
function fncTest(test):Void {
myText = test; //dynamic text box on the stage
}
but that didn't seem to work.. Do I have to make the function public or that only works for classes?
I'm trying to pass an array of X arrays as parameters to a function such as :
var someArray = [0, 1, 2];
var someOtherArray = [A,B,C];
array = [someArray, someOtherArray,...];
myMC.someFunction(array);
The problem is that the function doesn't see where the 1st array stops, it's like passing a big array such as
myMC.someFunction(someArray,SomeOtherArray, ...) becomes
myMC.someFunction(0,1,2,A,B,C) instead of myMC.someFunction([0,1,2],[A,B,C]);
I even tried to make a string such as str += "[array[0]]"+","+"[array[1]] ..but it still passes everything as one big array....how to pass X arrays to a function??
Is there any way that you can pass a string to a function and use its value as the variable name you wish to change. For example.
[Code]...
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"));
}
This is what i want to be able to do, only i can't... And i don't want to have a loop when i call the method executing the methods in my children. Hints?
Code:
this.executeMethod([Function(methodInChild)], ArrayOfChildren);
private function executeMethod(_methods:Array, _instances:Array):void{
[Code].....
I have an external log file which name changes each session, with the format XXXXX.log
I need to load it inside a swf to show its data, but each time the logs name is different, I need to open the .fla, changing the name of the file and then republishing the swf.
So I have made a simple script to load another .txt, to type manually in it the 5 number of the logs name and load it externally inside the swf:
Code:
var logNumLoader:URLLoader = new URLLoader();
logNumLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
logNumLoader.addEventListener(Event.COMPLETE, loadedLogNum);
[Code]....
While I cannot assign the value of logNum to the last function, the .log cannot be opened.
I'm sure that I'm doing something daft here - I just need to remove a child that's created in the constructor through an event listener.My code is below but does not work. Can someone point me in the right direction please?
public class Main extends Sprite public function Main()
super();
var rectangleIndex:uint = this.getChildIndex(playerBackground)
[code]......
how to pass parameter to eventListener function.[code]
View 1 RepliesI´d like to know how could use the Timer class extended.I´m trying to pass a parameter to the constructor function, so I can use it inside the listener.
Here´s example:
[CODE]
package { import flash.utils.Timer import flash.display.DisplayObject public class ChangeColorTimer extends Timer { public static const CHANGE_COLOR:String = "changeColor"; public var obj:DisplayObject public function ChangeColorTimer(delay:Number, repeatCount:int, obj:DisplayObject ) { super(delay, repeatCount) this.obj = obj } } }
[/CODE]
That was the ChangeColorTimer that extends Timer.Now, I´d want to know how would I use ChangeColorTimer.I thought it was the same as using Timer.I´ve tried this:
[CODE]
public function changeColor(mc:MovieClip):void { var colorTransform:ColorTransform = new ColorTransform() colorTransform.color = 0xEE0000 mc.transform.colorTransform = colorTransform var changeColorTimer:ChangeColorTimer = new ChangeColorTimer(400, 1, mc) changeColorTimer.addEventListener(ChangeColorTimer.CHANGE_COLOR, setNormalColorListener) changeColorTimer.start() } private function setNormalColorListener(e:Event):void{ trace("called") }
[/CODE]
I called changeColor, but, I don´t get "called" in the output from the setNormalColorListener listener.
i want to pass by reference so i can use this variable outside the function.
What im doing is creating a global variable such as var cont:int; and then in a eventListener like enter_frame (stage.addEventListener..) calling a function called "mover", this function modifies "cont" value and i just want to print this value modified. The issue is i cant pass the value by reference just by const :S. The function is void, but if i change it to return int, its useless because each time i call the function, the value i want to return its created each time with a new value, beacuse i need to declare it so.. I read i can use a var such as Object but i really dont get it (im used to c++ i have to say)
I'm making a tile game in flash and I need to pass event.currentTarget (the current tile) into a new function which sends the tile back to it's start position.[code]I need to call this function from other places in my code..I've tried passing the object itself to another function as a variable but it loses it's start position information !
View 2 RepliesIs there any way to pass parameters to mc.onRelease?
View 5 RepliesInside my function there is an if() statement like this:
if(passedValue < staticValue)
But I need to be able to pass a parameter dictating whether the if expression is like above or is:
if(passedValue > staticValue)
But I cant really pass < or > operator in has a parameter, so I was wondering what is the best way to do this?
Also if the language I am using matters its ActionScript 3.0