ActionScript 3.0 :: Defining Values Of Variables For Classes, Subclasses, And Instances?

Jan 5, 2010

how subclasses,instances,and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues.Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".

Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct? I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?

Animals.as

Code:
package
{
import flash.display.MovieClip;[code]..........

Also, conventionally, what should be in my Main class? Only the addChild code which attaches MCs to the stage? Or should the values of variables be defined in Main? What am I missing? I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head.where I should be defining values of variables for classes, subclasses, and instances?

View 1 Replies


Similar Posts:


Define Vars In Subclasses, Instances?"

Jan 5, 2010

how subclasses, instances, and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues. I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".

Intuitively,I think Animals should declare that every subclass should have some animalSpecies ,and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass.Is this correct?

I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?

Animals.as
package
{import flash.display.MovieClip;[code]..........

Also, conventionally, what should be in my Main class? Only the addChild code which attaches MCs to the stage? Or should the values of variables be defined in Main? What am I missing?I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient.

View 12 Replies

ActionScript 3.0 :: Where To Define Vars In Subclasses, Instances

Jan 5, 2010

I'm trying to figure out how subclasses, instances, and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues.
 
Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct?
 
I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?
 
Animals.as
package {   import flash.display.MovieClip;   public class Animals extends MovieClip    {      public static var animalSpecies:String;      public function Animals() {}    }} 
Dog.as

[code]....
 
I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head. Can someone please explain where I should be defining values of variables for classes, subclasses, and instances?

View 3 Replies

ActionScript 3.0 :: Where To Define Vars In Subclasses, Instances?

Jan 5, 2010

I'm an AS3 newbie and I'm trying to figure out how subclasses, instances, and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues.Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".

Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct? I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?

Animals.as

Code:
package
{
import flash.display.MovieClip;[code]...

I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head. Can someone please explain where I should be defining values of variables for classes, subclasses, and instances?

View 1 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 2.0 :: Defining Variables - Unique To Load SWFs Instead Of Declaring All The Variables

Mar 21, 2012

I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.

View 2 Replies

ActionScript 3.0 :: Defining Classes And Constructors Methods?

Nov 24, 2009

It's not clear to me, where I have to define Classes and Constructor methods. In AS2 it was possible, to define a class "light" by defining a constructor method. In AS3, I read, a class can only be defined in an external AS-file. Is it still possible to use the constructor method inside the Flash-File or do I have to source out all my constructor methods and implement them into real classes into an external AS-File?

View 4 Replies

ActionScript 3.0 :: HitTestPoint And Defining A Range Of Values?

Sep 15, 2011

Is it possible to definine a range of values for the x or y parameter of hitTestPoint?

For example... hitTestPoint(100, rangeOfValues, false);

I've tried a few different things but nothing has worked so far.

View 1 Replies

ActionScript 3.0 :: Defining XML Values In The Embed Code?

Oct 26, 2010

I was wandering if there is a way to override a value that is defined in an xml file by somehow defining it as a variable in the embed code.

[Code]...

View 1 Replies

ActionScript 2.0 :: Defining Alpha Values Of Buttons

May 21, 2007

I need to make the buttons that are associated with this code, toggle, so once you press them they become greyed out. So I was thinking of after you press a button, the alpha is reduced to 40%. Can someone help me place that piece of code into this monster? -I know it should go into the presto function of my script. Which works fine, but then it stays at 40%alpha after the user click on a different button. I need it to toggle off once someone clicks on the next button. [code]

View 1 Replies

ActionScript 3.0 :: Creating And Defining Movie Clips With Classes?

Jul 18, 2011

I have 2 classes. Class "a" creates an empty movie clip and class b defines that movie clip further.

Code:

// THE A CLASS Creates an empty movie clip.
package insane
{
import flash.display.MovieClip;

[Code].....

View 9 Replies

Php :: Defining A Custom Class With Text Input Values?

Jul 13, 2011

I have another question for the masses out there regarding trying to input values from a text input box to a custom class. I currently have a custom class named Company with properties that correspond to values in a MySQL database.

So I created an input UI on the client application that calls out for Address, Name, Zip, Phone, etc. - Then there is a button to submit to values to the database for creation. Here's my question:

How do I take each individual textinput.text property and 'mesh' them all together to a Company object to send to the server? The PHP that is written takes in an argument like this:

public function createNewCompany (Company $item) { .......

So is that even the right way to send them in? Or???

There are a total of 11 things (properties) that need to be submitted.

View 1 Replies

ActionScript 2.0 :: Defining And Using Variables?

Mar 12, 2004

I posted a problem recently and I think I was asking too much too soon, I apoligise for that one. I want to try again with my problem. Basically I am making an interactive circuit builder in flash mx for 8-10 year olds (does anyone remember crocodile clips?).

[Code]...

View 8 Replies

ActionScript 2.0 :: [MX] - Defining Variables In A For Loop?

Feb 15, 2005

Here's what I've got:

var cColor1:Color = new Color(mcBut1.mcFill);
var cColor2:Color = new Color(mcBut2.mcFill);
var cColor3:Color = new Color(mcBut3.mcFill);
var cColor4:Color = new Color(mcBut4.mcFill);
var cColor5:Color = new Color(mcBut5.mcFill);

What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?

Something like:

for (var i:Number = 1; i < 6, i++) {
var cColor+i = new Color(eval("mcBut"+i).mcFill);
}

View 2 Replies

ActionScript 2.0 :: MovieClipLoader And Defining Variables?

Apr 28, 2008

using the MovieClipLoader function to load in several images into various actionscript defined movieclips. These movie clips, with images loaded into them, are going to have onRelease functions associated with them which will load in a larger version of the image already loaded. As you can picture, there are a series of thumbnails, and each thumbnail needs to be clickable and load a larger version of itself into an empty clip. However, I can't seem to define variables inside of the MovieClipLoader object as it's not technically a movie clip?

How might I know which larger file to load when one of the thumbnails is clicked? All the files are named all sorts of things, aren't in any particular order (user defined from a drag-n-drog UI)... I thought I was on the right track, until I realized I couldn't define variables within the empty clip holding the thumbnails..

View 2 Replies

ActionScript 2.0 :: [MX] - Defining Variables In A For Loop

Feb 15, 2005

Here's what I've got:

[Code]...

What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?

[Code]...

View 2 Replies

ActionScript 2.0 :: Defining Variables In A Function?

Apr 19, 2005

Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:

Code:
//define the function
function attachVid(nc, ns, curVid, vidFile) {

[Code].....

I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working.

View 1 Replies

ActionScript 1/2 :: Defining Variables From A Separate Timeline?

Jan 17, 2011

I'm having a strange problem setting variables in movie clips from another (parent timeline). I run the following code from the parent movie clip to target child movie clips it contains.

setVars = function (clip, value) {
clip.val1 = value;
clip.val2 = 0;

[Code].....
 
I am trying to set variables in a movie clip targetted by the 'clip' argument in the setVars function but they are being traced as undefined. However, setting the function works fine. I have also tried manually defining the variables in the movie clip and am still unable to change them externally from the setVars Function.

View 3 Replies

ActionScript 3.0 :: Defining Variables From Parent In Child

Mar 8, 2012

im working with my main FLA and a script for it child.as i have created a variable in the parent, "svar:Number = 0;" i would like the child to be able to modify this variable when certain triggers are met i've tried something like this in the "child.as" but im assuming its probably much more complicated

[Code]...

im wondering if there is a simple command such as this to call upon an existing variable in the parent? if not, is there a way i can import the variables using the import command?

View 9 Replies

ActionScript 2.0 :: (Flash CS3) Defining Variables To Different Buttons?

Nov 24, 2010

I'm trying to assign actions to various buttons for a website I am building, however I would also like to play a little movie first each time before linking to their individual different frames. The movie is the same for each button but then, obviously each button ultimately needs to link to a different frame. I'm guessing a nifty mix of gotoandPlay and variables are the answer but I'm getting myself in knots.

The structure of the site is as follows.On the main stage I currently have 4 frames. Each frame contains a different "page" of the website. The "home" frame has the navigation bar (including a sub-menu movie which has a number of buttons nested inside it which I think is going to be tricky). At the end of the "home" movie, there is a little fade animation which is labeled/ red flagged on the timeline - and it's this little animation I would like to have playing when a button is clicked on before linking to another frame.

At the moment the best I can manage is that when the button is clicked it goes back to the beginning of it's movie (a problem with the target paths perhaps?) as opposed to a label within the parent movie.I also think where I'm getting confused is exactly where I am supposed to define all the various variables and pieces of actionscript. The little snippits of code I have are as follows: Within the button I am trying to link, so far I have:

on(release){
_level0.frame_to_goto = "artwork";
play();
}

The "artwork" tag is the frame specific to that button (this is one of the sub-buttons that is nested within a submenu movie).Then in the movie for the webpage I have the following in the last frame of the mini animation that I want to play before the button links to the artwork frame:

stop();
if(_level0.frame_to_goto != undefined){
_level0.gotoAndPlay(_level0.frame_to_goto);
}else{
trace("An error as occured!");
}

View 7 Replies

ActionScript 2.0 :: Defining Variables For Buttons For Next Movie To Load?

Jun 28, 2005

I�m planning to make a magazine in Flash, and I would have to load several pages of it in order. But I�d like to put the buttons forward and previous on the main movie and make then load each page in a container.Is there a way to set variables for each page so the main movie "knows" what movie is loaded at the moment and what page it has to load next.

View 5 Replies

ActionScript 1/2 :: Arrays Within Custom Classes - Different Instances?

Jul 13, 2010

I have made a very simple custom class for keeping track of groups of offices for a company. The class has a Number variable to tell it how many different offices there are, and an Array to store the individual offices by name. It looks like this.

class officeCluster{
static var _className:String = "officeCluster";
// variables var numOffices:Number;
var locationArray:Array = new Array();
// functions function officeCluster() {
trace("officeCluster constructor");
}}

Now, it is my understand that when I create different instances of the class, they will each have their own version of "numOffices" and their own version of "locationArray". When I run traces of "numOffices", this seems to be true. For example,
trace(manufacturingOfficeCluster.numOffices);
trace(servicesOfficeCluster.numOffices);
yields
5
4

In the output panel, which is correct. However, there is trouble with the locationArray. It seems that as I assign different values to it, regardless of what instance I specify, there is only ONE array- NOT one for each instance. In other words,
trace(manufacturingOfficeCluster.locationArray[1].theLocation);
// theLocation is a String. The locationArray itself holds Objects.trace(servicesOfficeCluster.locationArray[1].theLocation);

Is anyone aware of any issues partaining to using Arrays within Class instances? I've been able to work around this by creating multiple arrays within the class and using a different one for each instance, but this seems very sloppy.

View 4 Replies

ActionScript 3.0 :: Collision Detection Between Two Instances Of Two Different Classes?

Jul 18, 2010

Say I have a public class named "player" and a public class named "enemy". Instances of each have been added to the stage in the maintimeline.

How do you check a collision between these instances?

View 2 Replies

ActionScript 2.0 :: Possible To Instantiate Instances Of User Classes

Feb 22, 2007

I'm wondering, is it possible to instantiate instances of user classes in the same way as you can instantiate the Object class? For instance, assuming that Vector is a user imported class:[code]I've tried that syntax or similar, and it throws me a syntax error. Is there another way to word the same idea?

View 2 Replies

ActionScript 3.0 :: Document Classes And Library Instances

Jul 14, 2009

1. I've got a Main Document class, that loads external swf each with its own document class (they are pages and pieces of the site).

2. The Main class makes use of some movieclip simply instantiated from the GUI library. It all goes fine.

3. The external swf have references to the Main class, and here start problems: when I compile them, I get an error for every library mclip used by Main. See the attachment. A simple trace(Main) is enough to start getting all that errors.

A partial solution is to uncheck Strict Mode in publish settings

View 10 Replies

ActionScript 2.0 :: Calling MX Prototype Classes And Instances?

Jun 3, 2004

i'm rockin' with creating prototype classes, however, i've run into something i can't explain when i am trying to call my prototype classes--in this case, i have a prototype class called interfaceClass, which contains several class functions--i've also created an instance of the class, called 'ui':

interfaceClass.startGame=function(){
trace("startGame");
ui.resetGame();

[code].....

View 2 Replies

Flex :: Storing Instances Of Classes In Shared Objects

May 26, 2010

Is it possible to store instances of a class in a cookie or in shared objects.

Basically in my application I have an object "Diagram" that the user can create. If they hit save, I want to store the current instance as a cookie and allows them to reload it later.

Alternatively, I could see about getting them to store the saved version on the hard disk. But even then, all I want to save and retreive is my actionscript object.

I've tried storing the object to SharedObject.data.diag, but when I try to retrieve the object from the cookie doing SharedObject.data.diag as Diag returns null.

View 1 Replies

ActionScript 3.0 :: Class Instances And Null Values?

Sep 22, 2008

I'm currently stumped by this. I've created a class to load xml data from a txt file, then assign that xml to a variable named siteStructureXml. When I trace the value of siteStructureXml from within the class instance it shows the expected xml data. When I try to assign the value to a variable returnedXml defined on the timeline of my movie, it's value traces as null. I've a feeling it's something blindingly obvious..

[Code]...

View 3 Replies

ActionScript 3.0 :: Classes - Why Static’s (not Available To Any Instances) Properties And / Or Methods Can Have A Public

Feb 17, 2009

I have a question about classes. I just learn that static means that functions and/or properties are specifics to a class, but is it a synonym of private? And why statics (not available to any instances?) properties and/or methods can have a public (available anywhere else (timeline)) access modifier? PS: I just start with classes.

View 6 Replies

ActionScript 3.0 :: Importing Classes / MovieClips - Spawning Instances Of A Symbol

Jul 6, 2009

i'm creating an application using AS3.0 and class files. in this application i have a MovieClip in the library i'm using that contains several symbols and configurable textfields and have already defined the functionality for these symbols. my question is, if i'm creating an application and through actionscript and i'm spawning instances of a symbol, do i have to define the functionality and initialize this symbol in the main application class?

specifics: i'm creating a panorama app with markers that are papervision3d planes. they use a movieClip texture that i've created and i want to configure textfields and display pictures that describe the info in the marker. i created a panoApp.as class file that configures the panorama. but i also have a marker.as class that defines the symbol's behavior. this movieclip has symbols in it it's stage that i've defined (ie: name_textfield, description_textfield, etc..) when i compile the project, the compiler errors saying that the variables/identified internal symbols are missing.

View 2 Replies







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