ActionScript 3.0 :: Adding Parameter From A Custom Class To An Array?

Jun 16, 2011

In class Main I am instantiating a custom class NavLabel that creates a textField. With in NavLabel I dispatch a custom event CustomEventWithParams on a reference to class Main that passes the parameter theLabelWidth along with it. from with in class Main i can trace the theLabelWidth for each of the instantiated NavLabel objects. I want to hold those values in an array labelWidthArray and then use them to position the NavLabel objects. how can I do this?

class Main

Code:
package
{
import flash.display.*;
import flash.events.*;

[Code]....

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Array As Parameter And Custom Class?

Dec 23, 2010

If I set my variables as type MovieClip instead of the type of the class for the MovieClip I am calling them as, will this affect my presentation in any way? Say I have a movieClip Walls with a class definition Walls. Will

var newwall:MovieClip = new Walls(); or
var newwall = new Walls();
be any different than
var newwall:Walls = new Walls();

View 9 Replies

Actionscript 3 :: Passing Custom Class As Parameter To Custom Class Where Parameter Class Not Constructed?

Jun 16, 2011

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:

[code].....

View 1 Replies

ActionScript 3.0 :: Adding Mc To Stage From In A Custom Class?

Jul 14, 2009

I have created a custom class called SceneNavagation.as which i use to add my navigation to the stage. I was having problems getting the addChild to display my mc on the stage. So I passed the stage instance into my class and used that to attach my movieclips. _stage.addChild();

This worked but Im new to as3 and just wanted to know if this was a good way to do this below is my code.

package com.lessons{
import com.caurina.transitions.Tweener;
import flash.display.*;

[Code]....

View 0 Replies

ActionScript 2.0 :: Adding Custom Class To Object?

Nov 23, 2005

For the game I am making, I'm using a self-made sprite managing system.I've got three classes: SpritesManager, SpriteGroup extends Movieclip and Sprite extends Movieclip.The idea is: SpritesManager is holding an object: "mainSprites", SpritesManager also hasa method "newGroup", wich creates a new SpriteGroup in mainSprites.In this way I want to make a system for creating and managing some sort of Movieclip-tree.For example:mainSprites.enemies.badEnemyThe method newGroup in SpritesManager has a param "name" wich is the name of the SpriteGroup to create.Here's where I'm stuck: how do I create a new SpriteGroup referenced to as "name" in mainSprites?

View 6 Replies

ActionScript 2.0 :: Adding Custom Class To Object

Jan 16, 2008

For the game I am making, I'm using a self-made sprite managing system. I've got three classes:
SpritesManager, SpriteGroup extends Movieclip and Sprite extends Movieclip.

The idea is: SpritesManager is holding an object: "mainSprites", SpritesManager also has
a method "newGroup", wich creates a new SpriteGroup in mainSprites. In this way I want to make a system for creating and managing some sort of Movieclip-tree.
For example: mainSprites.enemies.badEnemy

The method newGroup in SpritesManager has a param "name" which is the name of the SpriteGroup to create. How do I create a new SpriteGroup referenced to as "name" in mainSprites?

View 1 Replies

ActionScript 3.0 :: TypeError: Error #1009 When Adding Custom Class To Stage

May 18, 2009

I have extended a RadioButton into a custom class in order to store some extra info. I want to dynamically add these RadioButtons to the stage to create a dynamic menu box. So I started simple in order to make sure I knew how to do this.Here's the error (I love Flash IDE error reporting):

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.controls::RadioButton/drawLayout()
at fl.controls::LabelButton/draw()

[code]....

View 3 Replies

Flex :: Spark - Adding Custom Class To Implement Simple Grid?

Apr 13, 2011

To start - its best to say im new to Flex / OOP in general. I have been trying to add a custom class based on StrokedElement in order to implement a simple grid (not like the existing Flex Grids - this would just be for display - not holding elements etc...)

My current class looks like this:
package ui.helpers {
import flash.display.Graphics;
import spark.primitives.supportClasses.StrokedElement;
public class SGrid extends StrokedElement {
public function SGrid() {
[Code] .....

View 1 Replies

ActionScript 3.0 :: Array Of Custom Class - How To AddChild

Aug 18, 2010

I have an array of a custom class. The class includes 3 movieclips that all share the same position. I have 5 items in the array, and in the document constructor I fill them as such:

ActionScript Code:
glassArray[0] = new glasses(spot, beam1, glasses2, "index/nav/aboutus", new Point(156, 400));(different string and point for each of the 5 items)

Here's the glasses constructor:
ActionScript Code:
public class glasses extends MovieClip{ //I am the Constructor.
public var spot:MovieClip;
public var beam:MovieClip;
public var glass:MovieClip;
protected var target:String;
[Code] .....

It then goes on to fill each of those mclips with properties based on the point received. How to addchild from the class, I've got a simple for loop in the document constructor that adds them all in. Everything works, except what I'm seeing is that as each item in the array is added in, it overwrites the previous items' properties. In effect, I can create 5 items and give them each a different position, but when I go to addChild I see that all of them have taken on the position of the 5th one.!

View 2 Replies

ActionScript 3.0 :: Pass Movieclips In An Array To Custom Class

Dec 11, 2008

I have a custom class that animates a set of movie clips. Something like coverFlow or Carosell. What I want to do is pass a array of all the movie clips to be used by the class. I am not sure an array is the best solution but it makes sense to me. The class will not always know how many movieclips are being passed so with an array I can get the lenght and deal with it. here is the instaciation code of my class mBack and mFront are movie clips on the stage.[code]I get this error Type Coercion failed: cannot convert flash.display::MovieClip@113d2061 to Array.it kinda of makes sense why I got the error but if this is not correct how do I pass a list of mc's to my class.

View 5 Replies

ActionScript 2.0 :: Make A Custom Class Return An Array?

Feb 22, 2009

I'm making a custom class and all my get functions are working fine except the one that returns an array. Here is the code for my class (abridged to the relevant parts):

ActionScript Code:
/*
VolcanicIsland class for Polypelago
Script in progress

[Code].....

How do I get an array to return correctly? Doing trace(VI1.getData()[0]) doesn't work either.

View 1 Replies

ActionScript 3.0 :: Pushing Object To Array In Custom Class?

Dec 29, 2011

how can I push an object from my document class array to an array in my custom class?I have an instance of my custom class in my document class called "Pool".The array in my custom class is called "STOREDBALLS"The array in my document class is called "ballArray"How do I get the object from "ballArray" into "STOREDBALLS"I tried using "Pool.STOREDBALLS.push(ballArray[0])" but it didn't work.

View 3 Replies

ActionScript 2.0 :: Setting An Array As Part Of Custom Class

Sep 1, 2006

i am trying to make a custom class that has a small number of variables but I can't seem to get the array part to work.[code]I can't seem to get it to work. I can set and access the other variables OK its just the array thats giving me problems.

View 2 Replies

ActionScript 2.0 :: Array.sortOn With Objects Of A Custom Class?

Jul 27, 2007

I'm trying to do Array.sortOn on an array of custom-class objects. It's not working, though nothing in the documentation suggests that this is a problem. Below is the code. I'm confident the MetricRecord constructor is working fine because everything else works, and the traces below are correct, except they don't sort.

// This array sorts
metricRecords = new Array();
metricRecords.push({mediaVehicle:"cca", temp:"asxcvbxcber"});
metricRecords.push({mediaVehicle:"aaa", temp:"asdfertr"});

[Code]....

View 1 Replies

ActionScript 3.0 :: Accessing Function Of Custom Class That Is Stored In An Array?

Jan 27, 2011

i am making a few object of action script..,what special about this object is that in the contructor function of  this object is that i  make it to send a sprite parameter which will act  as it's parent..,var anObject:myObject = new myObject(parentSprite);and in my main project i used those object and store it in an array after adding it to the stage.i do store it to an array cause i need to be able to refer back to it..everything was fine up until i need to call function inside that object which i already stored in an array. how should i call the function in that object from an array that stored the object?

View 4 Replies

ActionScript 2.0 :: Call A Custom Function From Another Custom Function's Parameter?

Apr 1, 2008

I want to call a function from another function's parameter but I don't know how and don't know if it is possible.I've considered this as a solution but it didn't worked.

Code:
function myFunc(target_mc:MovieClip, nX:Number, nY:Number, cFunc:Function) {
target_mc._x += nX;
targen_mc._y += nY;
target_mc.onPress = cFunc;

[code]....

View 2 Replies

ActionScript 3.0 :: Create A Custom Class That Extends The MovieClip Class And Contains A Custom Property Of "marker"

Jan 23, 2010

I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).

[Code].....

View 13 Replies

ActionScript 3 :: Flex Pass Parameter To Custom Component

Feb 11, 2011

I have a custom component written in action script (no UI). I am instantiating this component in an mxml file which is present in a library project. The custom component has a constructor which takes one argument. The library project is used in some other web project from where i pass a variable to this mxml file.[I have linked source of the web project to source of library.].

I have a static variable in my library project which holds the reference of the current object of the project. I need this static variable in order to use properties present in the mxml file. I am unable to use the property sent from the web project in the constructor of the custom component, but able to use the same in some other function present in the custom component.

View 1 Replies

ActionScript :: Flash - How To Pass Parameter To Custom Component

Nov 27, 2011

I have a custom component written in ActionScript. It has constructor which is expecting some arguments.

I want to include that custom component in mxml like this,

Main.mxml
...
<custom:CustomActionScriptComponent/> // Error line ..
..

But, it shows me an error saying

Error 1136: Incorrect number of arguments. Expected 1.

How to pass parameter in MXML file, to that custom ActionScript component?

View 2 Replies

ActionScript 2.0 :: Creating Custom Components With Variable / Parameter

May 7, 2003

I want to create a component with a variable/parameter that is a method it calls when (clicked on for example). In "Flash UI Components.fla" the they do this and I studied the code but cant get it to work. The Push Button one has a click handler, but the way it is actually called in the script is like this:
this.handlerObj[this.clickHandler](this);
That bracket/parenthesis thing is not working.

View 4 Replies

ActionScript 2.0 :: Passing Parameter To GotoAndPlay In Custom Function

Dec 13, 2004

I have a custom function with parameter. I'm trying to pass the parameter to the gotoAndPlay as follows. This is where the function is called...

Code:
myButton_btn.onPress = function() {
myFunction("Apply");
}
This is the function...
Code:
myFunction = function (fLabel) {
trace(fLabel);
gotoAndPlay(fLabel);
}

Basically "Apply" is a frame label that I'm trying to send the playhead to. The fLabel paramater traces out properly, but the gotoAndPlay doesn't send the playhead to the appropriate frame label. It sends it to 4 frames before the end. It's really weird. Even if I add frames to the timeline, it still sends it to 4 before the end. I can get it to work perfectly in a "new" flash document, but not in my existing document.

View 11 Replies

ActionScript 3.0 :: Set A Default Value For A Class Parameter Of Type Class?

Feb 2, 2010

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.

[Code]....

View 4 Replies

ActionScript 2.0 :: [FLASH CS5] Custom List Class That Manages Custom List Item Class?

Dec 2, 2011

This is my first time working with a class attached to a movieclip that is nested inside a class attached to a movie clip.I've tested all the properties and methods of PTListItem.as and they work properly but when I try to call them on the list item through PTListTop.as it returns undefined.The end goal is to dynamically load a checklist via a txt file.

View 1 Replies

Actionscript 3 :: Flex 4.5 Not Listening To Custom Event Dispatched In Custom Class?

Nov 4, 2011

I have the following situation:I have an event handler, that displays small messages in my application's statusbar.These messages get passes through by dispatching events from custom components.A simple message could be like "HTTP Error" or so.Now, the main event listener, in the main application file, listens to the event dispatched by any custom component,but seems to refuse listening to events dispatched by custom AS classes.Here is my code for the custom event:

package main.events
{
import flash.events.Event;[code]..

So to sum it all up:

- The event listener listens to the custom event dispatched by any custom component.

- The event listener does not listen to the custom event duspatched by an AS class.

Those who wonder, the event really gets dispatched, that's why I added a trace call.

View 2 Replies

Flex :: Access A Custom Property In A Custom Class?

Jan 25, 2010

I couldn't work it out yet...

package components {
public class templateSelection extends VBox {
static public var tempSelectionBag:Dictionary;

[Code]....

I want to have a custom class tempSelection with a Dictionary as a public accessable property of that class. If I use this code, the compiler tells me:

1046: Typ wurde nicht gefunden oder war keine Kompilierungszeit- onstante:Dictionary

Which translates to:

Type was not found or was not a compile-time constant: Dictionary

View 1 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.0 :: Pass Associative Array As Parameter?

Oct 6, 2009

Is it possible to create an associative array w/o using a variable to pass it as parameter to a function?[code]...

View 1 Replies

ActionScript 3.0 :: Class Name As Function Parameter?

Sep 10, 2009

I wanna pass a class name as a function parameter.In that function I wanna make instances of that class, any1 know how?

View 1 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

ActionScript 3.0 :: Extend A Class That Needs Parameter?

Sep 20, 2009

i have a button class that i use like:

btn1 = new ButtonClass("Label");

i want to extend ButtonClass.but this is giving me an error.

public class EnterButtonClass extend ButtonClass

how can i pass the param?

View 1 Replies







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