all groups > flash actionscript > october 2005 >
You're in the

flash actionscript

group:

AS 1.0 and instanceof and #initclip


AS 1.0 and instanceof and #initclip Fruber Malcome
10/13/2005 10:37:30 PM
flash actionscript: Instead of having to write my own, is there anyone out there that has an
"instanceof" function that works for AS1.0?
I'm aware of typeof() - but that doesn't work the same as instaceof.

I'm also trying to work around some of my #initclip pragmas. What exactly
does #initclip do that requires it's use? Is this one of those pragmas that is
overused - or typically required. If so - is there an AS1.0 equivelant.

What would one do in AS1 when the functionality of #initclip and/or instaceof
was necessary?

Any help would be appreciated..
thanks - Fruber
Re: AS 1.0 and instanceof and #initclip NSurveyor
10/13/2005 11:00:03 PM
Isn't instanceof available in AS1.0? And I'm quite sure #initclip is available
in AS1.0 (don't really know what it does tho)

If it isn't, try this:

Object.prototype.isInstanceOf = function(ofclass){
return (this.__proto__ == ofclass.prototype);
}
//
x = new String('hi');
trace(x.isInstanceOf(String));
Re: AS 1.0 and instanceof and #initclip Fruber Malcome
10/14/2005 1:34:11 AM
hmm.. Maybe I confused a few people by saying specifically AS1.0 and not
FlashPlayer 5.
When I compile my code using FlashPlayer 6 AS1.0 - I get no problems, but if I
compile the code for FlashPlayer 5 (which is really what I need) - I get errors
on the lines that use both initclip and instanceof.

so it's not an issue between AS1.0 and AS2.0 - but Player 5 and Player 6.

Sorry about the confusion - I'll play with the instanceof.

If compiled for Player 6 - I assume the files won't run properly in 5.0 -
since those commands aren't supported?

thanks - Fruber.

Re: AS 1.0 and instanceof and #initclip Fruber Malcome
10/14/2005 1:38:46 AM
Looks interesting..

I assume that if I didn't want this applied to all objects (which I belive
your version does) - I can use this for my custom objects.
(e.g. MyObject.prototype.isInstanceOf = function( objClass ){ return
this.__proto__ == objClass.prototype; }; )

Also - I notice you used this.__proto__ - should that really be
this.prototype.__proto__ ? If not - then maybe I was confused about something.

I use MyObject.prototype.__proto__ for class inheirtance, is that different
from the MyObject.__proto__ ?

thanks - Fruber.

Re: AS 1.0 and instanceof and #initclip Fruber Malcome
10/14/2005 4:09:50 AM
ahh - thanks..

In my particular case, I meant to use MyObject to represent a class that was written:

MyObject = function(){...}

got it.. now it makes sense..
thanks - Fruber.
Re: AS 1.0 and instanceof and #initclip Jeckyl
10/14/2005 9:06:30 AM
#initclip is for AS1 .. you don't really need it as much for AS2 afaik
--
Jeckyl

Re: AS 1.0 and instanceof and #initclip Jeckyl
10/14/2005 11:42:00 AM
[quoted text, click to view]

No .. this.__proto__ is exactly what it must be this.prototype.__proto__ is
copletely different and won't give you the corect result.

[quoted text, click to view]

If you are, then you're doing it wrong. instances objects do not generally
even have a .prototype property .. only Functions (ie classes) have a
prototype.
--
Jeckyl

AddThis Social Bookmark Button