ActionScript 3.0 :: Referencing A Class From A SQL Table?

Mar 5, 2011

I'm working on a game that pulls most of its information from an SQL table. The game itself has several different items that derive from a BaseItem class, and all have widely varying behaviors. While deriving these classes from the BaseItem class and scripting the correct behavior is easy enough, I'm having a bit of trouble trying to come up with an efficient way of storing the information for these items so that not only will the items be in the state that the user left them when they were last saved to the database, but they will be the correct item when loaded from the database in the first place. I'd like to do this with as little pollution of the iteminfo table as possible (for instance, I want a Truck item to have a "wheels" value of 4, but I don't want an item_wheels field on the row if the item is Pogo-stick).

So far, my best idea has been giving iteminfo an "itemtype" field that accepts an enumeration, like ITEM_TRUCK or ITEM_POGOSTICK, and using a switch statement in AS3 to instantiate the correct item based on the pulled value, but this seems rather sloppy.

The thread title says that I want to reference a class directly from a table, but if I knew how to fix this I'd have done so already, so I'd love to hear any solutions. And just for the info: I'm working with a combination of AS3, PHP, and MySQL.

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

Actionscript 3 :: Referencing Variable In Document Class From Another Class?

Mar 11, 2011

I need to increment an integer variable in a function within the document class upon transpiring event in another class. I can't seem to figure out how to call the function and reference the variable.

View 2 Replies

Actionscript 3 :: Use Transformation Table In Matrix Class?

Aug 2, 2011

How can I, if it's even possible, use this transformation table provided in my question's accepted answer here in Actionscript 3 in Flash? I understand it might have something to do with Matrix, but I really have no clue if that transformation provided in the answer is possible to implement there. Is it? If so how?

View 1 Replies

ActionScript 3.0 :: Referencing Class Objects From Class?

Jun 19, 2010

I have an enemy on the stage that reads whether it's being hit by a bullet by a hittest. There's a for loop inside the enemy's class that looks for all the bullets and names the bullet that's hitting it "hitBullet". What I'd like to do have an easy way of seeing what type of bullet is hitting the enemy. I'm basically looking for something like

if (hitBullet == RegBullet) {
//do regular bullet dying
}else if (hitBullet == ClusterBullet) {
//do clusterbullet dying
}

, where RegBullet and ClusterBullet are classes. But I have no idea what hitBullet is equal to when a ClusterBullet or RegBullet hits it. I traced hitBullet to see what it would return and got "[object ClusterBullet]", but I'm not sure what that would be in the actual code.

View 2 Replies

ActionScript 3.0 :: Referencing To A Class From Another Class?

Sep 27, 2009

I have a class called Circle and a class called ShapeFade, both with their own .as files. How do I add an instance of ShapeFade to Circle inside the Circle constructor? Like in the Circle file:

PHP Code:

public function Circle () {
this.addChild (ShapeFade);
}

Also, can I override a class function from the code window in the stage?

View 6 Replies

ActionScript 3.0 :: Referencing A Library Class?

Mar 17, 2009

In As 2 you were able to reference a linkage ID using a string.Example

Code:
var strName = 'home';
attachMovie(strName+'_mc', strName, 1);

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing Parent When It Could Be Of Any Class

Nov 17, 2010

I usually would call the parent of my class by something like:
MyCustomClass1(parent).thisFunction();
My problem is this works if I know the class of my parent. How do you handle the case where you class could have a parent of 2 or more possibilities?
parent.thisFunction(); // throws error of course

View 3 Replies

ActionScript 3.0 :: Referencing Parent Class?

Mar 16, 2009

A have two classes: Main and Navigation. I try to referenceobject in Main class from Navigation class based on the buttonnumber I clicked. Doesn't work as I want it to work. What can I do

View 1 Replies

Referencing Other Movieclips Within Actionscript Class

Jan 17, 2010

I have externalized the actionscript code of a movieclip into a separate class files.This movieclip requires references to some other clips on the stage. What I am currently doing to reference those clips is by using Movieclip(this.parent).otherclip but somehow that feels wrong.Is there a better way to pass in the required references into a class extending from Movieclip inside of the constructor? Or what is the recommended pattern here?

View 2 Replies

Flex :: Referencing Class Variables?

May 3, 2011

I have a bunch of variables in a class. There are situations when I want to set then to null/ "temp" etc as per a well defined logic. The challenge is to list out the variables at multiple places- tedious and error-prone.

classname.speed=NaN
classname.speedtype="not_set"
classname.distance=NaN
classname.distancetype="not_set"

would prefer a way to refer to these variables programatically and set something like "for all class variables- if variable ends in type, set as "not_set"; for other variables set as NaN How can I achieve this?

