ActionScript 3.0 :: Pass A Parameter To The Constructor Function

Mar 3, 2011

I´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.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Pass A Child From The Constructor To Another Function?

Sep 6, 2010

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]......

View 5 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 :: Pass Function Parameter 'evt'?

Feb 24, 2012

I'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]...

View 9 Replies

Call A Function With Event Parameter When Have No Event Parameter To Pass?

Aug 14, 2009

Forgive me for this stupid noob question but I want to call a function (loadList) that originally gets triggered after a mouseevent from another function (addToXML) that does not have an event.

The loadList function takes info from a XML var, sticks it into an array which then gets loaded into a tile list and that is working fine.

The addToXML function when called adds elements to the XML var after which I want to call the first function with the event parameter so it refreshes the items in the tile list.

I know it can do this by creating a new array and loading that into the tile list in the addToXML function, but it be much simpler to just recall the function.

I have tried things like

Code:
addToXML.addEventListener(Event.COMPLETE, loadList);

but all the event constants I have tried give me error messges like "1061: Call to a possibly undefined method addEventListener through a reference with static type Function."

View 3 Replies

ActionScript 3.0 :: Pass Parameter To EventListener Function?

Dec 1, 2010

how to pass parameter to eventListener function.[code]

View 1 Replies

ActionScript 3.0 :: Pass A Reference Parameter In A Function?

Mar 29, 2011

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)

View 3 Replies

ActionScript 1/2 :: Pass Parameter To OnRelease Function

Sep 26, 2011

Is there any way to pass parameters to mc.onRelease?

View 5 Replies

Actionscript 3 :: Pass < Or > Operator Into Function As Parameter?

Jan 14, 2010

Inside 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

View 4 Replies

AS3 :: Flex / Pass Parameter In Anonymous Function?

Aug 4, 2010

In as3, I am adding event listener and then attaching the anonymous function to it:[code]Now this whole piece of code is looped n times. Now, I have n myBoxes and whenever I roll my mouse over the box, it should alert the name. But, what I see is that the last value of count is used by each box. How can I pass parameter or value to the anonymous function? ( as roll over , I believe, expects only one variable)

View 2 Replies

ActionScript 3.0 :: Pass A Class Name As A Function Parameter?

Sep 10, 2009

I ran into a problem today. Since I wanna pass a class name as a function parameter. In that function I wanna make instances of that class,

View 3 Replies

ActionScript 2.0 :: Call A Function In SWF And Pass It A Parameter From JavaScript In The Page?

Apr 29, 2004

I'm trying to call a function in frame 1 of my SWF and also pass it a parameter.

I need to do this from elsewhere on the embedding HTML page using JavaScript.

For example call the function flashFunction(foo);

Does this require a listener in Flash that listens for the call, excepts "foo" and then calls the flashFunction and passes "foo" to it?

Can this be called directly without a listener?

View 7 Replies

Actionscript 3 :: Function - Custom "call - Later" - Pass More Than One Parameter

Feb 15, 2011

I have this class ('Scheduler.as'):

[Code]..

So as you see in your test-run the first two calls work fine, the one that calls a function that takes no parameters and the one that takes one parameter. The problem is when I need to pass more than one parameter! Solving the issue: Well, I know it'd be solved if I could simply retain the ...args as is, and pass it on to the this.m_function.call call. Another way, maybe is to have some sort of a foreach loop which would feed the designated ...args when the time comes, yet again, how would I refer/pass it?

View 1 Replies

ActionScript 3.0 :: Library Object's Constructor Can't Have Parameter's

Oct 11, 2009

I have a class in my .fla's library called StatBar_object. StatBar_object is an inherited class that extends from a custom class StatBar, while StatBar extends from MovieClip.

However, StatBar's constructor has a parameter (the constructor reads "public function StatBar(target:int)"). Thus, I continually get an output of:

"ArgumentError: Error #1063: Argument count mismatch on StatBar_object(). Expected 0, got 1.
at actionscript.stat::StatBox_object()
at actionscript.modes::battle_mode()"

Is there any way to get StatBar_object's constructor to include StatBar's parameter?

View 8 Replies

ActionScript 3.0 :: Error On Using An Untyped Parameter In The Constructor Of A Document Class?

Aug 9, 2010

I got an error like "Incorrect number of arguments.. Expected  0." when I was trying to make an instance of a user-defined class that I've written in the document class of my project.Here's the line in my document class:private var myNotice:myNoticeClass = new myNoticeClass(this);An untyped parameter is supposed to be the only argument to the constructor method of class myNoticeClass and the constructor is something like this

public function myNoticeClass(ref:*)
{ ......
}

[code].....

View 7 Replies

Actionscript 3 :: Pass All Parameters (one By One) In An Object To A Constructor?

Dec 1, 2010

I have the Class and the parameters of its contructor as an object. What I need to do is a function that returns an instance of this class, passing this parameters to the constructor.

This is the code:
Some random and unmodifiable class:

public Foo {
public function Foo(a:int, b:String) {
// constructor
}
}

And some function (in some another class):

function bar(params:Object):* {
var baz:Foo = new Foo(params.a, params.b);
return baz;
}

What I need to do is make this function generic, without pass params as parameter to Foo constructor because I can't modify it. Something like:

function bar2(clazz:Class, params:Object):* {
var baz:* = new clazz(/*some magic way to transform params in comma separated parameters*/);
return baz;
}

View 3 Replies

Actionscript 3 :: Pass Class As Constructor's Argument?

Oct 26, 2011

I'm trying to pass my object class as constructor argument. I have something like this:

