[Flashcoders] RE:Flashcoders] Extending Array Question
Thanks, that will work. So there is no definitive way to add the values all at once, i.e. [1,4,5,76,3] when extending an Array? Thanks again. Ian Thomasn wrote: Hi there (whoever you are!) Your problem is that the [1,2,3] initialiser syntax is actually a short cut for creating a new Array() object, not an ArrayExtension(). So you're replacing the object you just created with new(). What you need to do is to _modify_ your ArrayExtension() object, not replace it. If you try: var myArray:ArrayExtension = new ArrayExtension(); myArray.push(Hello); myArray.push(Goodbye); myArray.push(World); That should sort your problem. HTH, Ian ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] RE:Flashcoders] Extending Array Question
You could also do: var myArray:ArrayExtension = new ArrayExtension(); myArray.push(Hello, Goodbye, World); same result as doing them separately. [EMAIL PROTECTED] wrote: Thanks, that will work. So there is no definitive way to add the values all at once, i.e. [1,4,5,76,3] when extending an Array? Thanks again. Ian Thomasn wrote: Hi there (whoever you are!) Your problem is that the [1,2,3] initialiser syntax is actually a short cut for creating a new Array() object, not an ArrayExtension(). So you're replacing the object you just created with new(). What you need to do is to _modify_ your ArrayExtension() object, not replace it. If you try: var myArray:ArrayExtension = new ArrayExtension(); myArray.push(Hello); myArray.push(Goodbye); myArray.push(World); That should sort your problem. HTH, Ian ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- ~ Bob Leisle Headsprout Software Engineering http://www.headsprout.com Where kids learn to read! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] RE:Flashcoders] Extending Array Question
class com.ArrayExtension extends Array { public function ArrayExtension() { super() var argString = arguments[0].split(,); for(var i=0; i argString.length; i++) push(argString[i]); } } Usage: var arEx = new ArrayExtension(one,two,three); trace(arEx.length); hth, Mike On 4/18/06, Robert Leisle [EMAIL PROTECTED] wrote: You could also do: var myArray:ArrayExtension = new ArrayExtension(); myArray.push(Hello, Goodbye, World); same result as doing them separately. [EMAIL PROTECTED] wrote: Thanks, that will work. So there is no definitive way to add the values all at once, i.e. [1,4,5,76,3] when extending an Array? Thanks again. Ian Thomasn wrote: Hi there (whoever you are!) Your problem is that the [1,2,3] initialiser syntax is actually a short cut for creating a new Array() object, not an ArrayExtension(). So you're replacing the object you just created with new(). What you need to do is to _modify_ your ArrayExtension() object, not replace it. If you try: var myArray:ArrayExtension = new ArrayExtension(); myArray.push(Hello); myArray.push(Goodbye); myArray.push(World); That should sort your problem. HTH, Ian ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- ~ Bob Leisle Headsprout Software Engineering http://www.headsprout.com Where kids learn to read! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- Mike -- http://www.mikebritton.com http://www.mikenkim.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] RE:Flashcoders] Extending Array Question
Another solution: // ActionScript 2.0 Class Definition: com/ArrayExtension.as dynamic class com.ArrayExtension extends Array { function ArrayExtension() { if (arguments.length == 1 !isNaN(arguments[0])) { this.length = arguments[0]; } else { this.push.apply(this, arguments); } } } // fla for Testing // Frame Action import com.ArrayExtension; var arEx0:ArrayExtension = new ArrayExtension(one, two, three); trace([arEx0.length, arEx0]); // Output: 3,one,two,three var arEx1:ArrayExtension = new ArrayExtension(3); trace([arEx1.length, arEx1]); // Output: 3,undefined,undefined,undefined // [Debug] [List Variables]: Variable _level0.arEx0 = [Object #3] [ 0:one, 1:two, 2:three ] Variable _level0.arEx1 = [Object #4] [] _ Mike Britton wrote: class com.ArrayExtension extends Array { public function ArrayExtension() { super() var argString = arguments[0].split(,); for(var i=0; i argString.length; i++) push(argString[i]); } } Usage: var arEx = new ArrayExtension(one,two,three); trace(arEx.length); Good luck, Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com