I'm working on an accordion component and I was thinking that it'd be cool if I could write a very basic one and then set it up so that it would be possible to pass in any kind of container class and child class so long as they subclassed a particular parent or implemented an interface (haven't really gotten that far yet).
What I've noticed though is that I can't setup a default class for my constructor parameter. For example I'd like to do this:
Code: public function DropDownList(containerClass:Class = ContainerSprite, childClass:Class = ChildSprite) However it gives me the following error: 1047: Parameter initializer unknown or is not a compile-time constant.
Does anyone know what is the syntax to use for a function's default parameter when it's a Vector? You can easily create a default value for an int or Number or even an Array, but what about a Vector?
Let's say I have a Custom Event Class, and it has several Event types stored in static Constant:
[Code]...
Is there an easy way to validate that the type passed to the Constructor is one of the Static Constants of the Class, without having to check it against each value?
instance is a public static variable on the default class, Main. I can do Main.instance.defaultClassFunction() with no problems at all, I use it to access functions and variables from within other classes. Is it possible to use this method to call a function on the subclass, currently I have to do this,
I have a custom class being constructed from my main class. In the custom class it has another custom class that is passed in as a parameter. I would like to strictly type the parameter variable but when I do, 'the type is not a compile type constant etc'.This, I understand, is because the custom class used as a parameter has not yet been constructed.It all works when I use the variable type ( * ) to type the parameter.I suspect this is a design flaw, in that I am using an incorrect design pattern.It is actually hand-me-down code, having received a large project from someone else who is not entirely familiar with oop concepts and design patterns.
I have considered using a dummy constructor for the parametered class in my main class but the passed in class also takes a custom class (itself with a parametered constructor). I am considering using ... (rest) so that the custom classes' parameters are optional.Is there any other way to control the order of construction of classes? Would the rest variables work?edit)in main.as within the constructor or another function
var parameter1:customclass2; customclass1(parameter1); in customclass1 constructor:
This code seems to compile fine in the IDE, but the command-line compiler (SDK 4.5 mxmlc.exe) reports "Parameter initializer unknown or is not a compile-time constant."
package { public class Constants { public static const CONSTANT : int = 0;
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.
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."
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.
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?
Essentially, I have a function with three parameters, that works fine when I type in the parameter values. The function is tweens(MCname, targX, targY) and it runs properly when I use tweens(btn1, 150, 200) for instance. I need the function to move 6 different movie clips, one at a time, and I am using a variable (Counter) and an if statement to tell the function to run again after one of my tween classes finishes. The code all works, and it will run six times with the same clip if I just type in one of the movie clip's instance names as the MCname parameter.
BUT, if I try to use a variable (BTNname) to serve as the MCname parameter, it will not work, making it so I cannot apply the function to my 6 different movie clips. I put a trace on the MCname parameter, and it returns the correct value (btn1, btn2, btn3, etc) but it is not moving the corresponding movieclips. I've tried a number of different methods, but nothing will work.[code]...
I'm trying to program a race timer with OOP, and I've been adding more and morefunctionality to its class. Everything had been running well, until I had the idea to put a countdown() function, to make a cool countdown effect. Things got worse when I wanted to make the countdown function to call another function when the countdown effect has finished.The code runs well when I first pass a function parameter from the Main class to the Timer'scountdown() function. The problem begins when I want that function to be past again on other private function of the same class, because this time, the function becomes nullOn the Main class constructor, I 've written the following line:
I am sending a name of a function via parameters to another function. This allows more usage of a single function. However, the button commands work every-so-often. The message appears everytime with no problem.
Code: _root.msgReveal("This is just a random message. Click the ok button to close.", false, true, false, false, _level0.msgHide(), false);
Simply said, I want to have an inputtextfield, a button that is linked to the textfield and a dynamic textfield as an display, to display stuff, which comes from the inputtextfield and the button.Then, I want to have items in the actionscript, like item1 = 5, or item1 = 1a, or 1a = item1. Just some code that equals to another code. But for now item1 = 5.For the button that is linked to the input textfield, has to calculate something when pressed and the dynamic textfield will display it. So if I would type in the inputtextfield 5 and press the button, it will be as example multiplied by 2, so the dynamic textfield will show 10.
Still following? The point is, I know how to set something like that up, but what I want is that when I type item1 in the textfield (which equals to 5) and press the button the dynamic text will show 10, because "2 x instance name inputtextfield" (in which intem 1 is typed, which equals 5) should be 10 right? But when I try to do this, the dynamic text will show nothing or some error. but when I type directly in the code "2 x item1" and press the button it will show 10. But I want it to double link, so "2 x (instancename inputtextfield which equals to what is typed in the field, this case: item 1 which equals to 5) and not that it stops to item1, so it will freak.
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?
Let say I have two type object, one is MovieClip and other is Sprite, then I'm creating a function to access its child. ActionScript Code: function accessChild(parentObj:Object, childObj:Object):void { trace(parentObj.childObj); }
Then using "Analyze Project Source Code..." from FlashDevelop tools to analyze my code, I've got an error message: "Do not use Object class. It is a bad practice to use the dynamic class Object. Prefer using strongly typed object, or marker interface in order to avoid silent compilation errors while refactoring". What type of object should I use in the parameter if I don't know the type of object if using an Object class as type object is a bad practice?
public class ribbon extends Sprite { private var fallAmount,taper; public function ribbon(FallAmount=50,Taper=0.2){ fallAmount=FallAmount; taper=Taper; }
When I export assests for actionscript the defaul package is empty it there change to change it? To each time I export library asset for actionscritp default value for class field will contain package?