Forum | Examine Region Editor

You must be logged in to post Login Register

Search Forums:


 






Examine Region Editor

No Tags
UserPost

8:27 pm
August 4, 2011


firefly431

Member

posts 13

I guess this is where I put it…

This is an editor for examine regions. It's written in AS3.


import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.events.Event;

var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderReady);

var pbar:MovieClip;

var crect:MovieClip;
var cursor:MovieClip;

btn.addEventListener(MouseEvent.MOUSE_DOWN, loadMap)

function loadMap(e:*=null) {
	pbar = new MovieClip();
	addChild(pbar);
	pbar.graphics.beginFill(0x0099FF);
	pbar.graphics.drawRect(10,191-10,236,1);
	pbar.graphics.endFill();
	pbar.scaleX=0;
	//trace(String(bob.text).substr(0,bob.text.length-1)+"");
	var url:String=String(bob.text).substr(0,bob.text.length-1);
	if (url.indexOf(".") == -1) {
		url+=".png"
	}
	trace(url);
	var fileRequest:URLRequest = new URLRequest(url);
	myLoader.load(fileRequest);
}

function onProgressStatus(e:ProgressEvent) {
      // this is where progress will be monitored
      //trace(e.bytesLoaded, e.bytesTotal);
	  pbar.scaleX=e.bytesLoaded/e.bytesTotal;
}

function onLoaderReady(e:Event) {
      // the image is now loaded, so let's add it to the display tree!
	  removeChild(pbar);
	  removeChild(btn);
	  removeChild(bob);
      addChild(myLoader);
	  crect=new MovieClip();
	  cursor=new MovieClip();
	  flash.ui.Mouse.hide();
	  addChild(cursor);
	  addChild(crect);
	  cursor.mouseChildren=false;
	  cursor.mouseEnabled=false;
	  crect.mouseChildren=false;
	  crect.mouseEnabled=false;
	  myLoader.addEventListener(MouseEvent.MOUSE_MOVE,update);
	  myLoader.addEventListener(MouseEvent.MOUSE_DOWN,m_down);
	  myLoader.addEventListener(MouseEvent.MOUSE_UP,m_up);
	  myLoader.addEventListener(Event.ENTER_FRAME,eframe);
}

var sx:int=-1;
var sy:int=-1;

function update(e:MouseEvent) {
	cursor.graphics.clear();
	cursor.graphics.beginFill(0x0099FF);
	cursor.graphics.drawRect(myLoader.mouseX,0,1,192);
	cursor.graphics.drawRect(0,myLoader.mouseY,256,1);
	cursor.graphics.endFill();
	if (sx != -1) {
		crect.graphics.clear();
		crect.graphics.beginFill(0xFFFFFF,0.5);
		crect.graphics.drawRect(sx,sy,myLoader.mouseX-sx,myLoader.mouseY-sy);
		crect.graphics.endFill();
	}
}

function m_down(e:MouseEvent) {
	sx=myLoader.mouseX;
	sy=myLoader.mouseY;
}

function m_up(e:MouseEvent) {
	if (sx != -1) {
		var xx:int=Math.min(sx,myLoader.mouseX);
		var yy:int=Math.min(sy,myLoader.mouseY);
		var x2:int=Math.max(sx,myLoader.mouseX);
		var y2:int=Math.max(sy,myLoader.mouseY);
		trace("region "+xx.toString()+" "+yy.toString()+" "+(x2-xx).toString()+" "+(y2-yy).toString()+" LABEL");
	}
	sx=sy=-1;
	crect.graphics.clear();
}
var time:int=0;
function eframe(e:Event) {
	time=(time+2)%100;
	crect.alpha=Math.sin(time*(Math.PI/50))/3+0.666;
}

You need two things in your stage:
A textbox called "bob" (don't know why I named it that)
and a button named "btn" (stands for button).
Just input the name of your map in the "bob" textbox and click the "btn".

10:10 pm
August 4, 2011


saluk

Admin

posts 144

This sounds interesting, although I'm not sure how to use it. Do you have an executable version?

8:17 am
August 5, 2011


firefly431

Member

posts 13

Post edited 8:18 am – August 5, 2011 by firefly431


http://www.mediafire.com/?qqgm…..9ezbsi168z

It's both win and mac. Anything that runs on your OS will work (I've included the updated source)

11:38 am
August 6, 2011


firefly431

Member

posts 13

Here's an updated link. It has support for managing multiple regions and renaming them. It also can generate labels for them.

http://www.mediafire.com/file/…..v2.tar.bz2

11:39 am
August 6, 2011


firefly431

Member

posts 13

IF you're wondering, it's for PyWright. I don't know how to edit posts.

12:44 pm
August 6, 2011


firefly431

Member

posts 13

How to use: Go to pywright wiki, and go to tutorials, INTERMEDIATE TUTORIALS (My category), and then Investigation Tutorial. It tells you how to use it. Smile

No Tags