Missing properties in TypeScript - reactjs

class RolloutStoreClass {
import { observable, action, makeAutoObservable } from "mobx";
public queue = observable<IDeploymentProject>([]);
public inProcess = observable<IDeploymentProject>([]);
public successfull = observable<IDeploymentProject>([]);
public failed = observable<IDeploymentProject>([]);
constructor() {
makeAutoObservable(this);
}
#action
private clearQueue(): void {
this.queue = [] ;
this.inProcess = [];
this.failed = [];
this.successfull = [];
}
}
export const RolloutStore = new RolloutStoreClass();
I get the issue on the clearQueue Function exactlly on this. queue
Error is:
In the "never []" type, the following properties of the "Observable Array " type are missing: "spliceWithArray, clear, replace, remove, toJSON".

You either need to make your queue (and other fields) regular array, all observability will still work.
Or use .clear() method inside clearQueue:
private clearQueue(): void {
this.queue.clear();
// ...
}
One more thing: when you use makeAutoObservable you don't need to explicitly mark action's observable's and so on, you can just drop all the decorators:
class Foo {
// Don't need explicit observable decorator
public queue: IDeploymentProject[] = [];
// ...
constructor() {
makeAutoObservable(this);
}
// You can remove action decorator
private clearQueue(): void {
this.queue = [] ;
this.inProcess = [];
this.failed = [];
this.successfull = [];
}
}

Related

Reactions inside the class

