ActionScript 3.0 :: Flash When Is It Worth "splitting" Similar Objects Into Different Classes?

Apr 22, 2012

I'm about to start on a side-scrolling game which will involve around 10 different characters the play could choose from and probably about 20 different enemies. Each of these will have slightly different graphics, movement speeds, attack rates, etc. but I'm wondering how to manage it. The way I see it there's two options: Have a general classes "Player" and "Enemy" with a setter method for the exact character which could set a bunch of class variables like speed, max health, etc.. Most of the code would be the same but I'd need a lot of "if" statements in some places (ranged attack vs. sword, etc.).Have a whole bunch of classes "Goblin", "Scarecrow", "Skeleton", etc. that inherit from "Player" or "Enemy". All the stats could be hard coded in individual classes, no need to perform multiple checks on which character it is, but there will inevitably be some code repetition.

I'm bearing in mind that I'll have to reference these regularly. For example, each "Player" will probably have a "target" class variable to track who it's moving towards/attacking. If I strongly type this as "Enemy" and then set it to an instance of "Goblin", for example, will it be cast to "Enemy"? Is that a bad thing performance wise? What about using Vector.<Enemy> for tracking objects on screen? I'm guessing I'll have the same casting issue if the actual objects I push there are instances of Player's sub-classes. Will it negatively impact performance to have ~30 extra classes if I go with option 2?

View 3 Replies


Similar Posts:


Flash :: Are There Any Sound Classes Similar To The S:ContentCache

Jan 18, 2012

Is there a ContentCache[1] for sound assets? Once I load in a sound I want to keep a reference to it so it doesn't have to load again. Possibly a class reference to it or to the byte array (I'm rusty here).

The reason for this is to keep it in memory so the Flash Player doesn't have to reload it so the start time (latency) is low. These are short audio clips.

[URL]

View 1 Replies

Flash :: Instantiate Objects With Similar/identical Functionality But Different Properties?

Aug 25, 2011

New to AS3, long time programmer. Essentially I am creating a myriad of objects, all of which will have the same functionality, although the properties will vary between each object, including the artwork. I believe they will all be movieclips as they will be interactive and I believe they will be moving.

I am wondering what the best way to create these objects are. I am assuming that I create an object class with the functionality and properties, I'm just unsure how to instantiate multiple copies with different properties, if that makes sense.

View 2 Replies

Flash :: Passing Data Between Objects/classes?

Dec 27, 2010

So i a building a categorized menu of different foods. I have a class for "categories" (buttons) which essentially will return a string "salads", "drinks", etc. I now have another class "menuItems" for items within categories and this handles sizes such as "small", "med", "large", etc. My problem now is that when i return "salads", i want to invoke an array which contains all the elements of salads, send it to menuItems which will populate the menu. So far i have both the category objects and the menu object setup. I just cant seem to be able to send the data that the category object is returning and pass it to the menu object. Both of which are added to the stage as shown below:

If there was a way that i could say add all these classes to one class so that they can talk to each other that would be great but i dont know how to do this.

View 1 Replies

Flash :: Objects Still Created When Omit Importing Classes?

Oct 2, 2011

I'm working through a tutorial to create an mp3 player in actionscript. When I delete my first 4 lines of code, the .swf still works great! I thought you needed to declare what classes you're importing for every object you create later on.

import flash.events.MouseEvent;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;

[Code]...

View 1 Replies

ActionScript 3.0 :: Access Other Objects On Stage In Flash Inside Of Two Custom Classes?

Jan 13, 2009

I have a CustomSimpleButton class and a CustomSprite class which creates a bunch of CustomSimpleButtons and displays them at runtime. How can I access other objects on the stage in Flash inside of my two custom classes? If I want an object tween to occur when one of my custom buttons is clicked how do i reference the object that I want to tween if I'm inside of my custom class.

View 0 Replies

Asp.net :: Is It Worth Trying To Use SOAP

Aug 31, 2009

I have a small RIA that I built as a learning/make-my-life-easier project that uses Flex and ASP.Net. Currently, my architecture utilizes straight HTTP posts and the server responds with xml. I posted another question about security in my web app and some people mentioned SOAP. SOAP is something I've never actually used and I was wondering what the pros/cons were to using SOAP over my current architecture and then subsequently, how much work is require to convert such an application to utilize SOAP.

View 2 Replies

ActionScript 3.0 :: Gaia Framework Worth Learning?

Dec 7, 2011

I've been learning greensock and I find it helpful now when studying greensock I've been introduced to Gaia does anyone here have an opinion on Gaia?

View 3 Replies

ActionScript 3.0 :: Loading 8MB Worth Of Images Into A Game?

Aug 13, 2010

