ActionScript 3.0 :: Pass Movieclip To Function?
Oct 27, 2010I'm trying to make some tables. I have some movie clips:
cella1
cella2
cella3
[code]....
I'm trying to make some tables. I have some movie clips:
cella1
cella2
cella3
[code]....
How can I combine the following functions and still pass a different string to the buildUI(); function?
I have two functions that do the same thing only at the end they both call a function and pass a String value to the function. This string value is the only thing different.
Below is are my eventlisteners and functions as they are now:
female_start.addEventListener(MouseEvent.MOUSE_DOWN, startFemale);
male_start.addEventListener(MouseEvent.MOUSE_DOWN, startMale);
//FUNCTIONS THAT DO THE SAME THING AND BOTH CALL buildUI BUT PASS A DIFFERENT STRING.
[Code].....
why wont this work?
some_mc["nested_mc_name"].onPress = function():Void {
trace ("test")
};
I'm trying to make a dynamic function so I can pass a string var for the name of any nested movieClip I want on the fly.
it seems to me that when you use laco tweens and callback a function, you can't pass data in that function, because the function won't wait until the tween is finished but is being carried out right away. For instance, I want to tween movieclip MC:
[Code]...
I have a movieClip named MC, and it's enabled with action script, with the class name MC_Rectangle and a Stage.I override the MC_Rectangle class file in a mc_rectangle.as external file.here is the code:
package{
import flash.display.*;
import flash.events.*;[ code].....
I have new a object in the main stage var
mc_rect:MC_Rectangle = new MC_Rectangle()
in main stage:
1. how can i access the variable "sequence" in "mc_rect"
2. how can i pass parametre from main stage to mc_rect via function setSequence(data:int)?
3. how can i call the function in addSequence() in mc_rect.
in asp.net, i usually use mc_rect.sequenct,mc_rect.setSequence(data), mc_rect.addSequence() to achieve my goals......btw, can function in mc_rect return out result to main stage?
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.
My 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 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 RepliesHow 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.