View 2 Replies

Android :: AS3 Referencing Class From Timeline

Dec 10, 2011

I can import other classes to the timeline and use them just fine, but this class is giving me major problems? I am parsing XML data from my server on it and it is giving me errors that look like this.

The timeline reference and usage:
import networkScores;
var network:networkScores = new networkScores();
addChild(network);
score1Textfield.text = network.score1.toString();
[Code] .....

The errors I am getting:
Scene 1, Layer 'Actions', Frame 4, Line 149 1119: Access of possibly undefined property score1 through a reference with static type networkScores.
1067: Implicit coercion of a value of type networkScores to an unrelated type flash.display:DisplayObject.

View 1 Replies

ActionScript 3.0 :: Referencing A Class Using A String?

Aug 10, 2011

Is it possible to use a class name stored in a string and pass it as a parameter??I'm using the push method in a flex mobile project. I have the name of the view I would like to pass into the push method stored in a string. But the push method only accepts it as a class not a string.How do I use a String to load or pass the class name to the method?

var NameClass:Class = "views.Contact";
navigator.pushView(NameClass);

View 9 Replies

ActionScript 3.0 :: Referencing All Children Of A Class?

Oct 31, 2010

just thinking out the setup of a sidescroll/platformer..i want the player not to fall through the floor or go through walls i know how to hittest with a single object, but what i have is various objects that extend the class wall. if I hittest with wall will that also apply to the serrated_floor and portcullis classes that extend wall?

View 1 Replies

IDE :: Make A Table In Flash And Enable The Column Headers On The Table To Sort Column On Click?

May 4, 2009

How to make a table in Flash and enable the column headers on the table to sort column on click?I have seen some tutorials with mySQL but I'd like to start with something basic. Is a sortable table possible using just Flash and AS 2.0?

View 1 Replies

ActionScript 3.0 :: Referencing A Loaded Clips Class?

Mar 18, 2009

I have a swf that is loaded into my main swf with the loader class. When I click a button in the main swf I want to call a function in the loaded swf Main class.

When I do a trace it is showing the loaded clip as [object Home] which is the name of the Main document class associated to the loaded swf. I have a public function in my Home.as called startAnimation() but when I try to call it I get

[quote]1061: 1061: Call to a possibly undefined method startAnimation through a reference with static type flash.display:Sprite.

View 21 Replies

ActionScript 3.0 :: Referencing Stage Objects From Within Class

Sep 3, 2009

How to access stage elements from within a class.
buttonControls.as

Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....

View 2 Replies

ActionScript 3.0 :: Referencing An Object Inside A Class

Feb 1, 2009

and I'm trying to add an event listener and a function to the class, but I keep getting errors of undefined, I tried just about everthing to be able to refference obj0

objGroup.obj0.addEventListener(MouseEvent.CLICK, onClick)
private function onClick (event:MouseEvent):void{
trace ("Click");
}

View 17 Replies

ActionScript 3.0 :: Referencing Movie Clips On A Class?

May 7, 2010

I'm developing a Hygrometer in Flash CS4. The Hygrometer is a Movie Clip currently on the stage with 16 Movie Clips inside with instance names like segment01_mc, segment02_mc.. segment16_mc. I'm trying to make a class for the Hygrometer MC and I need to access the "segment" MC's. But I can't find a solution.

Is there any way to reference the "segment" movie clips? How can I assign instance names to the "segment" movie clips?

Here's my current Hygrometer class code:

[Code]....

View 14 Replies

ActionScript 3.0 :: Referencing A Dynamic Textfield From A Class

May 25, 2010

how do I reference a dynamic text field in my fla file from a class which isn't the document class? For example: I have an fla file called main.fla which contains no actionscript and has a single dynamic textfield called "text_txt" on the main timeline.

[Code]....

View 8 Replies

Flex :: MXML Class Referencing Syntax?

Mar 17, 2011

I'm having a problem that has been really getting to me for the last 12 hours or so and I can't seem to find the answer anywhere. I know it's something simple, but I just don't know the correct syntax.

I've got a Flex Application in Flash Builder 4 with a file called "Test.mxml" which looks like this (simplified):

[Code]...

View 1 Replies

ActionScript 3.0 :: Referencing Stage.stageWidth From A Class

Jan 7, 2009

I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.

I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.

Under this type of linkage, is there a way to reference the stage width from the class? I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class. Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.

[Code]....

View 3 Replies

ActionScript 3.0 :: Referencing Stage From External Class

Feb 14, 2009

I'm having problems referencing the stage from an external class. I've tried :
Code:
stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
And also
Code:
MovieClip(parent).addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);
But no luck. Can I not do this? I'm making a pencil class that I want to be able to reuse. I also tried "this" and while it didn't throw and error, it didn't work either.

