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);
Related
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).
i am rebuilding a top down shooter form a .fla files with actions in it to a separate .as file
managed to fix allot of problems with is but i stumbled upon a problem with a function that drops random squares in to a particleContainer and adds them to stage to float down.
when the page is loaded is get allot of
TypeError: Error #1009: Cannot access a property or method of a null object reference. at Level/generateParticles()
i really hope someone can help me fix this! and show me where i made a mistake, i have tried allot of things already but none of them seem to work:(
package {
import playerAuto
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.filters.BlurFilter;
import flash.utils.Timer;
import flash.text.TextField;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.utils.*;
import flash.display.Shape;
import flash.display.DisplayObject
/**
*
*/
public class Level extends Sprite
{
//these booleans will check which keys are down
public var leftIsPressed:Boolean = false;
public var rightIsPressed:Boolean = false;
public var upIsPressed:Boolean = false;
public var downIsPressed:Boolean = false;
//how fast the character will be able to go
public var speed:Number = 5;
public var vx:Number = 0;
public var vy:Number = 0;
//how much time before allowed to shoot again
public var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
public var cLimit:int = 12;
//whether or not the user is allowed to shoot
public var shootAllow:Boolean = true;
//how much time before another enemy is made
public var enemyTime:int = 0;
//how much time needed to make an enemy
//it should be more than the shooting rate
//or else killing all of the enemies would
//be impossible :O
public var enemyLimit:int = 16;
//the PlayerAuto's score
public var score:int = 0;
//this movieclip will hold all of the bullets
public var bulletContainer:MovieClip = new MovieClip();
//whether or not the game is over
public var gameOver:Boolean = false;
private var PlayerAuto:playerAuto = new playerAuto;
// publiek toegangkelijke verwijzing naar deze class
public static var instance:Level;
public var particleContainer:MovieClip = new MovieClip();
// constructor code
public function Level()
{
instance = this;
PlayerAuto.x = 200;
PlayerAuto.y = 100;
addChild(this.PlayerAuto);
Project.instance.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
Project.instance.stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
Project.instance.stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
Project.instance.stage.addEventListener(Event.ENTER_FRAME, generateParticles);
drieButton.addEventListener( MouseEvent.CLICK, loadScreenThree );
//checking if there already is another particlecontainer there
if(particleContainer == null)
{
//this movieclip will hold all of the particles
addChild(this.particleContainer);
}
}
function keyDownHandler(e:KeyboardEvent):void {
switch(e.keyCode) {
case Keyboard.LEFT : leftIsPressed = true; break;
case Keyboard.RIGHT : rightIsPressed = true; break;
case Keyboard.UP : upIsPressed = true; break;
case Keyboard.DOWN : downIsPressed = true; break;
}
}
function keyUpHandler(e:KeyboardEvent):void {
switch(e.keyCode) {
case Keyboard.LEFT : leftIsPressed = false; break;
case Keyboard.RIGHT : rightIsPressed = false; break;
case Keyboard.UP : upIsPressed = false; break;
case Keyboard.DOWN : downIsPressed = false; break;
}
}
function enterFrameHandler(e:Event):void {
vx = -int(leftIsPressed)*speed + int(rightIsPressed)*speed;
vy = -int(upIsPressed)*speed + int(downIsPressed)*speed;
PlayerAuto.x += vx;
PlayerAuto.y += vy;
}
function generateParticles(event:Event):void
{
//so we don't do it every frame, we'll do it randomly
if(Math.random()*10 < 2){
//creating a new shape
var mcParticle:Shape = new Shape();
//making random dimensions (only ranges from 1-5 px)
var dimensions:int = int(Math.random()*5)+1;
//add color to the shape
mcParticle.graphics.beginFill(0x999999/*The color for shape*/,1/*The alpha for the shape*/);
//turning the shape into a square
mcParticle.graphics.drawRect(dimensions,dimensions,dimensions,dimensions);
//change the coordinates of the particle
mcParticle.x = int(Math.random()*stage.stageWidth);
mcParticle.y = -10;
//adding the particle to stage
particleContainer.stage.addChild(mcParticle);
}
//making all of the particles move down stage
for(var i:int=0;i<particleContainer.numChildren;i++){
//getting a certain particle
var theParticle:DisplayObject = particleContainer.getChildAt(i);
//it'll go half the speed of the character
theParticle.y += speed*.5;
//checking if the particle is offstage
if(theParticle.y >= 400){
//remove it
particleContainer.stage.removeChild(theParticle);
}
}
}
/**
* eventhandler voor als je op de tweede knop klikt
*/
private function loadScreenThree( event:MouseEvent ):void
{
// eerst opruimen!
cleanListeners();
// dan naar ander scherm
Project.instance.switchScreen( "derde" );
}
private function cleanListeners():void
{
drieButton.removeEventListener( MouseEvent.CLICK, loadScreenThree );
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.removeEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
stage.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.removeEventListener(Event.ENTER_FRAME, generateParticles);
}
}
}
I think the problem is here:
for(var i:int=0;i<particleContainer.numChildren;i++){
var theParticle:DisplayObject = particleContainer.getChildAt(i);
[...]
if (theParticle.y >= 400){
particleContainer.removeChild(theParticle);
}
}
You are removing children from the particleContainer while iterating through it. This is usually a bad idea because once you remove an item from the beginning, you are changing the index of all following items.
One solution is to loop backwards, so when you remove something the only items changed are the ones that you already checked.
for(var i:int=particleContainer.numChildren - 1; i>=0; i--){
And the rest keeps the same.
I wanted to setup an array of movieclip buttons to navigate across my timeline via labels, this is where it went pear shaped.
Having spent three days reading and attempting most online solutions I couldn't find a method which worked 100% without failing in some way or another.
I've had some joy with the method below having seen a blog entry covering different ways to call frames etc and which highlighted the bugbear below :
clipArray[i].mouseChildren = false; //Hidden bugbear
I've added the full code below so hopefully it may help anyone else who similarly nearly resorted to hari-kari in trying this.
import flash.events.MouseEvent;
import flash.events.Event;
var clipArray:Array = [btn_1,btn_2]; // Movieclip's called btn_1 etc...
var destArray:Array = ["page_1","page_2"]; Labels on timeline...
for (var i:int = 0; i < clipArray.length; i++) {
clipArray[i].buttonMode = true; // Define Button from Movie Clip
clipArray[i].useHandCursor = true; // Enable HandCursor over clip
clipArray[i].mouseChildren = false; // Define clip as single denomination
clipArray[i].addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
clipArray[i].addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
clipArray[i].addEventListener(Event.ENTER_FRAME, frameHandler);
clipArray[i].addEventListener(MouseEvent.CLICK,clickHandler, false, 0, true);
}
function clickHandler(event:MouseEvent):void {
for (var i:int = 0; i < clipArray.length; i++) {
if (event.currentTarget == clipArray[i]) {
this.gotoAndStop(destArray[i]);
clipArray[i].mouseEnabled = false;
clipArray[i].useHandCursor = false;
clipArray[i].alpha = 0.5;
} else {
clipArray[i].mouseEnabled = true;
clipArray[i].useHandCursor = true;
clipArray[i].alpha = 1;
}
}
}
function mouseOverHandler(e:MouseEvent){
e.target.onOff = true;
}
function mouseOutHandler(e:MouseEvent){
e.target.onOff = false;
}
function frameHandler(e:Event){
if(e.target.onOff){
e.target.nextFrame();
} else {
e.target.prevFrame();
}
}
This works fine, now however my understanding of whether it is 'good' code or not is an issue, if this could be improved in any way I'd like to know why and how as the problem with learning AS3 from 2 is that often you use code having seen it online without fully grasping the detail.
Tentatively, I'm pleased as this proved to be a nightmare to find or to resolve and hope it helps anyone else in a similar state of mind.
Adding MovieClip buttons with fluidity and which cancel out from an array became a three day mission when you're learning...
You might find you have more freedom if you put all of this in a class and use the Tween class to travel to your 'labels' instead of the timeline. It would mean that you would be able to remove your event listeners until your animation has finished.
Also it looks like you might be better off using the MouseEvent.ROLL_OVER and MouseEvent.ROLL_OUT
If I'm honest I don't know what some of your methods want to do without seeing your whole project, but I've quickly written a class for you. I've replaced animating between pages with just having your buttons animate to a ramdom location. (Remember to export your MovieClips you create with the IDE into actionscript, giving them the class name Button01, Button02 etc...). I hope this sends you in the right direction :)
package com
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
public class Main extends MovieClip
{
private var btn_1:Button01 = new Button01;
private var btn_2:Button02 = new Button02;
private var clipArray:Array = new Array();
private var xAxis:Number = 0;
private var yAxis:Number = 0;
private static const WIDTH:int = 300;
private static const HEIGHT:int = 250;
private var tweenButton:Tween;
public function Main()
{
makeArrays();
addChildren();
setEventListeners()
}
private function makeArrays():void
{
for(var i:uint=0; i<2; i++)
clipArray.push(this['btn_'+(i+1)]);
}
private function addChildren():void
{
for(var i:uint=0; i<clipArray.length; i++){
addChild(clipArray[i]);
clipArray[i].x = WIDTH*Math.random();
clipArray[i].y = HEIGHT*Math.random();
}
}
private function setEventListeners():void
{
for (var i:uint=0; i<clipArray.length; i++) {
clipArray[i].buttonMode = true; // Define Button from Movie Clip
//clipArray[i].useHandCursor = true; // Enable HandCursor over clip
//clipArray[i].mouseChildren = false; // Define clip as single denomination // DON'T NEED THIS WITH ROLL_OVER
clipArray[i].addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler);
clipArray[i].addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler);
clipArray[i].addEventListener(Event.ENTER_FRAME, frameHandler);
clipArray[i].addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true);
}
}
private function tweenButtons(e:Event):void
{
var dispObj = e.currentTarget as DisplayObject;
dispObj.removeEventListener(MouseEvent.CLICK, clickHandler)
tweenButton = new Tween(dispObj, 'x', Regular.easeIn, dispObj.x, WIDTH*Math.random(), 1, true);
tweenButton = new Tween(dispObj, 'y', Regular.easeIn, dispObj.y, HEIGHT*Math.random(), 1, true);
tweenButton.addEventListener(TweenEvent.MOTION_FINISH, reattachEventListener);
}
private function reattachEventListener(e:Event):void
{
tweenButton.removeEventListener(TweenEvent.MOTION_FINISH, reattachEventListener);
for (var i:uint=0; i<clipArray.length; i++) {
if(!(hasEventListener(MouseEvent.CLICK)))
clipArray[i].addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true);
}
}
private function clickHandler(e:MouseEvent):void
{
for (var i:uint=0; i<clipArray.length; i++) {
if (e.currentTarget == clipArray[i]) {
tweenButtons(e);
clipArray[i].buttonMode = false
clipArray[i].alpha = 0.5;
} else {
clipArray[i].buttonMode = true;
clipArray[i].alpha = 1;
}
}
}
private function mouseOverHandler(e:MouseEvent):void // I HAVE NO IDEA WHAT YOU'RE TRYING TO DO HERE
{
e.target.onOff = true;
}
private function mouseOutHandler(e:MouseEvent):void // I HAVE NO IDEA WHAT YOU'RE TRYING TO DO HERE
{
e.target.onOff = false;
}
private function frameHandler(e:Event):void // I HAVE NO IDEA WHAT YOU'RE TRYING TO DO HERE
{
if(e.target.onOff){
e.target.nextFrame();
}else{
e.target.prevFrame();
}
}
}
}
Hi I try pass my Arry to Class. I try to pass it and it look like this:
Frame 32 earlier are some animations.
import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
import Wyjazd;
stop();
ofertaBTN.addEventListener(MouseEvent.CLICK, wyskok);
function wyskok(e:MouseEvent)
{
var vektor:Array = new Array(I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII);
var menu:Wyjazd = new Wyjazd(vektor);
}
Class
package
{
import fl.transitions.Tween;
import fl.motion.easing.*;
import flash.filters.*;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.MovieClip;
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array)
{
var xX = ar.x;
var time:Number = 2;
var offset:Number = 0;
for (var i:Number = 0; i < 12; i++)
{
var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,266.65 + offset,time,true);
ar[i].addEventListener(MouseEvent.MOUSE_OVER,podswietlenie);
ar[i].addEventListener(MouseEvent.MOUSE_OUT,zgaszenie);
time += 0.2;
offset += 15.25;
}
function zgaszenie(e:MouseEvent)
{
ar[i].filters = [];
}
function podswietlenie(e:MouseEvent)
{
var pods:GlowFilter = new GlowFilter ;
pods.inner = false;
pods.color = 0x000000;
pods.knockout = false;
ar[i].filters = [pods];
}
/*var targetLabel:String;
ar.addEventListener(MouseEvent.MOUSE_OVER, podswietlenie);
ar.addEventListener(MouseEvent.MOUSE_OUT, zgaszenie);
ar.addEventListener(MouseEvent.CLICK,przejscie);
function przejscie(e:MouseEvent)
{
targetLabel= e.currentTarget.name;
tween = new Tween(ar,"x",Sine.easeOut,ar.x,xX,time,true);
trace(targetLabel);
}*/
}
}
}
But I still gets Error #1063. It say that I pass no argument. How pass it properly? So Could you help me?
UPDATE #1:
I use try use trace. Frame code isn't chance but Class look like this.
package
{
import fl.transitions.Tween;
import fl.motion.easing.*;
import flash.filters.*;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.display.MovieClip;
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array)
{
trace(ar.length);
//reast is commented
}
}
}
But still, I got Error #1063, we must go deeper. Then I change frame code:
import flash.events.MouseEvent;
import fl.transitions.Tween;
import flash.display.MovieClip;
stop();
ofertaBTN.addEventListener(MouseEvent.CLICK, wyskok);
function wyskok(e:MouseEvent)
{
var vektor:Array = [I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII];
trace(vektor.lenght);
//var menu:Wyjazd = new Wyjazd(vektor);
}
Now I got Error #1007 Instantiation attempted on a non-constructor. at site_fla::MainTimeline/wyskok()
It looks like you meant to quote each of the values in the array:
new Array('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII');
To narrow it down, I would suggest commenting out your Wyjazd function code and replacing it with a trace statement such as trace(ar.length);
See if you can run that and if it traces out the array length. If it can, then the problem is not the passing of the array to the function.
I was able to test this and it worked for me when I created this, so that's why I suggest the above.
If it does still throw the same error, then can you supply me with a little more information?
Are you using Flash Professional?
Are you calling var vektor from frame 1 in the actions tab?
Are you calling the Wyjazd class from your main document any other way (such as adding the class to the .fla properties?
Try this:
var vektor:Array = [I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII];
Also, I think this line is not correct:
var xX = ar.x;
.. and btw, you could change this too
// for (var i:Number = 0; i < 12; i++)
for (var i:int = 0; i < ar.length; i++)
You can't have a parameter for a symbol that is instanciate from the IDE, check this similar question and answer : AS3 not accepting constructor
You have to try to initialize your class differentely, but it really depends on your usage
for example :
public class Wyjazd extends MovieClip
{
public function Wyjazd(ar:Array=null) // use a default parameter
{
if (ar!=null) init(ar) // call your init function
}
public function init(ar:Array):void {
var xX = ar.x;
var time:Number = 2;
var offset:Number = 0;
for (var i:Number = 0; i < 12; i++)
{
var tween:Tween = new Tween(ar[i],"x",Sine.easeOut,ar[i].x,266.65 + offset,time,true);
ar[i].addEventListener(MouseEvent.MOUSE_OVER,podswietlenie);
ar[i].addEventListener(MouseEvent.MOUSE_OUT,zgaszenie);
time += 0.2;
offset += 15.25;
}
function zgaszenie(e:MouseEvent)
{
ar[i].filters = [];
}
function podswietlenie(e:MouseEvent)
{
var pods:GlowFilter = new GlowFilter ;
pods.inner = false;
pods.color = 0x000000;
pods.knockout = false;
ar[i].filters = [pods];
}
/*var targetLabel:String;
ar.addEventListener(MouseEvent.MOUSE_OVER, podswietlenie);
ar.addEventListener(MouseEvent.MOUSE_OUT, zgaszenie);
ar.addEventListener(MouseEvent.CLICK,przejscie);
function przejscie(e:MouseEvent)
{
targetLabel= e.currentTarget.name;
tween = new Tween(ar,"x",Sine.easeOut,ar.x,xX,time,true);
trace(targetLabel);
}*/
}
}
}
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