ActionScript 2.0 :: Define A Custom Class To Be An AsBroadcaster In The Classes Constructor?

Feb 22, 2007

Can I define a custom class to be an AsBroadcaster in the classes constructor?

Code:

class myClass{
function myClass(){
AsBroadcaster.initialize(this);
}
}

And if so will that give me the ability to addListeners to an instance of that class?

The reason I want this approach is because I want to broadcast events from inside one of the custom classes methods and I want a textField on the stage to be listening for that broadcast message.

View 3 Replies


Similar Posts:


Actionscript 3 :: Flash Define Variables Before Or In Class Constructor?

Dec 15, 2011

what is the difference between something like

package {
public class Myclass {
var txt:TextField = new Textfield();

[code]....

View 1 Replies

ActionScript 3.0 :: Passing Arguments To A Custom MC Class Constructor?

Oct 30, 2011

I'm having trouble with the constructor for a custom Class tied to a library MovieClip.
 
Say I have a MovieClip in my library named Circle, which is tied to the class com.shapes.Circle . I want the Circle class contstructor to take 2 arguments, xScale and yScale:
 
public function Circle(xScale:Number, yScale:Number) { }
 
However, if I try to call that from in code, for example Circle ball = new Circle(3.14,2.0); , I always get an "Incorrect number of arguments. Expected 0" error.
 
Is it possible to have a custom class tied to a MovieClip that can take arguments, or does Flash not allow this? I'd asked about this before and thought I figured it out, but from looking at it now I apparently hadn't figured it out and had resorted to a sloppy workaround; I'm hoping to fix it now.

View 12 Replies

ActionScript 3.0 :: Custom Class Extending MovieClip - Constructor/assignment?

Jul 10, 2009

I've got a simple class:
 
package somepackage
{
import flash.display.MovieClip;

public class NewMc extends MovieClip{  public var myVar:String = "something";}}
 
And there is a question now: how can I assign a "real" MovieClip object to my created-class object?
I mean: var realMc:MovieClip = new MovieClip();

[Code]...

View 6 Replies

ActionScript 2.0 :: Custom Class Instance Doesn't Recognize Own Constructor

Aug 18, 2011

I'm having a problem with customized Actionscript objects not recognizing thier own constructor. This is the pertinant part of my script:

ActionScript Code:
//File: Line.as
class Line extends Object{
public function Line(args){

[Code].....

Clearly, the variable "testLine", is one of my custom "Line" objects. Clearly, it has been made with the "Line" constructor. So why won't flash acknowledge this?

View 3 Replies

ActionScript 2.0 :: Custom Classes Keep A Reference In The Class

Dec 21, 2011

I'm adding many custom classes on stage using the object.registerclass trick. Those classes all implement the same interface so I can call common functions for all of them. My problem is that I have many of those custom classes for which I keep a reference in the class where I'm attaching them to the stage with attachmovie. So, in this parent class, if I do a for in loop like this:

[Code]...

View 4 Replies

Data Integration :: Loading XML Using A Custom Class And Accessing It From Other Classes?

Aug 30, 2006

I began with a class for a movie clip rollover function FigureRollOver. It works marvellously. Three things happen:

1) it loads XML from a file "mod1_fig1.xml" and uses another class, XMLMember, to retool the scoping of the XML so that I can get at it

2) an onload call inside of XMLMember calls the myOnLoad function and transfers the XML into an array.

3) so long as the array is finished building, rolling over a movie clip attaches a new movie clip with the rollover text in it.But I don't want all those functions in one because I need it to be more dynamic, starting with being able to load any old xml file instead of just "mod1_fig1.xml", plus it seems lik overbuilding to have all of that in one class, so I've separated out the loading of the XML and building of the array into its own class, FigureXMLLoader. FigureRollOver is then left to just attach the rollover with text in it, extracted from the array built by the new class.

Problem is, though the array builds inside FigureXMLLoader, I can't figure out how to make it available outside the class. I know that I'm constructing things in the wrong order, and that the array needs to be somehow built inside the class function to be available, but I can't figure out how to do that. A cruddy work-around is to put a function call at the end of the building of the array, which calls yet ANOTHER function on the main timeline of my .swf to put the array I've just built into a new variable.This works, but it's messy. It seems like I should be able to have one line of script in the .swf that generates an array on the main timeline (or just a public array) which I can then access from my FigureRollOver class:

var myRollOvers:Array = new FigureXMLLoader("mod1_fig1.xml");

Here is FigureXMLLoader (see comments in the code for more details) which obviously does not return an array as it is, because of all the working around I've had to do. Note the "testing" variable, which can be traced from the main timeline of the .swf, but I will get "not what I want" because of course the array hasn't been built yet, and never will be, inside of the declaration as it is. How do I get it in there so I can return an array?

View 2 Replies

ActionScript 3.0 :: Custom Base Classes And Custom Classes

Jun 25, 2009

I've created a base class to house some basic functions I'd like to have across several movie clips in a game I'm making, however, when I link a custom class to the same movie clip I get the message; "The base class will not be used because the class specified is already defined and extends its own subclass. If you wish to use the base class, specify a class name in the Class field that will be auto-generated or enter the default base class 'flash.display.MovieClip' in the Base Class field." I removed the 'extends MovieClip' inside the Class but it still shows the message. Does this mean that I cannot use a custom class and a custom base class on a movie clip?

View 2 Replies

ActionScript 3.0 :: Classes - Define The Objects & Variables?

Oct 27, 2010

m new to as3 & am trying to make a platform game. i'm just not sure how to define the objects & variables. like my character & any other object i want it to collide with will be sprites, but im not sure where to go from there.

View 2 Replies

ActionScript 3.0 :: Classes And Inheritance Of The Constructor?

May 8, 2009

I have three classes (shown below, after the problem description).The first class (InteractiveStrategy) is the main class definition. In there I declare and instantiate two variables, download and upload, both of DataTxRx class.

On instantiation the folowing error pops up>> 1203: No default constructor found in base class strategy:DataTxRx public function Question(){ The second class, DataTxRx does two things only, either to download data or to upload data. As shown in its constructor, if the required parameter 'direction' is equal to DOWNLOAD, it calls the DownloadData() function. Similary, it calls the UploadData() if the required parameter is equal to UPLOAD.
 
The third class, Question extends the DataTxRx class, but itself has no constructor. However it has other methods(not shown) for adding, modifying and deleting questions anomg others.
 
package strategy{
import flash.display.Sprite; import flash.events.*;
import strategy.*;

[code]....

View 4 Replies

Actionscript :: Constructor For Value Object Classes?

May 9, 2011

Is it OK to use the constructor to set properties for a value object class or must I use dot notation and set each one, one-by-one? I recently read an article that was saying I should do it one-by-one as value objects should only contain properties and went on to say using the constructor is not OK (best-practice wise).

Code:
("not OK")
var employee=new[code].............

View 1 Replies

ActionScript 3.0 :: Constructor Functions Of Multiple Classes?

May 16, 2009

I have a rather general question regarding OOP. How do constructor functions execute with multiple class extensions? I'm making an orbital physics simulation, and every spatial body is of the class SpaceObject, which extends Sprite. Then, I have all earth-type planets be of the class Earth, which extends SpaceObject. There are certain parameters that I'd like to set for every single SpaceObject (like position and size) in the constructor function, and certain parameters (like density and mass) that I'd like to set in the constructor of class Earth.But from the main timeline, when I create an instance of class Earth, I can only enter the parameters of the Earth constructor, ie

Code:
var planet1:Earth = new Earth(density, mass)
Or I can create an instance of SpaceObject:

[code]......

View 2 Replies

Actionscript 3 :: Flex 4: Can't Define S:layout For Subclasses Of Classes Extending Group?

Sep 9, 2011

I'm trying to create a base class for components by extending Group in Flex 4, but I can't seem to define the layout through MXML. Any time I try to move the definition to a subclass of my base component, I get the following error:

Error: Could not resolve <s:layout> to a component implementation.

Judging by that error, it seems that some magic from the framework's side goes into assigning it for a Group and thus the compiler fails when trying to assign it for any other classes. Does anyone know how this is supposed to work? how to allow me to define it in subclasses?

View 1 Replies

Actionscript 3 :: Define A Custom Operator?

Mar 16, 2011

How can I define a custom operator - for example equality operator - for a custom class?

View 1 Replies

Flex :: MXML Views - Passing Dependencies Into Constructor Of Classes

Oct 6, 2009

I'm used to building applications using pure AS3. I always pass dependencies into the constructor of classes I make, but this method seems to not work out well for Flex MXML views. It seems like I should define setters on the MXML class, which map to attributes in the tag/class instantiation. But using this method I cannot specify which properties are required and in what order I expect them etc. What is the preferred method to give a Flex view it's dependencies?

View 3 Replies

Flex :: Define Custom 'contentGroups' In A Custom Flex 4 Component?

May 12, 2010

The spark panel component for example can be written like this

<Panel title="Skinny">
<child components ... />
<controlBarGroup>
<child control bar components ... />
</controlBarGroup>

[Code]...

The motivation here is that I can now create a couple different skin files to change the look and layout of those subgroups. Reading source of the spark panel, there are some calls within the mx_internal namespace such as getMXMLContent() which is a method of the spark group component, but which I have no access to.

Does the description above make sense? How can I create custom 'contentGroups' in my custom Flex4 component that can use nested mxml child components? Should I approach this a different way?

View 2 Replies

ActionScript 3.0 :: Create A Class File To Define A Class Called SimpleSquare

Feb 14, 2011

i) Create a symbol called SimpleSquare. This should consist of a simple red square graphic

ii) Create a class file to define a class called SimpleSquare. This should be linked to the SimpleSquare symbol. SimpleSquare ashould have the following functionality: When the instance is placed on the Stage, it should start to disappear by decreasing its alpha at 0.01 in every frame (hint: alpha)

View 1 Replies

Flex :: Define A Class Implements ICollectionView - Which Can Use As ComboBox Or DataGrid's DataProvider(not Build-in Class)

Aug 19, 2010

recently, I research for the collection framework, and find LinkedSet(AS3Commons collection framework,it is a good opensource framework) written in ActionScript, but it can't use as dataProvider in ComboBox or DataGrid, because only implements ICollectionView can use as dataProvider. So I want to try if a class implements ICollectionView can work or not. I know Flex has build-in class implements ICollectionView, but I only want to define a class not use build-in class. The class as simple as possible.(can work is enough)

View 1 Replies

ActionScript 2.0 :: Class Scripts May Only Define Class Or Interface Constructs

Sep 7, 2007

i am working on a project where i have some common code which i import in different movie clips and different files the code is in actionscript 2 in an external .as file. this is not a class its just a bucnh of functions and temporary variables.Problem is when i use the check syntax button or auto format button i get the following error."ActionScript 2.0 class scripts may only define class or interface constructs."this used to work fine in flash 8 but it always gives this error since i started using flash 9.the code works fine too. its just that my auto format button and the check syntax doesn't work.

View 5 Replies

ActionScript 3.0 :: Define A Custom Data Type In Flash?

Sep 16, 2009

How can I define a custom data type in flash? for example in C/C++ I can do something like this:

[Code]...

Is there a way something like this can be done in flash? Basically I want to be able to create my own variable types.

View 3 Replies

ActionScript 3.0 :: Declaring Variables In A Sub Class But Using Them In The Base Class Constructor?

Sep 20, 2009

I am creating a Weapon class for a game and the weapons itself will be the sub classes. The sub classes will hard code some values (such as max ammo and the weapon name).

I trying to access this declared data in the base class constructor, at the moment it's not outputting the values. Is this possible?

I've broken my Weapon class for simplicity:

ActionScript Code:
package
{
import flash.display.MovieClip;

[Code]....

My current workaround is creating a protected method in the base class to trace the information and calling that method in the sub class's constructor, this works fine but this doesn't seem like the most efficient technique?

View 7 Replies

Javascript :: Define A Custom Selection / Mask On An Image (script Online Just After An Upload)

Mar 12, 2012

I'm looking for a script which allows the creation of a custom selection on a image online. This step is just after an upload. As a picture is worth a thousand words:

View 1 Replies

AS3 :: Clone Class Object When Class Has Parameterized Constructor

May 9, 2011

I want to clone a class object. I tried following from here:

package
{
import flash.net.registerClassAlias;
import flash.utils.ByteArray;

[Code]...

BUT this only works when the class has a default constructor and not when it has parameterized constructor:

how to clone a class object when the class has a parameterized constructor?

View 2 Replies

Actionscript 3 :: Creating Dynamically Flex Custom ItemRender (Constructor)?

Sep 4, 2009

am creating some Advanced Datagrid with actionscript. I have created an actionscript class where I extend the VBox object:

[Code]...

View 3 Replies

ActionScript 3 :: Flash - Define Custom Behaviors For The Android Phone's Volume Buttons Using Adobe AIR?

Aug 19, 2011

For buttons like the MENU or BACK button you can just add a listener for KeyboardEvent and check if the event keyCode is Keyboard.BACK or Keyboard.MENU.However I don't see anything for knowing if the phone's volume buttons were pressed.Is there a way to listen for volume up and volume down keyUp/keyDown events in AIR (ActionScript 3)?

View 1 Replies

ActionScript 3.0 :: Import Other Classes Into Main Class Or Extend Other Classes To Main Class?

Aug 1, 2011

how to get a Class file up and going in Flash and that works fine but say I want to import other classes. I try "import testCass" above in my import statements section of my as file and that doesn't work. What do I have to do to get that to work?

View 6 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 :: 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 2.0 :: Error "class Scripts May Only Define Class Or Interface Constructs"

Aug 13, 2006

i have incuded an AS file in my fla. But is gives an error ball.as: Line 73: ActionScript 2.0 class scripts may only define class or interface constructs.

[Code]...

View 1 Replies

ActionScript 2.0 :: Define A Simple Class?

Sep 6, 2009

I'm tryin' to define a simple class in actionscript2 but I receive some errors.Here's the code done in actionscript editor: (name of the file is NavaSpatiala.as)

Code:
class NavaSpatiala
{ // proprietate publica numita viteza (data membru)
public var viteza:Number;

[code]....

How I can use import command in class1.fla (I mean what is the contents of class1.fla when I use command import to import external class defined in NavaSpatiala.as) if I copy this code to NavaSpatiala.as to solve this error:

Classes may only be defined in external ActionScript 2.0 class scripts. line 1

I need to get rid of this error:

Code:
Classes may only be defined in external ActionScript 2.0 class scripts. line 1

View 4 Replies







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