|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
|
|
Porting issue with Array() constructor vs. typecasterHi all, -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterIn case... have you tried
myArray:Array = [myArrayOfArrays[0]]; ? Allen, Bruce Contractor, MPSC a écrit : > > > Hi all, > > MTASC Porting issue: > > I have an array of arrays, and I want to assign an element to an Array > variable. My happy solution with MTASC is: > > var myArray:Array=Array(myArrayOfArrays[0]) > > This is fine with MTASC, but is a problem with MMC because MMC > compiles differently. In MMC, the Array(myVariable) code works as an > Array constructor rather than a type caster, resulting in a nested array. > > I like how MTASC works, but this was a gotcha for me because I didn’t > expect MMC to be deficient. Is there a list of MMC vs. MTASC compiler > differences with things like this in it? Is there an MMC-compatible > solution for assigning an element of an array into a variable typed as > an Array? > > Thanks, > -Bruce Allen > -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterThe problem is, is that he is NOT creating a new array but he's casting the reference in myArrayOfArrays[0] to the myArray variable. When running his code, MMC doesn't cast but creates a new array (like your code does) which he doesn't want.
Bruce, I haven't tried this or anything, but can't you just say: myArray:Array = myArrayOfArrays[0]; without the cast? Or does that throw up a type cast error in MTASC? - Luke On 11/09/2007, at 10:02 AM, Julien D wrote:
-- MTASC : no more coffee break while compiling |
|
|
RE: Porting issue with Array() constructor vs. typecasterNo, myArrayOfArrays[0] is of type Object, so neither compiler will allow the assignment into myArray:Array.
-Bruce -----Original Message----- From: mtasc-bounces@... on behalf of Luke Schreur Sent: Mon 9/10/2007 5:16 PM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster The problem is, is that he is NOT creating a new array but he's casting the reference in myArrayOfArrays[0] to the myArray variable. When running his code, MMC doesn't cast but creates a new array (like your code does) which he doesn't want. Bruce, I haven't tried this or anything, but can't you just say: myArray:Array = myArrayOfArrays[0]; without the cast? Or does that throw up a type cast error in MTASC? - Luke On 11/09/2007, at 10:02 AM, Julien D wrote: > In case... have you tried > myArray:Array = [myArrayOfArrays[0]]; > ? > > Allen, Bruce Contractor, MPSC a écrit : >> >> >> Hi all, >> >> MTASC Porting issue: >> >> I have an array of arrays, and I want to assign an element to an >> Array variable. My happy solution with MTASC is: >> >> var myArray:Array=Array(myArrayOfArrays[0]) >> >> This is fine with MTASC, but is a problem with MMC because MMC >> compiles differently. In MMC, the Array(myVariable) code works as >> an Array constructor rather than a type caster, resulting in a >> nested array. >> >> I like how MTASC works, but this was a gotcha for me because I >> didn't expect MMC to be deficient. Is there a list of MMC vs. >> MTASC compiler differences with things like this in it? Is there >> an MMC-compatible solution for assigning an element of an array >> into a variable typed as an Array? >> >> Thanks, >> -Bruce Allen >> > > > -- > MTASC : no more coffee break while compiling > > -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterBut a cast does not convert. If myArrayOfArrays[0] is an Object then Array( myArrayOfArrays[0] ) will not make it an array. Or do I misunderstand what you're saying... On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote:
-- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterhi there,
i was just wondering... have you tried: var myArray:Array = new Array(myArrayOfArrays[0].lenght); myArray = myArrayOfArrays[0]; apart from that a list with the differences would be much appreciated. cheers, jan Luke Schreur schrieb: > But a cast does not convert. If myArrayOfArrays[0] is an Object then > Array( myArrayOfArrays[0] ) will not make it an array. Or do I > misunderstand what you're saying... > > > On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: > >> No, myArrayOfArrays[0] is of type Object, so neither compiler will >> allow the assignment into myArray:Array. >> -Bruce >> >> >> -----Original Message----- >> From: mtasc-bounces@... >> <mailto:mtasc-bounces@...> on behalf of Luke Schreur >> Sent: Mon 9/10/2007 5:16 PM >> To: MotionTwin ActionScript2 Compiler List >> Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster >> >> The problem is, is that he is NOT creating a new array but he's >> casting the reference in myArrayOfArrays[0] to the myArray variable. >> When running his code, MMC doesn't cast but creates a new array (like >> your code does) which he doesn't want. >> >> Bruce, I haven't tried this or anything, but can't you just say: >> >> myArray:Array = myArrayOfArrays[0]; >> >> without the cast? Or does that throw up a type cast error in MTASC? >> >> - Luke >> >> >> On 11/09/2007, at 10:02 AM, Julien D wrote: >> >>> In case... have you tried >>> myArray:Array = [myArrayOfArrays[0]]; >>> ? >>> >>> Allen, Bruce Contractor, MPSC a écrit : >>>> >>>> >>>> Hi all, >>>> >>>> MTASC Porting issue: >>>> >>>> I have an array of arrays, and I want to assign an element to an >>>> Array variable. My happy solution with MTASC is: >>>> >>>> var myArray:Array=Array(myArrayOfArrays[0]) >>>> >>>> This is fine with MTASC, but is a problem with MMC because MMC >>>> compiles differently. In MMC, the Array(myVariable) code works as >>>> an Array constructor rather than a type caster, resulting in a >>>> nested array. >>>> >>>> I like how MTASC works, but this was a gotcha for me because I >>>> didn't expect MMC to be deficient. Is there a list of MMC vs. >>>> MTASC compiler differences with things like this in it? Is there >>>> an MMC-compatible solution for assigning an element of an array >>>> into a variable typed as an Array? >>>> >>>> Thanks, >>>> -Bruce Allen >>>> >>> >>> >>> -- >>> MTASC : no more coffee break while compiling >>> >>> >> >> >> >> >> >> >> >> >> The WatchGuard Firebox which protects your network detected a message >> which may not be safe. >> >> Cause : The file type may not be safe. >> Content type : application/ms-tnef >> File name : winmail.dat >> Virus status : No information. >> Action : The Firebox deleted winmail.dat. >> >> Your network administrator can not restore this attachment. >> >> -- >> MTASC : no more coffee break while compiling > > > -- MTASC : no more coffee break while compiling |
|
|
RE: Porting issue with Array() constructor vs. typecasterOkay, I'll reword the issue:
Variable myArrayOfArrays is an array and its elements such as myArrayOfArrays[0] are also arrays. I want to put element myArrayOfArrays[0] into variable myArray:Array. Unlike MTASC, which allows us to specify typing for Array elements, the MMC compiler forces array elements to be of type Object. But I know my array element is of type Array, so I want to put it into a variable of type Array. Typically, you can typecast your array element into the type you need as soon as you get it out of the array, but MMC treats the syntax for typecasting to type Array as an Array constructor. MTASC treats the syntax for typecasting to type Array as a typecast, and I like it that way, but it leaves me with two problems: 1) I don't know how to typecast an array element from type Object to type Array in a way that is compatible with MMC. 2) I don't like writing code that breaks when other people compile it in MMC. It makes it harder to get people to accept MTASC. This is why I am asking if we have a complete list of compiler differences. -Bruce -----Original Message----- From: mtasc-bounces@... on behalf of Luke Schreur Sent: Mon 9/10/2007 11:06 PM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster But a cast does not convert. If myArrayOfArrays[0] is an Object then Array( myArrayOfArrays[0] ) will not make it an array. Or do I misunderstand what you're saying... On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: > No, myArrayOfArrays[0] is of type Object, so neither compiler will > allow the assignment into myArray:Array. > -Bruce > > > -----Original Message----- > From: mtasc-bounces@... on behalf of Luke Schreur > Sent: Mon 9/10/2007 5:16 PM > To: MotionTwin ActionScript2 Compiler List > Subject: Re: [mtasc] Porting issue with Array() constructor vs. > typecaster > > The problem is, is that he is NOT creating a new array but he's > casting the reference in myArrayOfArrays[0] to the myArray variable. > When running his code, MMC doesn't cast but creates a new array (like > your code does) which he doesn't want. > > Bruce, I haven't tried this or anything, but can't you just say: > > myArray:Array = myArrayOfArrays[0]; > > without the cast? Or does that throw up a type cast error in MTASC? > > - Luke > > > On 11/09/2007, at 10:02 AM, Julien D wrote: > >> In case... have you tried >> myArray:Array = [myArrayOfArrays[0]]; >> ? >> >> Allen, Bruce Contractor, MPSC a écrit : >>> >>> >>> Hi all, >>> >>> MTASC Porting issue: >>> >>> I have an array of arrays, and I want to assign an element to an >>> Array variable. My happy solution with MTASC is: >>> >>> var myArray:Array=Array(myArrayOfArrays[0]) >>> >>> This is fine with MTASC, but is a problem with MMC because MMC >>> compiles differently. In MMC, the Array(myVariable) code works as >>> an Array constructor rather than a type caster, resulting in a >>> nested array. >>> >>> I like how MTASC works, but this was a gotcha for me because I >>> didn't expect MMC to be deficient. Is there a list of MMC vs. >>> MTASC compiler differences with things like this in it? Is there >>> an MMC-compatible solution for assigning an element of an array >>> into a variable typed as an Array? >>> >>> Thanks, >>> -Bruce Allen >>> >> >> >> -- >> MTASC : no more coffee break while compiling >> >> > > > > > > > > > The WatchGuard Firebox which protects your network detected a > message which may not be safe. > > Cause : The file type may not be safe. > Content type : application/ms-tnef > File name : winmail.dat > Virus status : No information. > Action : The Firebox deleted winmail.dat. > > Your network administrator can not restore this attachment. > > -- > MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling |
|
|
RE: Porting issue with Array() constructor vs. typecasterThis still has the problem of trying to assign a value of type Object into a variable of type Array at line "myArray = myArrayOfArrays[0];".
-Bruce -----Original Message----- From: mtasc-bounces@... on behalf of jannerick Sent: Tue 9/11/2007 2:29 AM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster hi there, i was just wondering... have you tried: var myArray:Array = new Array(myArrayOfArrays[0].lenght); myArray = myArrayOfArrays[0]; apart from that a list with the differences would be much appreciated. cheers, jan Luke Schreur schrieb: > But a cast does not convert. If myArrayOfArrays[0] is an Object then > Array( myArrayOfArrays[0] ) will not make it an array. Or do I > misunderstand what you're saying... > > > On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: > >> No, myArrayOfArrays[0] is of type Object, so neither compiler will >> allow the assignment into myArray:Array. >> -Bruce >> >> >> -----Original Message----- >> From: mtasc-bounces@... >> <mailto:mtasc-bounces@...> on behalf of Luke Schreur >> Sent: Mon 9/10/2007 5:16 PM >> To: MotionTwin ActionScript2 Compiler List >> Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster >> >> The problem is, is that he is NOT creating a new array but he's >> casting the reference in myArrayOfArrays[0] to the myArray variable. >> When running his code, MMC doesn't cast but creates a new array (like >> your code does) which he doesn't want. >> >> Bruce, I haven't tried this or anything, but can't you just say: >> >> myArray:Array = myArrayOfArrays[0]; >> >> without the cast? Or does that throw up a type cast error in MTASC? >> >> - Luke >> >> >> On 11/09/2007, at 10:02 AM, Julien D wrote: >> >>> In case... have you tried >>> myArray:Array = [myArrayOfArrays[0]]; >>> ? >>> >>> Allen, Bruce Contractor, MPSC a écrit : >>>> >>>> >>>> Hi all, >>>> >>>> MTASC Porting issue: >>>> >>>> I have an array of arrays, and I want to assign an element to an >>>> Array variable. My happy solution with MTASC is: >>>> >>>> var myArray:Array=Array(myArrayOfArrays[0]) >>>> >>>> This is fine with MTASC, but is a problem with MMC because MMC >>>> compiles differently. In MMC, the Array(myVariable) code works as >>>> an Array constructor rather than a type caster, resulting in a >>>> nested array. >>>> >>>> I like how MTASC works, but this was a gotcha for me because I >>>> didn't expect MMC to be deficient. Is there a list of MMC vs. >>>> MTASC compiler differences with things like this in it? Is there >>>> an MMC-compatible solution for assigning an element of an array >>>> into a variable typed as an Array? >>>> >>>> Thanks, >>>> -Bruce Allen >>>> >>> >>> >>> -- >>> MTASC : no more coffee break while compiling >>> >>> >> >> >> >> >> >> >> >> >> The WatchGuard Firebox which protects your network detected a message >> which may not be safe. >> >> Cause : The file type may not be safe. >> Content type : application/ms-tnef >> File name : winmail.dat >> Virus status : No information. >> Action : The Firebox deleted winmail.dat. >> >> Your network administrator can not restore this attachment. >> >> -- >> MTASC : no more coffee break while compiling > > > MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasteroops, sorry there has been a type error. i meant it in another war, like:
myArray = Array(myArrayOfArrays[0]); because i am started being really interested, i just tried it out myself: // AS var twoDimArr:Array = new Array(2); twoDimArr[0] = new Array(2); twoDimArr[1] = new Array(2); twoDimArr[0][0] = 0; twoDimArr[0][1] = 1; trace(twoDimArr[0]); var arrOne:Array = twoDimArr[0]; var arrTwo:Array = Array(twoDimArr[0]); var arrThree:Array = new Array(twoDimArr.length); arrThree = Array(twoDimArr[0]); twoDimArr[0][1] = 'new value'; trace(twoDimArr[0]); trace(arrOne); trace(arrTwo); trace(arrThree); // AS traces are: 0,1 0,new value 0,new value 0,new value 0,new value compiled in flash cs3 with settings for the player 8 and as2.0 cheers, jan Allen, Bruce Contractor, MPSC schrieb: > This still has the problem of trying to assign a value of type Object into a variable of type Array at line "myArray = myArrayOfArrays[0];". > > -Bruce > > > -----Original Message----- > From: mtasc-bounces@... on behalf of jannerick > Sent: Tue 9/11/2007 2:29 AM > To: MotionTwin ActionScript2 Compiler List > Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster > > hi there, > > i was just wondering... have you tried: > var myArray:Array = new Array(myArrayOfArrays[0].lenght); > myArray = myArrayOfArrays[0]; > > apart from that a list with the differences would be much appreciated. > > cheers, jan > > Luke Schreur schrieb: >> But a cast does not convert. If myArrayOfArrays[0] is an Object then >> Array( myArrayOfArrays[0] ) will not make it an array. Or do I >> misunderstand what you're saying... >> >> >> On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: >> >>> No, myArrayOfArrays[0] is of type Object, so neither compiler will >>> allow the assignment into myArray:Array. >>> -Bruce >>> >>> >>> -----Original Message----- >>> From: mtasc-bounces@... >>> <mailto:mtasc-bounces@...> on behalf of Luke Schreur >>> Sent: Mon 9/10/2007 5:16 PM >>> To: MotionTwin ActionScript2 Compiler List >>> Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster >>> >>> The problem is, is that he is NOT creating a new array but he's >>> casting the reference in myArrayOfArrays[0] to the myArray variable. >>> When running his code, MMC doesn't cast but creates a new array (like >>> your code does) which he doesn't want. >>> >>> Bruce, I haven't tried this or anything, but can't you just say: >>> >>> myArray:Array = myArrayOfArrays[0]; >>> >>> without the cast? Or does that throw up a type cast error in MTASC? >>> >>> - Luke >>> >>> >>> On 11/09/2007, at 10:02 AM, Julien D wrote: >>> >>>> In case... have you tried >>>> myArray:Array = [myArrayOfArrays[0]]; >>>> ? >>>> >>>> Allen, Bruce Contractor, MPSC a écrit : >>>>> >>>>> Hi all, >>>>> >>>>> MTASC Porting issue: >>>>> >>>>> I have an array of arrays, and I want to assign an element to an >>>>> Array variable. My happy solution with MTASC is: >>>>> >>>>> var myArray:Array=Array(myArrayOfArrays[0]) >>>>> >>>>> This is fine with MTASC, but is a problem with MMC because MMC >>>>> compiles differently. In MMC, the Array(myVariable) code works as >>>>> an Array constructor rather than a type caster, resulting in a >>>>> nested array. >>>>> >>>>> I like how MTASC works, but this was a gotcha for me because I >>>>> didn't expect MMC to be deficient. Is there a list of MMC vs. >>>>> MTASC compiler differences with things like this in it? Is there >>>>> an MMC-compatible solution for assigning an element of an array >>>>> into a variable typed as an Array? >>>>> >>>>> Thanks, >>>>> -Bruce Allen >>>>> >>>> >>>> -- >>>> MTASC : no more coffee break while compiling >>>> >>>> >>> >>> >>> >>> >>> >>> >>> >>> The WatchGuard Firebox which protects your network detected a message >>> which may not be safe. >>> >>> Cause : The file type may not be safe. >>> Content type : application/ms-tnef >>> File name : winmail.dat >>> Virus status : No information. >>> Action : The Firebox deleted winmail.dat. >>> >>> Your network administrator can not restore this attachment. >>> >>> -- >>> MTASC : no more coffee break while compiling >> >> > -- MTASC : no more coffee break while compiling |
|
|
RE: Porting issue with Array() constructor vs. typecasterThanks, Jan, I have been making an invalid assertion.
myArray:Array=twoDimArray[0] works, but myArray:Array=twoDimArray.shift() fails. It looks like the compiler's type checking accepts the implicit accessor (using [0]) but fails using the method accessor (using shift()). So my workaround is to assign typed variables using subscripts, not Array methods. In my case, I can do the following: myArray:Array=twoDimArray[0]; uselessVariable:Object=twoDimArray.shift(); Thanks again, -Bruce -----Original Message----- From: mtasc-bounces@... on behalf of jannerick Sent: Tue 9/11/2007 10:49 AM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster oops, sorry there has been a type error. i meant it in another war, like: myArray = Array(myArrayOfArrays[0]); because i am started being really interested, i just tried it out myself: // AS var twoDimArr:Array = new Array(2); twoDimArr[0] = new Array(2); twoDimArr[1] = new Array(2); twoDimArr[0][0] = 0; twoDimArr[0][1] = 1; trace(twoDimArr[0]); var arrOne:Array = twoDimArr[0]; var arrTwo:Array = Array(twoDimArr[0]); var arrThree:Array = new Array(twoDimArr.length); arrThree = Array(twoDimArr[0]); twoDimArr[0][1] = 'new value'; trace(twoDimArr[0]); trace(arrOne); trace(arrTwo); trace(arrThree); // AS traces are: 0,1 0,new value 0,new value 0,new value 0,new value compiled in flash cs3 with settings for the player 8 and as2.0 cheers, jan Allen, Bruce Contractor, MPSC schrieb: > This still has the problem of trying to assign a value of type Object into a variable of type Array at line "myArray = myArrayOfArrays[0];". > > -Bruce > > > -----Original Message----- > From: mtasc-bounces@... on behalf of jannerick > Sent: Tue 9/11/2007 2:29 AM > To: MotionTwin ActionScript2 Compiler List > Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster > > hi there, > > i was just wondering... have you tried: > var myArray:Array = new Array(myArrayOfArrays[0].lenght); > myArray = myArrayOfArrays[0]; > > apart from that a list with the differences would be much appreciated. > > cheers, jan > > Luke Schreur schrieb: >> But a cast does not convert. If myArrayOfArrays[0] is an Object then >> Array( myArrayOfArrays[0] ) will not make it an array. Or do I >> misunderstand what you're saying... >> >> >> On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: >> >>> No, myArrayOfArrays[0] is of type Object, so neither compiler will >>> allow the assignment into myArray:Array. >>> -Bruce >>> >>> >>> -----Original Message----- >>> From: mtasc-bounces@... >>> <mailto:mtasc-bounces@...> on behalf of Luke Schreur >>> Sent: Mon 9/10/2007 5:16 PM >>> To: MotionTwin ActionScript2 Compiler List >>> Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster >>> >>> The problem is, is that he is NOT creating a new array but he's >>> casting the reference in myArrayOfArrays[0] to the myArray variable. >>> When running his code, MMC doesn't cast but creates a new array (like >>> your code does) which he doesn't want. >>> >>> Bruce, I haven't tried this or anything, but can't you just say: >>> >>> myArray:Array = myArrayOfArrays[0]; >>> >>> without the cast? Or does that throw up a type cast error in MTASC? >>> >>> - Luke >>> >>> >>> On 11/09/2007, at 10:02 AM, Julien D wrote: >>> >>>> In case... have you tried >>>> myArray:Array = [myArrayOfArrays[0]]; >>>> ? >>>> >>>> Allen, Bruce Contractor, MPSC a écrit : >>>>> >>>>> Hi all, >>>>> >>>>> MTASC Porting issue: >>>>> >>>>> I have an array of arrays, and I want to assign an element to an >>>>> Array variable. My happy solution with MTASC is: >>>>> >>>>> var myArray:Array=Array(myArrayOfArrays[0]) >>>>> >>>>> This is fine with MTASC, but is a problem with MMC because MMC >>>>> compiles differently. In MMC, the Array(myVariable) code works as >>>>> an Array constructor rather than a type caster, resulting in a >>>>> nested array. >>>>> >>>>> I like how MTASC works, but this was a gotcha for me because I >>>>> didn't expect MMC to be deficient. Is there a list of MMC vs. >>>>> MTASC compiler differences with things like this in it? Is there >>>>> an MMC-compatible solution for assigning an element of an array >>>>> into a variable typed as an Array? >>>>> >>>>> Thanks, >>>>> -Bruce Allen >>>>> >>>> >>>> -- >>>> MTASC : no more coffee break while compiling >>>> >>>> >>> >>> >>> >>> >>> >>> >>> >>> The WatchGuard Firebox which protects your network detected a message >>> which may not be safe. >>> >>> Cause : The file type may not be safe. >>> Content type : application/ms-tnef >>> File name : winmail.dat >>> Virus status : No information. >>> Action : The Firebox deleted winmail.dat. >>> >>> Your network administrator can not restore this attachment. >>> >>> -- >>> MTASC : no more coffee break while compiling >> >> > MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterHi Bruce, I ran into a similar problem today with Flash IDE compiler. Casting a reference to an Object that could be an Array to a reference of type Array actually creates a new Array instance. We already figured that out. I needed some graceful way of solving this issue and came up with the following construction: a : Array = ( new Array() ).concat( myObjectReferenceThatCouldbeAnArray ); Hope this might be useful to you in the future. - Luke On 12/09/2007, at 6:47 AM, Allen, Bruce Contractor, MPSC wrote:
-- MTASC : no more coffee break while compiling |
|
|
|
|
|
interface with getter/setterHello,
I try to create an interface with getter/setter but i have a syntax error : interface ITextField { public function set txt (sTxt:String); public function get txt ():String; } i don't find the error, can you help me please ? -- ________________________________________________ Matthieu Ressources Flash : http://www.delfiweb.com ________________________________________________ -- MTASC : no more coffee break while compiling |
|
|
RE: interface with getter/setteri may be wrong but i don't think you can declare those sorts of accessors in an interface. you'd to do something like:
interface ITextField { public function setTxt (sTxt:String); public function getTxt ():String; } but, like i say, i may be wrong... T ------------------------- Trevor Burton Flash Developer VirtueFusion 14-16 Betterton Street London, WC2H 9AH t: 0207 420 6420 m: 07954 239 024 ________________________________ From: mtasc-bounces@... on behalf of Matthieu Sent: Wed 19/09/2007 16:58 To: MotionTwin ActionScript2 Compiler List Subject: [mtasc] interface with getter/setter Hello, I try to create an interface with getter/setter but i have a syntax error : interface ITextField { public function set txt (sTxt:String); public function get txt ():String; } i don't find the error, can you help me please ? -- ________________________________________________ Matthieu Ressources Flash : http://www.delfiweb.com <http://www.delfiweb.com/> ________________________________________________ -- MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling |
|
|
RE: interface with getter/setterInterfaces can't have implemented functions, you can declare the method
in the interface but not its implementation, you'd need to put this in a baseclass. ------------------------------------ Bluetube Interactive Grant Davies President grant@... tel: 404-428-6839 fax: 708-983-1577 ------------------------------------ -----Original Message----- From: mtasc-bounces@... [mailto:mtasc-bounces@...] On Behalf Of Matthieu Sent: Wednesday, September 19, 2007 11:58 AM To: MotionTwin ActionScript2 Compiler List Subject: [mtasc] interface with getter/setter Hello, I try to create an interface with getter/setter but i have a syntax error : interface ITextField { public function set txt (sTxt:String); public function get txt ():String; } i don't find the error, can you help me please ? -- ________________________________________________ Matthieu Ressources Flash : http://www.delfiweb.com ________________________________________________ -- MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling |
|
|
Re: interface with getter/setterWhat about :
interface ITextField { public var txt:String; } ? Grant Davies a écrit : > Interfaces can't have implemented functions, you can declare the method > in the interface but not its implementation, you'd need to put this in a > baseclass. > > > > ------------------------------------ > Bluetube Interactive > Grant Davies > President > grant@... > tel: 404-428-6839 > fax: 708-983-1577 > ------------------------------------ > > -----Original Message----- > From: mtasc-bounces@... > [mailto:mtasc-bounces@...] On Behalf Of Matthieu > Sent: Wednesday, September 19, 2007 11:58 AM > To: MotionTwin ActionScript2 Compiler List > Subject: [mtasc] interface with getter/setter > > Hello, > > I try to create an interface with getter/setter but i have a syntax > error : > > interface ITextField > { > public function set txt (sTxt:String); > public function get txt ():String; > > } > > i don't find the error, can you help me please ? > > -- > ________________________________________________ > Matthieu > Ressources Flash : http://www.delfiweb.com > ________________________________________________ > > > > -- MTASC : no more coffee break while compiling |
|
|
Re: interface with getter/setterhi mathieu,
back in the days i did something like this: interface MyInterface { public function set _link(link:Object):Void; public function get _link():Object; } there is an error in eclipse, but the compiler throws no errors... cheers, jan Matthieu schrieb: > Hello, > > I try to create an interface with getter/setter but i have a syntax error : > > interface ITextField > { > public function set txt (sTxt:String); > public function get txt ():String; > } > > i don't find the error, can you help me please ? > -- MTASC : no more coffee break while compiling |
|
|
Re: interface with getter/setter
thanks for your answer.
Yes it's fdt who make a syntax error. I don't find solution but mtasc can compil. jannerick a écrit :
-- ________________________________________________ Matthieu Ressources Flash : http://www.delfiweb.com ________________________________________________ -- MTASC : no more coffee break while compiling |
|
|
RE: Porting issue with Array() constructor vs. typecasterThanks.
Now I have two solutions: 1) use the [] array access operator to avoid typing requirements, and 2) use concat() to return type Array when a reference to the original array is not required. -Bruce -----Original Message----- From: mtasc-bounces@... on behalf of Chris Miles Sent: Wed 9/19/2007 8:38 AM To: MotionTwin ActionScript2 Compiler List Subject: RE: [mtasc] Porting issue with Array() constructor vs. typecaster Beware that using concat will result in a *new* Array and not a reference to the original array. Depending on your usage that could be a problem. Chris ________________________________ From: mtasc-bounces@... [mailto:mtasc-bounces@...] On Behalf Of Luke Schreur Sent: 19 September 2007 03:47 To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster Hi Bruce, I ran into a similar problem today with Flash IDE compiler. Casting a reference to an Object that could be an Array to a reference of type Array actually creates a new Array instance. We already figured that out. I needed some graceful way of solving this issue and came up with the following construction: a : Array = ( new Array() ).concat( myObjectReferenceThatCouldbeAnArray ); Hope this might be useful to you in the future. - Luke On 12/09/2007, at 6:47 AM, Allen, Bruce Contractor, MPSC wrote: Thanks, Jan, I have been making an invalid assertion. myArray:Array=twoDimArray[0] works, but myArray:Array=twoDimArray.shift() fails. It looks like the compiler's type checking accepts the implicit accessor (using [0]) but fails using the method accessor (using shift()). So my workaround is to assign typed variables using subscripts, not Array methods. In my case, I can do the following: myArray:Array=twoDimArray[0]; uselessVariable:Object=twoDimArray.shift(); Thanks again, -Bruce -----Original Message----- From: mtasc-bounces@... on behalf of jannerick Sent: Tue 9/11/2007 10:49 AM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster oops, sorry there has been a type error. i meant it in another war, like: myArray = Array(myArrayOfArrays[0]); because i am started being really interested, i just tried it out myself: // AS var twoDimArr:Array = new Array(2); twoDimArr[0] = new Array(2); twoDimArr[1] = new Array(2); twoDimArr[0][0] = 0; twoDimArr[0][1] = 1; trace(twoDimArr[0]); var arrOne:Array = twoDimArr[0]; var arrTwo:Array = Array(twoDimArr[0]); var arrThree:Array = new Array(twoDimArr.length); arrThree = Array(twoDimArr[0]); twoDimArr[0][1] = 'new value'; trace(twoDimArr[0]); trace(arrOne); trace(arrTwo); trace(arrThree); // AS traces are: 0,1 0,new value 0,new value 0,new value 0,new value compiled in flash cs3 with settings for the player 8 and as2.0 cheers, jan Allen, Bruce Contractor, MPSC schrieb: This still has the problem of trying to assign a value of type Object into a variable of type Array at line "myArray = myArrayOfArrays[0];". -Bruce -----Original Message----- From: mtasc-bounces@... on behalf of jannerick Sent: Tue 9/11/2007 2:29 AM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster hi there, i was just wondering... have you tried: var myArray:Array = new Array(myArrayOfArrays[0].lenght); myArray = myArrayOfArrays[0]; apart from that a list with the differences would be much appreciated. cheers, jan Luke Schreur schrieb: But a cast does not convert. If myArrayOfArrays[0] is an Object then Array( myArrayOfArrays[0] ) will not make it an array. Or do I misunderstand what you're saying... On 11/09/2007, at 3:16 PM, Allen, Bruce Contractor, MPSC wrote: No, myArrayOfArrays[0] is of type Object, so neither compiler will allow the assignment into myArray:Array. -Bruce -----Original Message----- From: mtasc-bounces@... <mailto:mtasc-bounces@...> on behalf of Luke Schreur Sent: Mon 9/10/2007 5:16 PM To: MotionTwin ActionScript2 Compiler List Subject: Re: [mtasc] Porting issue with Array() constructor vs. typecaster The problem is, is that he is NOT creating a new array but he's casting the reference in myArrayOfArrays[0] to the myArray variable. When running his code, MMC doesn't cast but creates a new array (like your code does) which he doesn't want. Bruce, I haven't tried this or anything, but can't you just say: myArray:Array = myArrayOfArrays[0]; without the cast? Or does that throw up a type cast error in MTASC? - Luke On 11/09/2007, at 10:02 AM, Julien D wrote: In case... have you tried myArray:Array = [myArrayOfArrays[0]]; ? Allen, Bruce Contractor, MPSC a écrit : Hi all, MTASC Porting issue: I have an array of arrays, and I want to assign an element to an Array variable. My happy solution with MTASC is: var myArray:Array=Array(myArrayOfArrays[0]) This is fine with MTASC, but is a problem with MMC because MMC compiles differently. In MMC, the Array(myVariable) code works as an Array constructor rather than a type caster, resulting in a nested array. I like how MTASC works, but this was a gotcha for me because I didn't expect MMC to be deficient. Is there a list of MMC vs. MTASC compiler differences with things like this in it? Is there an MMC-compatible solution for assigning an element of an array into a variable typed as an Array? Thanks, -Bruce Allen -- MTASC : no more coffee break while compiling The WatchGuard Firebox which protects your network detected a message which may not be safe. Cause : The file type may not be safe. Content type : application/ms-tnef File name : winmail.dat Virus status : No information. Action : The Firebox deleted winmail.dat. Your network administrator can not restore this attachment. -- MTASC : no more coffee break while compiling -- MTASC : no more coffee break while compiling <mime-attachment.txt> <mime-attachment.txt> -- MTASC : no more coffee break while compiling |
|
|
Re: Porting issue with Array() constructor vs. typecasterValid point. I my case this didn't matter but if it would have, I probably would have done the following:
a : Array = ( new Array() ).concat( myObjectReferenceThatCouldbeAnArray ); // other stuff myObjectReferenceThatCouldbeAnArray = a; - Luke On 20/09/2007, at 1:38 AM, Chris Miles wrote:
-- MTASC : no more coffee break while compiling |
| Free embeddable forum powered by Nabble | Forum Help |