In the game I am creating, I don't want to import the images directly to flash, otherwise the game will be well over 10MB and that is not a good thingamajiggy So, I am loading them in from a folder residing in the same directory as the SWF.Question - Even if a 56k user plays the game, they shouldn't have a problem receiving the files pretty quickly, considering the image folder with the 8MB+ images is in the same directory, right?

View 4 Replies

ActionScript :: Splitting Flash Design And Coding?

Oct 14, 2009

Hi, I am brand new to Flash and I come from other development environments so I have a question about a possibility. I am aware that you can have a symbol (like a MovieClip) use a custom class to handle how it responds to the world, but I was wondering if it's possible to be able to set some values via flash without having to touch code. For example, I create a MovieClip called Crate, which has a class that lets it be destroyed, but then the designer wants to specify that certain crates have contents inside of them. Is there any way to do that in flash without having to create a new class for the crate?
 
In other words: the designer puts a Crate in the world and then sets a propery (for example: contents = TennisBall) and the Crate class handles the rest. Will this work? Also, am I right to understand that instances of symbols are all the exact same? So I can't have the designer create a new instance of Crate and then change it to be a little different (like draw a sticker on the Crate), but still have it be the same as all the other Crates?
 
I hope these questions make sense and I apologize if I asked this in the wrong forum. I'm very interested in developing games for flash, especially after the news that CS5 will let you export to the iPhone, but I'd like to keep the code away from the designer as much as possible,

View 2 Replies

ActionScript 3.0 :: Flash Splitting A Display Object

Jun 24, 2010

I have text field about in the center of my stage. When a button is clicked, I want this text to split and animate out and the new text to appear. What I thought was to use the Bitmap data object and draw the content movieclip using the .draw() method and then manipulate this pixel data. But I have only done very trivial things with pixel data in actions script.

View 2 Replies

ActionScript 3.0 :: Traversing Objects Through Different Classes?

Feb 12, 2010

I have 2 classes Main.as and RedPawn.as (yes, in the same folder).I am wanting to check if a child exists on a movie clip in Main.as through RedPawn.as.This is within a for loop since I am checking 24 possible values for _dest until I find a match.This simplified code example would be in the RedPawn class:

