Skip to main content
Adrien_
Known Participant
July 23, 2011
Question

why does action script not support constructor over loading?

  • July 23, 2011
  • 1 reply
  • 257 views

This would make life so much simpler? is there an official reason or is it "were too lazy"

This topic has been closed for replies.

1 reply

Inspiring
July 23, 2011

Don't know how anyone could answer the why here, unless they're an Adobe engineer. You can simulate overloading with an arguments array.

public function doSomething (myObject:Object = null, ...rest)

So you could do something like

public function savePersonalListItems (personName:String, ...rest) and then act upon the array of parameters that would be passed into the rest array. http://www.sephiroth.it/weblog/archives/2006/06/actionscript_3_rest_parameter.php

If you want to overload with known entities, it's probably just as good to go with default values so they parameters become optional

public function saveTopThreeItems( object1:Object = new Object(), object2:Object = new Object(), object3:Objects = new Object())

then you can pass in none or all three. Just some ideas that you may already implement.