I'd like mobx to trigger a reaction whenever an observable changes. I want it to be trigerred inside the class that has that observable so the trigger method could manipulate other data in the store, for example data in a sub-store.
class Animal {
name
energyLevel
constructor(name) {
reaction(
() => giraffe.isHungry,
isHungry => {
if (isHungry) {
console.log("Now I'm hungry!")
} else {
console.log("I'm not hungry!")
}
console.log("Energy level:", giraffe.energyLevel)
}
)
this.name = name
this.energyLevel = 100
makeAutoObservable(this)
}
reduceEnergy() {
this.energyLevel -= 10
}
get isHungry() {
return this.energyLevel < 50
}
}
(The example is taken from the docs: https://mobx.js.org/reactions.html)
If I move the reaction inside the constructor function, it will not be triggered (in the original code it's outside the class). How can I trigger reactions inside the class?
First of all, to refer to the current instance of the class you need to use this keyword, like this.isHungry and etc.
And second is that you need to use reaction after you use makeAutoObservable, so just move it in the end of constructor:
class Animal {
name;
energyLevel;
constructor(name) {
this.name = name;
this.energyLevel = 100;
makeAutoObservable(this);
reaction(
() => this.isHungry,
(isHungry) => {
if (isHungry) {
console.log("Now I'm hungry!");
} else {
console.log("I'm not hungry!");
}
console.log('Energy level:', this.energyLevel);
}
);
}
reduceEnergy() {
this.energyLevel -= 60;
}
addEnergy() {
this.energyLevel += 60;
}
get isHungry() {
return this.energyLevel < 50;
}
}
const animal = new Animal('cat');
animal.reduceEnergy();
animal.addEnergy();

Response Handle

I am pulling data database,
My response class
sealed class Response<out T>{
object Loading: Response<Nothing>()
data class Success<out T>(val data: T): Response<T>()
data class Error(val message: String): Response<Nothing>()
}
Where should I handle the incoming data like this?
First approach
View Model
class DataViewModel (private val useCase: UseCase, ) : ViewModel() {
private val _dataState = mutableStateOf("")
val dataState = _dataState
val loading = mutableStateOf(false)
private val _eventFlow = MutableSharedFlow<UIEvent>()
val eventFlow = _eventFlow.asSharedFlow()
fun getData() {
viewModelScope.launch {
useCase.getData().collect { response ->
when(response){
is Response.Error -> {
_eventFlow.emit(UIEvent.ShowSnackBar(response.message))
loading.value=false
}
is Response.Loading -> loading.value=true
is Response.Success -> {
_dataState.value = response.data
loading.value=false
_eventFlow.emit(UIEvent.Success)
}
}
}
}
}
sealed class UIEvent {
data class ShowSnackBar(val message: String) : UIEvent()
object Success : UIEvent()
}
}
Screen
#Composable
fun DataScreen(dataViewModel: DataViewModel) {
val scaffoldState = rememberScaffoldState()
LaunchedEffect(key1 = true) {
dataViewModel.eventFlow.collectLatest { event ->
when (event) {
is DataViewModel.UIEvent.ShowSnackBar -> {
scaffoldState.snackbarHostState.showSnackbar(event.message)
}
is DataViewModel.UIEvent.Success -> {
"Do something"
}
}
}
}
Scaffold(
scaffoldState = scaffoldState,
content = { EditProfileContent(dataViewModel.dataState.value) }
)
}
Second Approach
View Model
class DataViewModel (private val useCase: UseCase, ) : ViewModel() {
private val _dataState = mutableStateOf<Response<Data>>(Response.Loading)
val dataState = _dataState
fun getData() {
viewModelScope.launch {
useCase.getData().collect { response ->
_dataState.value = response
}
}
}
}
Screen
#Composable
fun DataScreen(dataViewModel: DataViewModel) {
val scaffoldState = rememberScaffoldState()
when(val dataState = dataViewModel.dataState.value){
is Response.Error -> {
LaunchedEffect(key1 = true, block = {scaffoldState.snackbarHostState.showSnackbar(dataState.message)}) }
is Response.Loading -> { Loading() }
is Response.Success -> {
Scaffold(
scaffoldState = scaffoldState,
content = { EditProfileContent(dataState.data) }
)
// Do something else
}
}
}
The first approach seems much easier to me, especially when I'm pulling in more than one data, but when I search, the second approach is usually used in most places.
What's wrong with using the first approach? Which is the best practice?

ActionScript 3.0 - Change Url import from a Class

I want to import an XML file and add it to a grid. That part I have done, but I want to use the class to change the XML file. Now, the file is stuck at the original file.
Example class:
package {
import fl.controls.dataGridClasses.DataGridColumn;
import fl.data.DataProvider;
import flash.net.*;
import flash.events.*;
import fl.controls.DataGrid;
import fl.data.DataProvider;
import flash.display.Stage;
import flash.display.MovieClip
public class Tabellkamp extends MovieClip {
public var link1: String = new String("_blank");
public var request: URLRequest;
public var loader: URLLoader;
public var gridd: DataGrid = new DataGrid();
public function Tabellkamp() {
loader.load(request);
loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
var loader: URLLoader = new URLLoader();
loader.load(new URLRequest(link1));
}
function loaderCompleteHandler(event: Event): void {
var teamXML: XML = new XML(loader.data);
var firstCol: DataGridColumn = new DataGridColumn("somthing on the xml");
firstCol.headerText = "first";
gridd.columns = [firstCol];
addChild(gridd);
}
}
}
Main timeline/ other class:
public class Lagegridd extends MovieClip {
public function Lagegridd() {
btn_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event: MouseEvent) {
var newXML: Tabellkamp = new Tabellkamp();
newXML.link1="newxmlfile.xml";
addChild(newXML);
}
Maybe some other problems with the code, but the main question is how to change the url, and then addChild(). Never mind the grid, it is just an example.
I appreciate some help, on how to use the class several times.
Pretty simple. Destroy the existing instance and create a new one. Also, don't declare functions inside other functions.
public class Lagegridd extends MovieClip
{
public function Lagegridd()
{
btn_1.addEventListener(MouseEvent.CLICK, onClick);
}
private var currentGrid:Tabellkamp;
private var gridSource:Array = ["file1.xml", "file2.xml", "file3.xml"];
private function onClick(e:MouseEvent):void
{
// Obtain the first element from the list.
var anUrl:String = gridSource.shift();
changeGrid(anUrl);
}
private function changeGrid(url:String):void
{
if (currentGrid)
{
removeChild(currentGrid);
// Another cleanup routines here, if necessary.
}
currentGrid = new Tabellkamp;
// You need to define this function instead of loading
// data from "link1" inside the object constructor.
currentGrid.loadData(url);
addChild(currentGrid);
}
}
UPD: OOP example.
package
{
import flash.display.Sprite;
import flash.system.System;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
// Don't use MovieClip if you don't have frames and timelines.
public class LasteinnXML extends Sprite
{
public var url:String;
public var loader:URLLoader;
public var dataProvider:XML;
public function load(path:String):void
{
url = path;
loader = new URLLoader;
loader.addEventListener(Event.COMPLETE, onData);
// Always handle erroneous cases. Last three arguments are there
// because it is wise to not unsubscribe from these events but
// let the garbage collector decide when to destroy them.
loader.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);
// You don't need to store the request object.
loader.load(new URLRequest(url));
}
private function onData(e:Event):void
{
try
{
dataProvider = new XML(loader.data);
finishLoading();
}
catch (fail:Error)
{
// There's another erroneous case even if loading is fine:
// Invalid XML data. Always chack for it as well.
onError(null);
}
// Handle the SUCCESSFUL case here.
}
private function finishLoading():void
{
// Cleanup routines. Dispose of your objects once you don't need them.
if (!loader) return;
loader.removeEventListener(Event.COMPLETE, onData);
loader = null;
}
private function onError(e:Event):void
{
// In case the object was already destroyed
if (!loader) return;
finishLoading();
// Handle the ERRONEOUS case here.
}
public function destroy():void
{
finishLoading();
// The recommended way of cleaning XML data up.
if (dataProvider)
{
System.disposeXML(dataProvider);
dataProvider = null;
}
}
}
}
Usage:
var A:LasteinnXML = new LasteinnXML;
var B:LasteinnXML = new LasteinnXML;
var C:LasteinnXML = new LasteinnXML;
addChild(A);
addChild(B);
addChild(C);
A.load("filea.xml");
B.load("fileb.xml");
C.load("filec.xml");
C.destroy();
removeChild(C);

Saving data from DDBB into AS class

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

ArrayCollection extend error

i extend ArrayCollection class for add push method
package com.cargo.collections
{
import mx.collections.ArrayCollection;
public class DataCollection extends ArrayCollection {
public function DataCollection(source:Array = null) {
super(source);
}
public function push(...parameters):uint {
var i:uint = source.push(parameters);
this.refresh();
return i;
}
}
}
but pushed data is array :/
var test:DataCollection = new DataCollection({id: 1});
test.source.push({id: 2});
test.push({id: 3});
output is
test = Array( {id: 1}, {id: 2}, Array({id: 3}) )
In your example ...parameters creates an array containing all the arguments passed to that function. This should work as expected:
public function push(...parameters):uint {
var i:uint = source.push(parameters[0]);
this.refresh();
return i;
}
Alternatively, if your purpose is to enable the pushing of multiple parameters you can use the Function.apply() method, which will translate a given array into multiple parameters:
public function push(...parameters):uint {
var i:uint = source.push.apply(null,parameters);
this.refresh();
return i;
}
This is the equivalent of saying
var i:uint = source.push(parameters[0],parameters[1],parameters[2]); // etc

Resources