Code:
_dest = 'example_mc'; // example_mc is pulled from an array
if ( MovieClip(root)._dest.numChildren < 2 ) { // do stuff; }

[code].....

View 8 Replies

ActionScript 3.0 :: Accessing Objects From Other Classes?

Jan 7, 2012

I want to access an object from a class in which it was not created in. I have a main class (A) in which I create and instantiate an object (of class B), from this class I can obviously do whatever I want with the object, no problem. The issue I'm having is another class (C) needs to access the object in question to change its x and y location values. Class C doesn't know what the instance of class B, created in class A, is; this doesn't surprise me, but I can't figure out how to allow class C to get access to what class A created.

View 7 Replies

ActionScript 2.0 :: Targeting Objects In Classes

Feb 7, 2005

I've got a problem targeting objects is AS2 classes. In a class I have a multi-dimensional array with paths to some mc's in the main timeline (caminho['mc']). I need to reference them via method in a class, so i use something like this:

[CODE]...

View 7 Replies

ActionScript :: Flex : Mapping Objects To Classes?

Jun 16, 2009

If I've got a bunch of plain old Objects, what's the best way to map them to a bunch of Classes?For example, if I use an HTTPService to pull in some JSON, then deserialize it, I'll have a bunch of objects which look like:

{ type: "person",
id: 42,
name: "David" }

And I want to turn them into instances of a Person class:

class Person {
id:int;
name:String;
}

(also to be considered: how about some standard way of dealing with relationships between objects? For example, if the Person had an additional "spouse" field:

{ type: "person", spouse: 61, ... } // Where 61 is the ID of the spouse
)

View 2 Replies

Flex :: Class - Create Own Classes / Objects?

Dec 7, 2009

When I try to do this in an AS CDATA block, it tells me I can't have a class declared within a class (the MX:Application itself). Makes sense. But where and how do I do it?

View 2 Replies

ActionScript 3.0 :: Accessing Objects With Linked Classes?

Sep 15, 2010

So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?

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

[cODE].....

View 0 Replies

ActionScript 2.0 :: Referring To Library Objects Via Classes?

Feb 26, 2007

I've been heavily mired in 3D recently, and decided to pay a visit back to good ole Flash.

My problem is this. I'm extending the MovieClipLoader class to create a Preloader Class (yes I'm sure it's been done fifty billion times but). I'm trying to refer to a symbol in a common library, the preloader symbol itself.

Inside my class I have this

Code:
function onLoadStart(target){
baseClip.attachMovie("preloaderTemplate_mc", "preloader_mc", 500, {_x:0, _y:20, _xscale:75, _yscale:75});
baseClip.preloader_mc.gotoAndPlay(1);
}

baseClip is a MovieClip object which takes a MovieClip passed to the constructor of the class in the FLA. (say a container movieclip which has a target clip preloaded into it) The class does load the target clip into the baseClip, but doesn't show the preloader, which makes me think I'm not referring to it properly.

View 4 Replies

ActionScript 3.0 :: Why Can't Classes Access Objects On Stage

Jul 22, 2009

Im trying to get used to packages and classes in AS3. Im used to put all code on the first frame of the timeline, but now i have 442 lines of code on the first frame. Yeah 442. And this is for a game engine so i thought i should put it inside some classes to make it easier to read an reusable. But i have noticed that if i create a class called Code and make a instance of that class like this:[AS]var codeObject:Code = new Code();[/AS]i get a bunch of errors because the class cant Acess the stage and the display list.i found a workaround by linking the class to a movieClip and and do this:[AS]MovieClip(parent);[/AS?

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

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 2.0 :: F5: Create An Array Of Values Not Objects / Classes?

Mar 11, 2005

I was wondering if I can create an array of created Classes. I have a feeling that I cannot, and that you can only create an array of values, not objects.

View 2 Replies

ActionScript 2.0 :: Assigning Tween Classes To Objects In An Array?

Jan 11, 2006

My array has a few objects that are revolving like on a carrousell...I want them to react on my mouseclick.I cant seem to get this to work...how would one make objects in an array do things?I cant even define the path to them properly, it appears that I SUCK. Allow me to present to you my little code-turdthat wont work in a million years level0.holder_mc.dot0.onRelease = function() {var xScaleT:Tween = new Tween(dot0, "_rotation", back.easeOut, 0, 1222, 2, true);

View 4 Replies

ActionScript 3.0 :: Using Classes To Add Objects To The Stage With Fluid Layout

Oct 20, 2009

I am using Gaia framework with a fluid layout at here is what I get

This is the error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.gaiaframework.FluidLayout::FluidObject/reposition()

[Code]....

View 7 Replies

Actionscript 3 :: - Access Objects Instantiated In Flex App's MXML File In Other Classes

Jul 29, 2011

I've got an object declared and instantiated in my Flex application's singular MXML file: public var CDN:CDNClass = new CDNClass; I would like to access this same CDN object (and its public methods and properties) in another class declared in a separate .as file as such:

[Code]...

But when I try to access the public method parsePlayList in the CDN object in a method in the class defined in the .as file, I get the following error: Access of undefined property CDN The reason I want to do this is to break up the logic of my application into multiple AS files and have minimal MXML files, probably only one.

View 2 Replies

Java :: RemoteObject In BlazeDS Environment: Serializing Objects From JAXB / XJC-generated Classes

May 10, 2011

I'm developing a webapp with Java backend and Flash (pure ActionScript) frontend using BlazeDS. I'm using the RemoteObject stuff to send objects, using custom serialization, where I need to implement Externalizable (Java) and IExternalizable (AS) interfaces. This works fine so far.

But now I need to send objects from Java to Flash, whose classes are generated with JAXB/XJC. Of course these generated Java classes don't implement the Externalizable interface, so it seems that I can't use my approach here. One possibility seems to be writing a XJC plugin which makes the classes implement Externalizable. But this looks like a tough job...

View 2 Replies

Auto-import As3 Classes (internal/intrinsic Flash Player Classes At Least) Using Emacs?

Aug 23, 2011

Is there any way to auto-import as3 classes (internal/intrinsic Flash Player classes at least) using Emacs ?

Looked for as3-mode and actionscript-mode but nothing working was found. as3-mode can import class if it is opened in buffer (but not *.mxml files)

View 1 Replies

Actionscript 3 :: Classes In Project Override Classes In A Flash CS3 SWC File?

May 6, 2011

I have an actionscript project which uses visual symbols from an SWC. I have a CheckoutButton which has the following class associated with it (compiled into the SWC in Flash CS3).

[Code]...

View 1 Replies

ActionScript 2.0 :: [FMX] - Splitting A Variable?

Apr 2, 2003

If I have a variable

a = 456

how can I get the numbers from it like

a1 = 4
a2 = 5
a3 = 6

View 4 Replies

ActionScript 2.0 :: Splitting A Var By Length?

Sep 15, 2004

i have a var lets say 'x' x="i like cheese and want to eat it everyday" i want to split the var x by every 10'th character, assuming the 10 chracter is not in the middle of a word , then i want it to split it before that so that no words are not cut out...

ex:
x="i like cheese and want to eat it everyday"
arr[1]="i like " 7chars causs 10th char was inside 'cheese' and spliting of words is not allowed
arr[2]="cheese and " 10 chars exactly , splits at space
arr[3]="want to " 8 chars 10th char inside eat .. u get the idea by now i hope
arr[4]="eat it "
arr[5]="everyday"

so its splitting the variable every 10th character.. if the 10th chracter is a space, if it is not it backs up to the previous space and for the next array slot starts from there

View 5 Replies







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