# Text inside a rectangle

**URL:** https://forum.kirupa.com/t/text-inside-a-rectangle/310211
**Category:** Uncategorized
**Created:** [June 4, 2010, 11:02am UTC](https://forum.kirupa.com/t/text-inside-a-rectangle/310211 "2010-06-04T11:02:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![itskarthi05](https://avatars.discourse-cdn.com/v4/letter/i/76d3ee/32.png) [@itskarthi05](https://forum.kirupa.com/u/itskarthi05)
#### Post date: [June 4, 2010, 11:02am UTC](https://forum.kirupa.com/t/text-inside-a-rectangle/310211/1 "2010-06-04T11:02:50Z")

</div>

hi,

I need to access the text inside the moieclip… i am creating a emptymovieclip(name : \_root.holder.contentMC)  
in this i am loading a swf file… now i am creating another movieclip as \_root.holder.contentMC.drawRect1… the drawrect1 movieclip is used for drawing a rectangle in that swf file… (for ex: in PDF file we will draw a rectangle to select the text)

problem:

now i need to get the text availabgle inside the drwarect1 movieclip… i dont know how to do this … if any help much appreciated

code:  
\_root.createEmptyMovieClip(“holder”,\_root.getNextH ighestDepth());  
\_root.holder.createEmptyMovieClip(“contentMC”,\_roo t.holder.getNextHighestDepth());  
\_root.holder.contentMC.loadMovie(“67.swf”);

var startX = 0;  
var startY = 0;

var listener:Object = new Object(\_root.holder);

Mouse.addListener(listener);  
remove\_mouse\_listener();  
listener.onMouseDown = function() {

```
startX = _xmouse;
startY = _ymouse;

_root.holder.contentMC.createEmptyMovieClip("drawR ect1",_root.getNextHighestDepth());
//trace(_root.holder.drawRect1.contentMC.charCount() );

```

};

function remove\_mouse\_listener() {

```
Mouse.removeListener(listener);

```

}

listener.onMouseUp = function() {

```
_root.holder.contentMC.drawRect1.beginFill(0x00000 0,5);
_root.holder.contentMC.drawRect1.lineStyle(1,0xCCC CCC);
_root.holder.contentMC.drawRect1.moveTo(startX,sta rtY);
_root.holder.contentMC.drawRect1.lineTo(_xmouse,st artY);
_root.holder.contentMC.drawRect1.lineTo(_xmouse,_y mouse);
_root.holder.contentMC.drawRect1.lineTo(startX,_ym ouse);
_root.holder.contentMC.drawRect1.endFill();
_root.holder.contentMC.drawRect1._alpha = 90;
var my_snap:TextSnapshot;
var startCount:Number=0;
mc.onPress = findText1;
findText1();
	
	
};

	function findText1()
	{
	resetSelection();
	var totalLength:Number = my_snap.getCount();
	var theText:String = my_snap.getText(0, totalLength, false);
	
	//theText.split(",");
	trace("the theText is" + theText);
	}
	
	function resetSelection()
	{
	
	my_snap= _root.holder.contentMC.drawRect1.getTextSnapshot() ;
	trace(my_snap);
	startCount=0;
	}

```

thanks in advance

karthikeyan.R
