package ConceptGraphMedium { import ConceptGraphMedium.Character; import flash.display.*; import flash.filters.* import flash.net.NetConnection; import flash.net.NetStream; import flash.media.Video; import flash.text.TextFieldAutoSize; import flash.text.TextField; import flash.events.Event; import flash.events.MouseEvent; import flash.geom.Transform; import flash.geom.Matrix; public class actionscript_graph_medium_CharacterHandler extends Sprite{ private var characterHandler:Array = new Array() //Array with the updated index of the elements in arrayCharacter private var allCharacters:Array = new Array; //Array with all the character objects contained in the XML File (charData) private var arrayCharacter:Array = new Array; //Array containing the character Object (arrayCharacter.object) and the quality of the relation (arrayCharacter.relation) private var arrayRelations:Array = new Array; //Contains relations among persons: fromID, toID, quality private var subRelation:Array = new Array; private var container:Sprite = new Sprite(); private var originX:uint = 400; //Set the X center (where the clicked character is set) private var originY:uint = 365; //Set the Y center (where the clicked character is set) private var affineTransform:Matrix; private var distanceBetweenTurns:uint = 70; private var radiusCircle:uint = 100; private var radius:uint = 50; private var numCharactersFirstTurn:uint = 15; //Minimum 3 private var increaseCharactersFactor:uint = 3; private var selectedLabel:TextField; private var descriptionLabel:TextField; private var ns:NetStream; public function actionscript_graph_medium_CharacterHandler (charData:Array, arrayRelations:Array, selectedLabel:TextField, descriptionLabel:TextField, ns:NetStream):void { this.arrayRelations = arrayRelations; this.selectedLabel=selectedLabel; this.descriptionLabel=descriptionLabel; this.ns = ns; for (var j:int=0; j(value + numCharactersFirstTurn - 3 + Math.pow(increaseCharactersFactor, currentTurn)) || (i-1)==(value + numCharactersFirstTurn - 3 + Math.pow(increaseCharactersFactor, currentTurn)); currentTurn++) { value += numCharactersFirstTurn - 3 + Math.pow(increaseCharactersFactor, currentTurn) } if ((i-1) < increaseSize) { //If we are over increaseSize we divide the angle among the constantDivisionNum constantDivisionNum = numCharactersFirstTurn - 3 + Math.pow(increaseCharactersFactor, currentTurn); angle += (360/(constantDivisionNum))*Math.PI/180; } else { //Otherwise, we divide it amongst the rest of the characters angle += 360/(arrayCharacter.length-increaseSize-1)*Math.PI/180; } arrayCharacter[i].setXWanted(originX + (((radiusCircle + (currentTurn * distanceBetweenTurns))*Math.cos(angle)))); //Final destination of the character arrayCharacter[i].setYWanted(originY + (((radiusCircle + (currentTurn * distanceBetweenTurns))*Math.sin(angle)))); //Final destination of the character } } public function click(characterClicked:Character): void { var tempArray:Array = new Array(); selectedLabel.htmlText = "You have selected: " + characterClicked.getName(); descriptionLabel.htmlText = "Description: " + characterClicked.getDescription(); trace ("esto"+characterClicked.getVideoURL()+"es"); if ((characterClicked.getVideoURL()==null) || (characterClicked.getVideoURL()== "")) { ns.pause(); } else { ns.play(characterClicked.getVideoURL()); } for (var i:int = 0; i All the characters when the mouse was clicked //tempArray => All the characters that are related to the clicked character checkExistence(tempArray); //Update arrayCharacter with tempArray characterGeometry(); //Set the characters (math and geometry) } public function overCharacter(ev:MouseEvent):void { ev.target.filters=[new BevelFilter( )]; //Bevel Filter when the mouse is over the character ev.target.increaseSize(60); //Increase the size ev.target.setIndexDisplay(container.getChildIndex(Character(ev.target))); container.addChildAt(Character(ev.target), container.numChildren); //Display the character in the front } public function outCharacter(ev:MouseEvent):void { ev.target.decreaseSize(); //Decrease size ev.target.filters=[]; //Eliminate Bevel Filter container.addChildAt(Character(ev.target), 1); //Place the character where it was situated } public function onPress(ev:MouseEvent):void { click(Character(ev.target)); } } }