Petrinetwork es una biblioteca en ActionScript 3, que simula el funcionamiento de la red de Petri. Diseñado para crear animación de flash interactiva en el entorno de entrenamiento Hypertest
La red de Petri es un multi -bottomed multifot de doble botón, que consiste en la parte superior de dos tipos: posiciones y transiciones interconectadas por los ARC. Los picos del mismo tipo no se pueden conectar directamente. En las posiciones, los marcadores (marcadores) pueden moverse sobre la red se pueden colocar en posiciones.
El evento es el funcionamiento de la transición en la que las marcas de las posiciones de entrada de esta transición se mueven al fin de semana. Los eventos ocurren instantáneamente o de manera diferente, cuando se cumplen las condiciones.
import PetriNetManager . State ;
import PetriNetManager . StateTransition ;
import PetriNetManager . ActionResult ;
import PetriNetManager . SceneManager ;
import PetriNetManager . StatesUpdateEventHandler ;
import flash . display . DisplayObject ; var sceneMgr = new SceneManager ( ) ; var sett : Object = {
//Номера позиций
states : [ 1 , 2 , 3 , 4 , 5 ] ,
//Количество маркеров в каждой позиции
markers : [ 1 , 0 , 0 , 0 , 0 ] ,
//Массив объектов переходов
transitions : [ {
//номер перехода
id : 1 ,
//Входные позиции
inputStates : [ 1 ] ,
//Выходные позиции
outputStates : [ 2 ]
} ,
{
id : 2 ,
inputStates : [ 2 ] ,
outputStates : [ 3 ]
} ,
{
id : 3 ,
inputStates : [ 1 ] ,
outputStates : [ 5 ]
}
]
} ; sceneMgr . initFromObject ( sett ) ; helpBtn . addEventListener ( MouseEvent . CLICK , helpBtnInvoke ) ;
function helpBtnInvoke ( e : MouseEvent ) : void {
sceneMgr . makeAction ( 1 ) ;
} function statesChangedHandler ( e : StatesUpdateEventHandler ) {
for each ( var s : State in e . States ) {
trace ( s . Id + " " + s . hasMarkers ( ) ) ;
}
trace ( "-----------------------------" ) ;
//Если срабатывает первый переход
if ( e . States [ 0 ] . hasMarkers ( ) ) {
//переходим на другой фон
bg1 . gotoAndStop ( 1 ) ;
//меняем текст в навигационном окне
curStr = "Зайдите в меню HELP или нажмите CTRL+SHIFT+D" ;
}
if ( e . States [ 1 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 2 ) ;
curStr = "Выберите пункт Default Keymap Reference" ;
}
if ( e . States [ 2 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 3 ) ;
curStr = "Список со всеми горячими клавишами" ;
}
if ( e . States [ 4 ] . hasMarkers ( ) ) {
bg1 . gotoAndStop ( 4 ) ;
curStr = "Форма поиска команды" ;
}
}
sceneMgr . addEventListener ( StatesUpdateEventHandler . STATES_UPDATE_EVENT , statesChangedHandler ) ; sceneMgr . initFromJson ( net1 . json ) ;