LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 


  #1  
Old 09-08-2004, 02:32 PM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
Prim

Ok as you may know Ted Patrick has released PRIM a couple of minutes ago for free under the BSD licence.

Just a couple of questions now looking at the code:

1. How has he managed to overload an operator e.g.

Actionscript:
createPrim ( Prim.STRICT | Prim.STRING , 'testVal' , 'Hello World' );
testVal = "Hello"; //works
testVal = 29; // fails

2. How has he apparently overloaded a function e.g.

Actionscript:
// In one file:
Object.prototype.createPrim = function(t,n,v,h,o,d){...}

//In another
Object.prototype.createPrim[0x2000100] = function(){...}

Woah?

Rich
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote
  #2  
Old 09-08-2004, 02:52 PM
swoop's Avatar
swoop swoop is offline

swoopy HyperModerator
 
Join Date: Jun 2001
Location: England
Posts: 1,562
Rep Power: 13
swoop is on a distinguished road
For those of us who aren't quite as uptodate as I should be , do you have a link to an article, or similar, with some background to all this?

swoop
Reply With Quote
  #3  
Old 09-08-2004, 02:59 PM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
oops sorry I forgot to link!

http://www.powersdk.com/prim/
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote
  #4  
Old 09-09-2004, 06:56 AM
puppy's Avatar
puppy puppy is offline
Guide
 
Join Date: Dec 2002
Posts: 2,875
Rep Power: 13
puppy is on a distinguished road
it keep saying that I need player... so dumb. use this link instead: http://powersdk.com/prim/prim002.swf?id=63&
__________________
Reply With Quote
  #5  
Old 09-10-2004, 02:33 PM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
Interesting, what browser/flash player are you using puppy?

Rich
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote
  #6  
Old 09-11-2004, 09:29 AM
prisma prisma is offline

Super Moderator
 
Join Date: May 2001
Location: Munich, Germany
Posts: 1,668
Rep Power: 14
prisma is on a distinguished road
Woah! That code is amazing. Gotta work myself through this.

The Flash detection JS code of the page looks pretty cool (although is obviously seems to have problems with puppys browser).
Also, how does he so sucessfully kill the right-click menu?

Also wonder if using his classes speeds up code (using integers instead of numbers for example).
__________________
... take me to your coder.
Reply With Quote
  #7  
Old 09-11-2004, 12:21 PM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
@prisma I know it's all damn cool, that guy knows his stuff.

> Also wonder if using his classes speeds up code (using integers instead of numbers for example).

I seriously doubt it, in fact I'm certain, they will not perform as well as Flash primitives or even intrinsic data types as they actually create a getter and setter in the _global scope for each PRIM (that's how he achieves the prim = 5 hack). Still pure genius.

> The Flash detection JS code of the page looks pretty cool

Do you think he'll notice if I steal it Seriously though, clean and concise, yoinked!

Rich
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote
  #8  
Old 09-15-2004, 06:54 AM
Timothee's Avatar
Timothee Timothee is offline

AS Coderator
 
Join Date: Mar 2002
Location: Singapore
Posts: 664
Rep Power: 12
Timothee is on a distinguished road
Yeah, some really nice stuff in there. Super clean code, professional quality stuff. I am kinda behind the time in this thread but since there is no answers to the original questions, I'll post anyway (though I'm sure you have already figured it out Rich ):

Quote:
1. How has he managed to overload an operator e.g.
He's creating getter/setter dynamically.

Quote:
2. How has he apparently overloaded a function e.g.
It is not true overloading, he is using the original function's own namespace to store all the other versions and then use a bit mask technique to determine which one to call.

Here is small example with a version system (no bitmask):
Actionscript:
myFunc = function(version) {
  return arguments.callee[version]();
}
myFunc[0] = function() {
  return "tata";
}
myFunc[1] = function() {
  return "toto";
}
myFunc[2] = function() {
  return "titi";
}

trace(myFunc(0));
trace(myFunc(1));
trace(myFunc(2));
And after that you can any level of complexity in there. Instead of using fixed value, use flags and you have a stable, extensible system.

In Prim, the parent function will add new elements in the child function (notably a broadcaster) and that child function becomes the getter/setter for the new virtual property created by the parent function. Smart stuff !

Tim.
__________________
n=4102746880;s="";do{s=String.fromCharCode((n&15)+ 101)+s}while(n>>>=4);trace(s);
Reply With Quote
  #9  
Old 09-15-2004, 07:55 AM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
Timothee you didn't dissappoint I had figured out the getters/setters but I had never seen the use of functions in that way, and using bitmasks to boot.

Incredibly powerful,

Rich
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote
  #10  
Old 09-15-2004, 11:48 AM
puppy's Avatar
puppy puppy is offline
Guide
 
Join Date: Dec 2002
Posts: 2,875
Rep Power: 13
puppy is on a distinguished road
just another silly question.

isn't that ECMA standard of type-less language about not-having-strict-typing? after C++, and specially C, one wouldn't disagree that "type-less" is an advantage? or would anyone?..
__________________
Reply With Quote
  #11  
Old 09-19-2004, 02:35 AM
FrozenMedia's Avatar
FrozenMedia FrozenMedia is offline

Frozen Moderator
 
Join Date: Apr 2003
Location: United Kingdom
Posts: 2,701
Rep Power: 13
FrozenMedia is on a distinguished road
Not since a while ago now puppy,

Take a look at:
http://www.darronschall.com/weblog/archives/000012.cfm

That's an old post, in the AS1 era, but it hints at how AS2 turned out. Certainly does have strict typing now along with JavaScript2 and any other ECMA 4+ languages.

What's interesting is how you can do both at once, typed and typeless, allowing for MAXIMUM confusion but huge flexibility as shown in PRIM.

As to which is better typed or un-typed, I would undoubtedly argue TYPED for better coding, less errors, but heaven forbid they take away the ability to use un-typed in ActionScript without first adding alot more power to the language itself, or we might be in a right pickle.

Rich
__________________
Blog: http://www.richardleggett.co.uk | If your happy with the help, let us know about it
Reply With Quote


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump




All times are GMT. The time now is 01:08 PM.