I m 探讨如何执行Misy/Trait, AS3。
我想能够把一些班级合并成一个单一目标。 当然,这并不是AS3的一种语言特征,但我希望,利用原型技术或可能采用某种加密法来实施这一功能可能有些方法。
现有的 Java实例是Qi4J,用户界定了Q4j框架根据元件和公约编码实施的接口。
是否有任何想法说明如何在SAP3内实现混合/特拉伊特概念?
I m 探讨如何执行Misy/Trait, AS3。
我想能够把一些班级合并成一个单一目标。 当然,这并不是AS3的一种语言特征,但我希望,利用原型技术或可能采用某种加密法来实施这一功能可能有些方法。
现有的 Java实例是Qi4J,用户界定了Q4j框架根据元件和公约编码实施的接口。
是否有任何想法说明如何在SAP3内实现混合/特拉伊特概念?
因此,我研究了几种方法。 。 ECMA script Format cuins,方法是将其他物体的界定方法添加到原型上。 但这意味着静态打字的优势已经消失。
我正在寻求一种解决办法,以抵消静态型系统。 我知道,ASMock 用于采用星码注射制造代理班。 我过去几天在ASMock周围 ha,并提出了一个可能的解决办法,即建立一个由班级组成的班级(通过代典注入)。
从用户的角度来看,这涉及界定您通过许多接口使用混合物的物体:
public interface Person extends RoomObject, Moveable
public interface RoomObject
{
function joinRoom(room:Room):void
function get room():Room
}
public interface Moveable
{
function moveTo(location:Point):void
function get location():Point
}
然后,你确定代表这些接口的班级:
public class MoveableImpl implements Moveable
{
private var _location:Point = new Point()
public function get location():Point { return _location }
public function move(location:Point):void
{
_location = location.clone()
}
}
public class RoomObjectImpl implements RoomObject
{
private var _room:Room
public function get room():Room { return _room }
public function joinRoom(room:Room):void
{
_room = room
}
}
在正常情况下,你想组成课堂,你将写:
public class PersonImpl implements Person
{
private var _roomObject:RoomObject = new RoomObjectImpl()
private var _moveable:Moveable = new MoveableImpl()
public function get room():Room { return _roomObject.room }
public function joinRoom(room:Room):void { _roomObject.joinRoom(room) }
public function get location():Point { return _moveable.location }
public function move(location:Point):void { _moveable.move(location) }
}
由于其常规布局,因此很容易用代码书写。 这正是我的解决办法,将equi形的 by形形形形形形色色色的外表注入新的类别。 有了这一代典注入系统,我们就能够形成这样的个人目标:
public class Main
{
private var mixinRepo:MixinRepository = new MixinRepository()
public function Main()
{
with(mixinRepo)
{
defineMixin(RoomObject, RoomObjectImpl) // associate interfaces with concreate classes
defineMixin(Moveable, MoveableImpl)
defineBase(Person)
prepare().completed.add(testMixins) // the injection is a async process, just liek in ASMock
}
}
private function testMixins():void
{
var person:Person = mixinRepo.create(Person)
var room:Room = new Room( room you can play in )
person.joinRoom(room)
trace( person.room: , person.room)
person.move(new Point(1, 2))
trace( person.location: , person.location)
}
}
目前,这一系统是概念的证明,因此非常基本和困难。 但这表明有可能接近SAP3的Schala混合体/海峡风格系统。 I ve made a github , 如果任何人有兴趣管理解决办法,并围绕解决办法进行ok弄,则持有该守则。
项目http://github.com/brianheylin/as3-retrofit/wiki/Misys-Auto-Proxy” rel=“noreferer”>。
I want to link some images into a swc library in pure actionscript 3 - is this possible?
I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...
So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...
I m a complete newbie to this, I ve been watching tons of tutorials, reading tutorials, reading the Adobe site, etc... The last time I programmed was BASIC on Apple IIe... I m trying to create a ...
I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...
When I make a new Flex application in Flex 4 beta 2 (Flash Builder), then it creates a border around the outside of the Panel in this example of a thick width. It places a border with a shadow on the ...
I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...
I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...