View 9 Replies

ActionScript 3.0 :: Referencing Stage From Within MovieClip Or Class

Dec 9, 2009

I'd like to know how I can reference root stage values from within a movieclip, or even worse, from a class. For example, I have a class called Bground.as. It does stuff, according to current stage size - so if someone were to resize the window/browser, Background updates in real time and does something fancy while it's at it. To do this "fancyness", I need stageheight and stagewidth. However, simply pointing to them does not work.

Here's the simplified ActionScript Code:
package klaseFP{
// imports
import flash.events.*;
import flash.display.*;
public class Bground extends MovieClip{
[Code] .....

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at klaseFP::Bground()
at FullScreen_03_fla::MainTimeline/frame1()

Background works as a document class, works perfectly in fact. However, if I use it as the class of a library object, error 1009 shows up. Same thing happens if I simply put the code into the timeline of the library object - stage referencing simply causes it to break. So, how do I dynamically change the values of variables in Background, according to values in the main movie/app?

View 2 Replies

ActionScript 2.0 :: Referencing To Class Members From OnSoundComplete?

Sep 28, 2010

like at the object, i have a class like that:

class myClass
{
var sound:Sound;
var num:Number;
public function MyClass()

[Code]...

View 2 Replies

ActionScript 3.0 :: Referencing A Dynamic Textfield From A Class?

May 25, 2010

how do I reference a dynamic text field in my fla file from a class which isn't the document class?

For example:

I have an fla file called main.fla which contains no actionscript and has a single dynamic textfield called "text_txt" on the main timeline.

My class file is called aClass.as and is the following:

package
{
public class aClass extends MovieClip
{

[Code].....

View 1 Replies

ActionScript 3.0 :: Referencing Class Variables For A Movieclip?

Dec 5, 2011

Hey guys. It's been a while since I've used Flash and I am still trying to wrap my head around Actionscript 3.0 and the way it works; I am so used to the way AS2 works.I have provided the code below, it's very simple, so you might be able to skip this explanation and just take a look at the error and the code:

- I have made a movieclip called HeroMC in my FLA.

- The HeroMC movieclip has the AS Class linkage of exactly the same name, "HeroMC".

- I have made an actionscript class file, HeroMC.as, to house specific variables for my hero; such as Name, Age, xPos and yPos.

- I have also made an actionscript class file, Main.as, the document class for this FLA.

- In Main.as I instantiate HeroMC using the variable hero, and then run the function addHero() from my constructor.

- addHero() is a simple stage.addChild(hero);

This all works perfectly fine and it adds my hero to the stage. However, the problem arises whenever I try to reference one of the variables from HeroMC.as. I am met with this error - I will use the variable xPos as an example.

Here is the error:

1119: Access of possibly undefined property xPos through a reference with static type HeroMC.

Here is the code for Main.as:

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

[code]....

It is obvious this is a very simple problem, but I have searched Google, Kirupa and Flashkit for an answer, but none of the threads I find discuss my specific circumstances and I am unable to find the specific information I need to.

View 3 Replies

ActionScript 3.0 :: Calling Collision Class Without Referencing Earlier

May 8, 2010

I should always be able to call the Collision class without referencing it earlier. I have all the imports I need (Events, Movieclip, Keyboard, MouseEvents). For some reason though, when I enter any code involving Collisions, specifically:
Collision.block(player, block);

I get this error:
/Users/Mike/Documents/Main.as, Line 50 1120: Access of undefined property Collision.

Is there something previous to using the Collision Class I must do? Placing it in the same folder as the rest of my work? Some sort of unseen reference?

View 5 Replies

ActionScript 3.0 :: Referencing A Newly Created Class Instance

Jun 16, 2011

I am completely new to actionscript although I do come from a OOP background. I have been asked to trial Flash and Actionscript 3 in particular - so I do come with a few preconceptions on how I expect actionscript to behave. I have a problem I donot understand. I have created a new class and to test it I use a simple test harness in the form of a .fla file.

The issue I have is when I create a new instance of the class and assign it to a variable, subsequent background changes to that instance of the class are not 'picked-up' when referenced through the variable. I would expect that given instance of class could be assigned to many different variables and any updates using one variable would accessible using any of the other variables.

[code]...

View 1 Replies

Actionscript 3 :: Referencing A Document Class From A Child MovieClip?

Apr 13, 2010

I have a document class with a child MovieClip on the stage. I have the clip already on the stage because it's part of an complex layout provided by the designer and it seems easier to leave it on the stage than to use addChild (since I would have to add about 60 objects).What is the best way to reference the document class from inside the child MovieClip class?

View 1 Replies







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