I have a movieClip object(Creature), and inside it, i have hitpoints that I would like to add to Creatures Array HitPoints. The way I would like to do this is to have every Parent that may have hitPoints, to have an array called HitPoints so that I can have each point add it self to the Array, regardless of the parent. IE, a skeleton creature and a goblin creature could use the same type of hitPoint objects inside of their base movieClip and still be accessable.
I have omitted some of the unnecessary parts of this class
package Assets.Creatures
{
import Assets.Points.HitPoint;
import Assets.GameStates.Main;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.geom.Point;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BaseAI_ extends MovieClip
{
//Characteristics
protected var Health : int = 10;
protected var SPEED : int = 3;
protected var Intellect : int = 3;
protected var Strength : int = 3;
protected var Dexterity : int = 3;
protected var AttackRange : int = 70;
protected var Temperment : String = "Agressive";
//public var Temperment : String = "Passive";
//public var Temperment : String = "Defensive";
//ARRAYS
public var HitPoints : Array = new Array;
// AttackTimers
protected var canAttack : Boolean = false;
protected var AttackSpeed : int;
protected var AttackTimer : Timer;
protected var AbilityCooldownsUP : Boolean = false;
//protected var ABILITY : Timer;
//AI STATES
protected var CURRENT_STATE : int = 0;
protected static var STATE_IDLE : int = 0;
protected static var STATE_ENGAGE : int = 1;
protected static var STATE_ATTACK : int = 2;
protected static var STATE_FLEE : int = 3;
//Reference
protected var Target : MovieClip;
//Directions
protected var SlopeY : Number;
protected var SlopeX : Number;
protected var EngagePosition : Point;
protected var RunDirection : Number;
public function BaseAI_()
{
addEventListener(Event.ADDED_TO_STAGE, Awake);
} // constructor code
private function Awake (e : Event) : void
{
AttackSpeed = (5000 / Dexterity);
AttackTimer = new Timer (AttackSpeed, 0);
AttackTimer.addEventListener(TimerEvent.TIMER, AttackSpeedTimer);
AttackTimer.start();
Main.main.EnemyArray_2.push(this);
stage.addEventListener(Event.ENTER_FRAME, update);
}
public function AddHitPoints (hitPoint : MovieClip) : void
{
HitPoints.push(hitPoint);
}
}
and the hitPoint class is
package Assets.Points
{
import Assets.Creatures.BaseAI_;
import Assets.Creatures.Player_;
import Assets.Creatures.Player_Human;
import flash.display.MovieClip;
import flash.events.Event;
public class HitPoint extends MovieClip
{
public function HitPoint()
{ // constructor code
addEventListener(Event.ADDED_TO_STAGE, Awake);
} // constructor code
private function Awake (e : Event) : void
{
trace("HitPoints parent is " + parent);
parent.AddHitPoints(this);
//parent.HitPoints.push(this)
//trace("my parent has " + parent.HitPoints.length);
}
}
}
So in the child class (hitPoints) I am adding the hitPoints directly to the ParentClass BaseAI_ on the stage, I have tried a few different ways to add HitPoints both directly with parent.AddHitPoints(this); and parent.HitPoints.push(this)
I think you need to use this.parent and not just parent.
Related
So I have 2 files, where I want to be able to access an array from 1 file in the other.
package code {
import flash.display.DisplayObjectContainer;
import flash.display.MovieClip;
import flash.ui.Keyboard;
import code.*;
public class Init extends MovieClip {
public var _solidObjects: Array;
public function Init() {
_solidObjects = [wall01, wall02, wall03, wall04];
}
}
}
How would I be able to access the _solidObjects array from another class in a seperate file?
Any help would be appreciated as I have been trying for a while with no success, thanks.
Constructors can be passed variables. For example:
First class:
package code {
public class Init extends MovieClip {
public var solidObjects: Array;
public function Init() {
solidObjects = [wall01, wall02, wall03, wall04];
}
}
Second class:
package code {
public class SomeClass extends MovieClip {
public var solidObjects: Array;
public function SomeClass(param:Array) {
this.solidObjects = param;
}
}
}
Usage context:
var initObj:Init = new Init();
var secondObject:SomeClass = new SomeClass(initObj.solidObjects);
I am not having any issues making calls from the form instance to the Revit class. It's when I try to assign a List to the Revit class's function categoryList(), that I get a variable doesn't exist in the context error. I tried prefixing a reference to the instance of the form class "Form UF = new Form;" This doesn't work.
//The Revit Class
public Result Execute(ExternalCommandData commandData, ref string message,....)
{
User_Form UF = new User_Form(commandData);
UF.ShowDialog();
public List<BuiltInCategory> categoryList(Document doc, int intSwitch)
{
//list built in categories for built in filter_1
builtInCats_List = new List<BuiltInCategory>();
switch (intSwitch)
{
case (1):
...
case (3):
...
case (4):
{
builtInCats_List = newStateCb1;
return builtInCats_List;
}
default:
{
builtInCats_List = newStateCb1;
return builtInCats_List;
}
}
}
using Form = System.Windows.Forms.Form;
using WS = ModelAuditor_2014.WorksetSorter_2014;
using ModelAuditor_2014;
using System.Threading;
//The Form
namespace ModelAuditor_2014
{
public partial class User_Form : Form
{
//Constructor
WorksetSorter_2014 WS = new WorksetSorter_2014();
//Revit references
public Autodesk.Revit.UI.UIApplication rvtUiApp;
public Autodesk.Revit.UI.UIDocument rvtUiDoc;
public Autodesk.Revit.ApplicationServices.Application rvtApp;
//Global Variables
public List<BuiltInCategory> Filter01_CategoryList;
public List<BuiltInCategory> Filter02_CategoryList;
public int intSwitch;
public List<BuiltInCategory> newStateCb1;
public User_Form(ExternalCommandData commandData)
{
//Revit references
rvtUiApp = commandData.Application;
rvtUiDoc = rvtUiApp.ActiveUIDocument;
rvtApp = rvtUiApp.Application;
InitializeComponent();
}
public void User_Form_Load(object sender, EventArgs e)
{
//use rvtDoc = Doc
Autodesk.Revit.DB.Document rvtDoc = .....
//CheckedListBox for filter01
checkedListBox1.DataSource = WS.categoryList(rvtDoc, intSwitch = 1);
Filter01_CategoryList = new List<BuiltInCategory>();
Filter01_CategoryList = WS.RetrieveSchema(rvtDoc, false);
foreach (BuiltInCategory ChkedB1 in Filter01_CategoryList)
{
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if (checkedListBox1.Items[i].ToString() == ChkedB1.ToString())
{
checkedListBox1.SetItemChecked(i, true);
}
}
}
public List<BuiltInCategory> returnNewStateCB1()
{
newStateCb1 = checkedListBox1.CheckedItems.Cast
<BuiltInCategory>().ToList<BuiltInCategory>();
return newStateCb1;
}
I passed the list from the win form to another public function in the revit app, I was able to access the list returned by this function.
I have a problem, I am working on a larger project, and I made a small project to test this problem.
The problem being:
I have made a button which spawns enemy's. When an enemy hits allyCopy it bounces back in the opposite direction. But the problem is that EVERY instance of enemy bounces back when a single one hits the test object.
My code:
my main class:
package {
import flash.display.*;
import flash.ui.*;
import flash.events.*;
public class MainClass extends MovieClip {
public var speed:int = 3;
public static var enemyArray:Array = [];
public var randNumber:Number = 0;
public static var allyCopy1 = new allyCopy();
public function MainClass() {
stage.addEventListener(Event.ENTER_FRAME, update);
spawnButton1.addEventListener(MouseEvent.CLICK, spawnEnemy);
allyCopy1.addEventListener(MouseEvent.MOUSE_DOWN, dragOn, true);
allyCopy1.addEventListener(MouseEvent.MOUSE_UP, dragOff, true);
addChild(allyCopy1);
allyCopy1.x = 60,25;
allyCopy1.y = 208,05;
}
public function update(e:Event)
{
/*for (var i:Number = 0; i < enemyArray.length; i++)
{
enemyArray[i].x -= speed;
}*/
}
public function dragOn (e:MouseEvent)
{
allyCopy1.startDrag();
trace("drag");
}
public function dragOff (e:MouseEvent)
{
allyCopy1.stopDrag();
}
public function spawnEnemy(e:MouseEvent)
{
randNumber = Math.random();
trace(randNumber);
var enemy1 = new enemy ();
addChild(enemy1);
enemyArray.push(enemy1);
if (randNumber <= .5)
{
enemy1.x = 526.25;
enemy1.y = 68.05;
} else
{
enemy1.x = 526.25;
enemy1.y = 200.05;
}
}
}
}
The enemy class:
package {
import flash.display.*;
import flash.events.*;
public class enemy extends MovieClip {
public static var hp:int = 100;
public static var speed = 3;
public function enemy() {
addEventListener(MouseEvent.CLICK, killEnemy);
addEventListener(Event.ENTER_FRAME, update);
}
public function update (e:Event) {
x -= speed;
if ( x <= 0)
{
MainClass.enemyArray.pop();
trace(MainClass.enemyArray);
}
if(MainClass.allyCopy1.hitTestObject(this))
{
speed = -3;
}
}
public function killEnemy (e:MouseEvent)
{
this.parent.removeChild(this);
trace(MainClass.enemyArray);
MainClass.enemyArray.pop();
}
}
}
Well the problem is that speed is static variable. This means that it's not separate for each enemy, but it's common (shared) for all instances. So if you change it, it changes everywhere..
Don't do variables static that often - it's pretty bad practice. The very same thing will happen with life - if you decrease the life of one enemy, it will decrease the life of all enemies (all instances of that class).
package
{
import flash.events.Event;
import flash.display.MovieClip;
// class
public class GameGrid extends MovieClip
{
private var gameHeight:Number = 600;
private var gameWeight:Number = 800;
private var gridHeight:Number = 50;
private var gridWeight:Number = 50;
private var rowNumber:int = 12;
private var columnNumber:int = 16;
private var backgroundGrid:Array = new Array(12,16);
private var foregroundGrid:Array = new Array(12,16);
function GameGrid(){
}
function addBackGrid(rowN:int,colN:int,mcObject:MovieClip)
{
backgroundGrid[rowN,colN].push(mcObject);
}
function addForeGrid(rowN:int,colN:int,mcObject:MovieClip)
{
foregroundGrid[rowN,colN].push(mcObject);
}
function calculateRowDiff(rowA:int,rowB:int):Number
{
return Math.abs(rowA-rowB);
}
function calculateColDiff(colA:int,colB:int):Number
{
return Math.abs(colA-colB);
}
function calculateCorDiff(colA:int,colB:int,rowA:int,rowB:int):Number
{
return Math.sqrt((calculateRowDiff(rowA,rowB) * calculateRowDiff(rowA,rowB)) + (calculateColDiff(colA,colB) * calculateColDiff(colA,colB)));
}
// add to stage
function paintbackgroundGrid()
{
for (var i:int=0; i<16; i++)
{
for (var j:int=0; j<12; j++)
{
MovieClip(backgroundGrid[i,j]).x = i * 50;
MovieClip(backgroundGrid[i,j]).y = j * 50;
stage.addChild(MovieClip(backgroundGrid[i,j]));
}
}
}
}
}
So what this GameGrid class do is to hold an Array of grids(or tiles which extends MovieCLip) that will be added to the main stage and will call the initializeItem function.
function InitializeItem(e:Event)
{
var gamemap = new GameGrid();
var mc:MovieClip = new MainCharacter();
gamemap.addBackGrid(1,1,mc);
gamemap.paintbackgroundGrid();
//trace("Year: "+gameTime.gameYear+" Month: "+gameTime.gameMonth+" Day: "+gameTime.gameDay+" "+gameTime.gameHour+":"+gameTime.gameMinute+":"+gameTime.gameSecond);
}
The initializeItem should create an instance of gamegrid, and add movieclips to their respective locations(stored using array) and display them.
and this is the error stacktrace:
ReferenceError: Error #1069: Property 1 not found on Number and there is no default value.
at GameGrid/addBackGrid()
The debugger suggest that the error came from the line backgroundGrid[rowN,colN].push(mcObject);
Is there a way I can hold a 2d array movieclips? I'm new to AS3 and it looks very similar to JAVA, what am I missing?
Try this
private var backgroundGrid = [];
function addBackGrid(rowN:int,colN:int,mcObject:MovieClip) {
if (backgroundGrid[rowN] == null) {
backgroundGrid[rowN] = [];
}
backgroundGrid[rowN][colN] = mcObject;
}
In as3, following code means create a array and the array contains two elements, one is 12, and the other is 16.
private var backgroundGrid:Array = new Array(12,16);
i am trying to make a "game" in Flex similar to Shake&Fidget. I'm saving all the user data in a mysql database and I retrieve the data using ZendFramework (PHP).
I thought of saving all the user and character info I'm going to need into am AS class so I can use that data in every view.
The data recived from the database is correct. I was able to load it in my app labbels but everytime i changed views it had to ask it again, so i thought of making this classes in order to just ask once for the information.
I'll post here the files so it's all more clear.
ViewNavigatorAplication.mxml
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
firstView="views.RotrHomeView"
persistNavigatorState="true">
<fx:Script>
<![CDATA[
import flash.net.registerClassAlias;
import valueObjects.Character;
registerClassAlias("Character", valueObjects.Character);
]]>
</fx:Script>
The first View goes to the login screen, it works OK. So i'll go to the view that loads and "tries" to show the character data.
char_panel.mxml
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:usersservice1="services.usersservice1.*"
title="Character Sheet"
viewActivate="char_panel_viewActivateHandler()">
<fx:Script>
<![CDATA[
import mx.binding.utils.*;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
import valueObjects.Character;
//[Bindable]protected var character:Character = new Character();
public function updateStats():void{
var str:int = parseInt(getGlobalStatsResult.lastResult.globalSTR) + parseInt(getCharacterStatsResult.lastResult.str);
var dex:int = parseInt(getGlobalStatsResult.lastResult.globalDEX) + parseInt(getCharacterStatsResult.lastResult.dex);
var intel:int = parseInt(getGlobalStatsResult.lastResult.globalINT) + parseInt(getCharacterStatsResult.lastResult.intel);
var cha:int = parseInt(getGlobalStatsResult.lastResult.globalCHA) + parseInt(getCharacterStatsResult.lastResult.cha);
var sta:int = parseInt(getGlobalStatsResult.lastResult.global_VIT) + parseInt(getCharacterStatsResult.lastResult.vit);
data.modStats(str,intel,cha,sta,dex)
data.showStats(lb_show_str,lb_show_dex,lb_show_int,lb_show_cha,lb_show_vit);
//character.showStats(lb_show_str,lb_show_dex,lb_show_int,lb_show_cha,lb_show_vit);
}
public function char_panel_viewActivateHandler():void{
if(!data){
data = new Character();
}
getCharacterStatsResult.token = usersService1.getCharacterStats("user01");
getGearListResult.addEventListener(ResultEvent.RESULT,onResult);
getGearListResult.token = usersService1.getGearList();
}
public function onStatsResult(event:ResultEvent):void{
if(getGlobalStatsResult.lastResult.globalSTR != null){
updateStats();
}
}
public function onResult(event:ResultEvent):void{
if(getGearListResult.lastResult[0].itemName != null){
getGlobalStatsResult.addEventListener(ResultEvent.RESULT, onStatsResult);
getGlobalStatsResult.token = usersService1.getGlobalStats("user01");
currentState = "Character";
}
}
]]>
</fx:Script>
<s:states>
<s:State name="Loading"/>
<s:State name="Character"/>
</s:states>
<fx:Declarations>
<s:CallResponder id="getCharacterStatsResult"/>
<s:CallResponder id="getGearListResult"/>
<s:CallResponder id="getGlobalStatsResult"/>
<usersservice1:UsersService1 id="usersService1"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label id="lb_show_str" includeIn="Character" x="119" y="46" text=""/>
<s:BusyIndicator includeIn="Loading" left="172" right="171" top="148" bottom="424"
horizontalCenter="0" verticalCenter="-138"/>
<s:Label id="lb_show_int" includeIn="Character" x="119" y="90"/>
<s:Label id="lb_show_cha" includeIn="Character" x="119" y="139"/>
<s:Label id="lb_show_vit" includeIn="Character" x="119" y="191"/>
<s:Label id="lb_show_dex" includeIn="Character" x="119" y="243"/>
As for the AS classes:
Character.as
package valueObjects{
import mx.data.ChangedItems;
import mx.messaging.channels.StreamingAMFChannel;
import spark.components.Label;
import spark.skins.spark.StackedFormHeadingSkin;
[Bindable]
public class Character
{
private var _name:String;
private var _stats:FinalStats;
private var _gear:GearList;
public function Character()
{
this._stats = new FinalStats();
this._gear = new GearList();
}
public function modStats(str:int,intel:int,cha:int,sta:int,dex:int):void{
this._stats.modStr(str);
this._stats.modInt(intel);
this._stats.modCha(cha);
this._stats.modVit(sta);
this._stats.modDex(dex);
}
public function getStats():Array{
var aStats:Array;
aStats["str"]=this._stats.getStr();
aStats["int"]=this._stats.getInt();
aStats["cha"]=this._stats.getCha();
aStats["sta"]=this._stats.getVit();
aStats["dex"]=this._stats.getDex();
return aStats;
}
public function setName(charName:String):void{
this._name = charName;
}
public function getName():String{
return this._name;
}
public function showStats(lbSTR:Label, lbDEX:Label, lbINT:Label, lbCHA:Label, lbVIT:Label):void{
lbSTR.text = "" + this._stats.getStr();
lbDEX.text = "" + this._stats.getDex();
lbINT.text = "" + this._stats.getInt();
lbCHA.text = "" + this._stats.getCha();
lbVIT.text = "" + this._stats.getVit();
}
}}
FinalStats.as
package valueObjects{
public class FinalStats
{
private var str:int = 0;
private var intel:int = 0;
private var cha:int = 0;
private var sta:int = 0;
private var dex:int = 0;
public function FinalStats()
{
}
public function getStr():int{
return this.str;
}
public function modStr(x:int):void{
this.str+=x;
}
public function getDex():int{
return this.dex;
}
public function modDex(x:int):void{
this.dex+=x;
}
public function getInt():int{
return this.intel;
}
public function modInt(x:int):void{
this.intel+=x;
}
public function getCha():int{
return this.cha;
}
public function modCha(x:int):void{
this.cha+=x;
}
public function getVit():int{
return this.sta;
}
public function modVit(x:int):void{
this.sta+=x;
}
}
}
And the last one GearList.as
package valueObjects{
import mx.data.ChangedItems;
import mx.messaging.channels.StreamingAMFChannel;
import spark.components.Label;
import spark.skins.spark.StackedFormHeadingSkin;
public class GearList
{
private var _headID:String;
private var _shoulderID:String;
private var _chestID:String;
private var _bracersID:String;
private var _glovesID:String;
private var _pantsID:String;
private var _bootsID:String;
private var _main_handID:String;
private var _off_handID:String;
public function GearList()
{
}
public function showStats(lbHead:Label, lbShoulder:Label, lbChest:Label, lbBracer:Label, lbGlove:Label, lbPants:Label, lbBoots:Label, lbMainHand:Label, lbOffHand:Label):void{
lbHead.text = ""+this._headID;
lbShoulder.text = ""+this._shoulderID;
lbChest.text = ""+this._chestID;
lbBracer.text = ""+this._bracersID;
lbGlove.text = ""+this._glovesID;
lbPants.text = ""+this._pantsID;
lbBoots.text = ""+this._bootsID;
lbMainHand.text = ""+this._main_handID;
lbOffHand.text = ""+this._off_handID;
}
public function getOff_handID():String
{
return _off_handID;
}
public function setOff_handID(value:String):void
{
_off_handID = value;
}
public function getMain_handID():String
{
return _main_handID;
}
public function setMain_handID(value:String):void
{
_main_handID = value;
}
public function getBootsID():String
{
return _bootsID;
}
public function setBootsID(value:String):void
{
_bootsID = value;
}
public function getPantsID():String
{
return _pantsID;
}
public function setPantsID(value:String):void
{
_pantsID = value;
}
public function getGlovesID():String
{
return _glovesID;
}
public function setGlovesID(value:String):void
{
_glovesID = value;
}
public function getBracersID():String
{
return _bracersID;
}
public function setBracersID(value:String):void
{
_bracersID = value;
}
public function getChestID():String
{
return _chestID;
}
public function setChestID(value:String):void
{
_chestID = value;
}
public function getShoulderID():String
{
return _shoulderID;
}
public function setShoulderID(value:String):void
{
_shoulderID = value;
}
public function getHeadID():String
{
return _headID;
}
public function setHeadID(value:String):void
{
_headID = value;
}
}}
If you are still here you have all my respect :D
When i try it out, i get the following error. I've tried in char_panel.mxml using Character::modStats(...) instead of data.modStats i'll put the error log under this one.
Error log when using data.modStats(...)
TypeError: Error #1006: modStats is not a function.
at views::char_panel/updateStats()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:23]
at views::char_panel/onStatsResult()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:39]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::CallResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\CallResponder.as:122]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:244]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at NetConnectionMessageResponder/resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:552]
at mx.messaging::MessageResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
Error Log using Character::modStats(...)
Error: Error #1034: Type Coercion failed: cannot convert valueObjects::Character$ to Namespace.
at views::char_panel/updateStats()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:23]
at views::char_panel/onStatsResult()[C:\Users\Zebrah\Rotr\Rotr\src\views\char_panel.mxml:39]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::CallResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\CallResponder.as:122]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:244]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at NetConnectionMessageResponder/resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\NetConnectionChannel.as:552]
at mx.messaging::MessageResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:235]
Thanks in advance to anyone that get so far in this help cry :D i'd apreciate any sugestions that you can make.
ok so the reason it doesn't work with data is that event though you said
data = new Character();
data is still actually an object (that now looks like a character). to make it work
var myChar:Character = Character(data); // cast it to a Character and it now knows the method
myChar.modStats()
the reason the other call didn't work is the way you called it:
Character::modStats(...)
This say look for a method called modStats in the namespace Character. Instead call this
character.modStats()
and it will work.
You Sir are my personal Hero :D, i've just tried it and it shows the data.
I changed the constructor for the character in Character.AS like this:
public function Character(obj:Object)
{
this._stats = new FinalStats();
this._gear = new GearList();
}
I'm not entirely sure if this is correct, but as you mentioned in your answer:
var myChar:Character = Character(data);
I supose i'll have to use that data object to initialice myChar...am i right? Well, later when i have the time i'll try to add new views and buttons to go through views and see if the data is there :D