package myclass {
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;

[code]....

Now, when I try to create my Example:

import myclass.Example;
var example:Example = new Example(myObjClass);

I get message, that I'm not passing any variable (Error #1063). Why is that? What is wrong with it?

View 1 Replies

ActionScript 3.0 :: Pass Value To Document Class's Constructor?

Jun 24, 2009

I want to pass values to document class's constructor form html while embedding.

View 2 Replies

ActionScript 3.0 :: Pass Array Of Arguments To Constructor

Apr 17, 2010

I'm passing a DisplayObject to a command that will instantiate it. Something like this:

// ViewClass is passed into this method typed as a Class
var view : DisplayObject = new ViewClass() as DisplayObject;

Is there a way to pass arguments to ViewClass() without knowing it's type? I'm assuming the list of parameters passed to any object's constructor is an array, but I'm not certain how to proceed.

I know I can do something like this:

// Assume arguments, an Array of arguments, has also been passed in
var view : DisplayObject = new ViewClass(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]) as DisplayObject;

But clearly I'd like something more dynamic, like to be able to just pass the arguments Array directly. I suppose all of this, however, goes against any type safe checking

View 5 Replies

ActionScript 3.0 :: Pass Variables To Base Class Constructor

Sep 8, 2009

I have a bunch of movieclips( clip A and B for this example) in my library that I want to use the same base class (MyClass.as in my example). I assigned the same base class in each clips property window and then gave each clip a unique class name which doesn't exist so flash says it will create the class automatically.

Now if I create a bunch of A's and B's on the stage via actionscript, how would I send variables to the constructor in MyClass.as without having to creating A.as and B.as to pass the variables along to the base class? if I do: Var newA:MovieClip = new A (argument 1, argument2, etc) It says it expects 0 args since the A & B classes were created automatically by flash.

View 9 Replies

ActionScript 3.0 :: Pass Reference To Stage In Class Constructor?

Aug 25, 2009

when to use this in a classes?is there any specific rule?is it wrong to use this when you want to just access the stage that way?or is it better to pass the reference to the stage in the class constructor?

View 5 Replies

Actionscript 3 :: Flash: Pass Constructor Arguments To Objects Placed On Stage?

Feb 28, 2010

Is it possible to pass constructor arguments to instance objects which I place on the stage? Are the instantiations of instance objects centralized somewhere as with .NET WinForms so I can just edit the xxx = new CustomRecangle() constructor?

public class CustomRectangle extends MovieClip {
public function CustomRectangle(width:int, height:int) {
this.width = width;
this.height = height;
}
}

View 4 Replies

Flash :: Use Apply() With Constructor To Pass Arbitrary Number Of Parameters?

Oct 6, 2010

I've got a function wich can accept a varible number of parameter with a rest operator. I want create an object passing the argument collected with the rest operator directly to a constructor without create an object and call an initializing function and without passing the entire array but the parameters ah I do with apply() function.

[Code]...

View 4 Replies

ActionScript 2.0 :: Pass Constructor Arguments Into An Instance That Extends The MC Class?

Apr 17, 2007

For example, I have the class Bullet, with a constructor: Bullet(start:Point, target:Point)constructor

But, if this Bullet class extends the MovieClip class, how do I pass start and target into it? Right now I am using attachMovie to create instances of the class. (They behave correctly with the static properties set by the constructor, but to be useful it needs arguments.)

View 3 Replies

AS3 :: Flash - Pass Parameter By Value?

May 6, 2010

im having problems with the following code:

for (var i:Number=0; i<numFaces;i++){
var faceLoader:Loader = new Loader();
faceLoader.contentLoaderInfo.addEventListener( Event.INIT,
function(fle:Event){

[code]....

The problem is that im sending the variable i to the function LoadCara on every iteration, and its always called with the last value of i. I would like this function to be called with the appropiate index.

View 2 Replies

Actionscript 3 :: Pass Arguments To Constructor If Object Is Loaded Dynamically With Loader In Flash?

Apr 11, 2011

Is this possible ? If yes how ?Otherwise what's the alternatives ?

By dynamically I mean using
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);

[code].....

View 2 Replies

Actionscript 2.0 :: Get URL Parameter (Pass It From HTML To Swf)?

Jun 14, 2009

I'm trying to get a URL parameter in my flash...The parameter is a xml url...
 
testXML = new XML();
testXML.load(xmlurl);I tried every code I can find on the web and couldn't find a solution to get xmlurl
  
I tried var xmlurl:String = String(_root.loaderInfo.parameters.xmlurl); but it didn't work...
_global.xmlurl didn't work either
 
Here is my HTML:
 
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="590" height="300" id="test" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="test.swf?xmlurl=data.xml" />

[code]....

View 16 Replies

ActionScript 3.0 :: Pass A Parameter In A Class?

Dec 16, 2011

I have seen this code in ultitouch gesture samples. But I don't kno how can I pass a bitmap parameter to the statement  [Embed(source="imagenes/prueba.jpg")], how can I use this code with other bitmaps using parameters in this class?
 
package
{
import flash.display.Bitmap;
import flash.display.Sprite;

[Code]....

View 4 Replies

Pass Array For Inspectable Parameter?

Jun 21, 2010

When I create a custom component, I define a property which is array that could accept values from the enumeration, see code below:[code]...

I would like to know how I can pass array of values to my component from MXML application that uses my custom component.

View 1 Replies

Actionscript 3 :: Pass (MovieClip) As A Parameter?

Mar 14, 2011

How can I pass the keyword this OR an instance name as a parameter inside a function?

function (reference:InstanceName):void // kind of what I want
{
reference.gotoAndPlay("frameLabel");
}

View 2 Replies







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