ActionScript 3.0 add border to movie clipe - actionscript-3

I had created the script below but the cordinate is not working right. please see my scripts and let me know what is wrong with my scripts.
thanks
/*mcc is the Instance name*/
var myMovieClip:Sprite = new Sprite();
trace("x" + mcc.x + "y" + mcc.y + "width" + mcc.width);
myMovieClip.graphics.lineStyle( 1, 0xFF0000 );
myMovieClip.graphics.drawRect( 0, 0, mcc.width+1, mcc.height+1 );
myMovieClip.graphics.endFill();
myMovieClip.x = -(mcc.x/2);
myMovieClip.y = -(mcc.y/2);
mcc.addChild(myMovieClip);

would need to know more about mcc looks like we're assuming that mcc has the content centered instead of the top right corner of mcc being at [0,0]
Try using the getBounds method instead.
something like this... though I haven't tested it
var bounds:Rectangle = mcc.getBounds(this)
myMovieClip.graphics.drawRect(
bounds.left-border/2, bounds.top-border/2,
bounds.width+border, bounds.height+border
);
myMovieClip.x = (mcc.x);
myMovieClip.y = (mcc.y);
mcc.addChild(myMovieClip);

thank you, it is working now, i used the getBounds and set the myMovieClip.x = (0); . It doesn't make sense but it works good now.
Anyway, the mcc could be anything, event rotate angle too.
var border=1;
var myMovieClip:Sprite = new Sprite();
myMovieClip.graphics.lineStyle( border, 0xFF0000 );
trace("getbound on mcc" + mcc.getBounds(mcc));
trace("parser" + mcc.getBounds(mcc).y)
trace("getbound on this" + mcc.getBounds(this));
trace("Other x " + mcc.x + " y " + mcc.y + " width " + mcc.width+ " height " + mcc.height);
var bounds =mcc.getBounds(mcc)
myMovieClip.graphics.drawRect(bounds.left-border/2, bounds.top/2,bounds.width+border, bounds.height+border);
myMovieClip.graphics.endFill();
myMovieClip.x = (0);
myMovieClip.y = (bounds.y)/2;
mcc.addChild(myMovieClip);
trace("New bound" + mcc.getBounds(mcc));

Related

How to replace RichTextEditor text without loosing the formatting in Flex

In my ActionScript code, I'm using a richTextEditor to do the following.
protected function createEmailTemplateContent(subRecord:String = null):void{
var index:int = emailTemplateContent.selection.beginIndex;
if(subRecord != null){
emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem.toString().substring(0,insertFieldDD.selectedItem.toString().indexOf('(+)')-1) + '].[' + subRecord + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}else{
emailTemplateContent.text = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}
}
The above method implements when the user selects an item from a drop down list. Then that particular item will be populated inside the text area of the rich text editor.
My issue is that if the user has already done some formatting (using the formatting options in RichTextEditor) on the text, that also get replaced when the user selects an item and populates the text area.
In this, 'emailTemplateContent' means the RichTextEditor. I have included my RichTextEditor code in the following.
<component:RichTextEditorWithAllControls id="emailTemplateContent" dropShadowVisible="false" creationComplete="emailTemplatesContentInit()" headerHeight="0" width="100%" height="100%" htmlText="#{emailTemplateObject.emailContent}" showControlBar="false" verticalScrollPolicy="auto"/>
I assume this happens because when I populate the 'text' value in the richTextEditor, the 'htmlText' value is also get replaced.
Does anyone know a way to overcome this issue.
Thanks in advance.
First store the concatenated text in a String and then replace it in the html text. Something like below
protected function createEmailTemplateContent(subRecord:String = null):void{
var index:int = emailTemplateContent.selection.beginIndex;
var newText:String;
if(subRecord != null){
newText = emailTemplateContent.text.substring(0,index)
+ '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem.toString().substring(0,insertFieldDD.selectedItem.toString().indexOf('(+)')-1) + '].[' + subRecord + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}else{
newText = emailTemplateContent.text.substring(0,index) + '{[' + fieldTypeDD.selectedItem + '].[' + insertFieldDD.selectedItem + ']}' + emailTemplateContent.text.substring(index,emailTemplateContent.text.length);
}
emailTemplateContent.htmlText = emailTemplateContent.htmlText.replace(emailTemplateContent.text, newText);
}

How to increase width of label?

I am adding a div dynamically.It contains random amount of data that sometimes spreads over more than one lines. Problem is that it becomes conj-gusted in that case.
Sample
in other words, i want to increase the line spacing of that label.
Here is code i am adding label
var m=0;
var ttp = document.getElementById("T_" + (m + 1));
var LH = document.createElement('label');
LH.id = "H_" + element_name + "_" + (m + 1);
var pp = document.createElement('p');
pp.innerHTML = "<br>" + element_name;
LH.appendChild(pp);
ttp.appendChild(LH);
You can able to add styles for a particular element at the time of creating. you can assign your styles here: obj.style.cssText
var LH = document.createElement('label');
//Code for set line height
LH.style.lineHeight = "15px";
LH.id = "H_" + element_name + "_" + (m + 1);
Through Javascript u can change the css by this
document.getElementById("lableId").style.line-height="20%";
or u can set css via
$('#LabelID').css('attribute','value');

Can TeeChart draw value label at cursor point?

I'm looking for HTML5 chart that can show value at cursor point like this
http://www.tradeviewforex.com/forex-blog/tip-14-how-to-use-the-crosshair-on-metatrader-4
I found StockChartX can do this
http://developer.modulusfe.com/stockchartx_html5/
(click Draw -> Annotation)
but I can effort this price :P
Thanks for answer!
Ps. Sorry for my bad english.
Something similar can be done with the Annotation tool in TeeChart HTML5. See the example here
Also, you can format a tool tip, if that is the need.
tip = new Tee.ToolTip(Chart1);
Chart1.tools.add(tip);
tip.format.font.style = "11px Verdana";
tip.render = "canvas";
tip.onshow = function (tool, series, index) {
scaling = 2;
poindex = index;
}
tip.onhide = function () {
scaling = 0;
poindex = -1;
}
tip.ongettext = function (tool, text) {
var txt = tool.currentSeries.title + ":\n" + "Value: " + text + tool.currentSeries.units + "\n" + jsonDataArray[0].evDataTime[tool.currentIndex] + " (ms)";
model.MouseOverY(text + tool.currentSeries.units);
model.MouseOverX(jsonDataArray[0].evDataTime[tool.currentIndex] + " (ms)");
model.SelectedSeries(tool.currentSeries.title);
return txt;
}

Mootools: how to show tips manually

I would like to show a tooltip by calling it from code. Something like:
tips.fireEvent('show', el);
or
label.fireEvent('mouseover');
The tips are already set and stored on domready and work perfectly on mouseover. MooTools 1.4.5.
What worked was creating a new tip:
var tip_title = el.retrieve('tip:title');
var tip_text = el.retrieve('tip:text');
var tips = new Tips(el, {fixed: true, offset: {x: 0, y: size.y}});
var tip = tips.toElement();
tip.getFirst('div.tip').set('html', '<b>' + tip_title + '</b><br />' + tip_text);
var pos = el.getPosition();
var size = el.getSize();
tip.setStyles({left: pos.x, top: pos.y + size.y});
tips.show(el);
Then, just added a little extra code to detach the additional tip on mouseover.

getRange(),setFormulas doesn't want to work

I have the following code and when I run it I get the right number of items in sheetFormulas (4), and the array values look correctly formed.
However, I get an error right after the sheetFormulas Browser.msgBox pops up, indicating the getRange().setFormulas line has an issue, but I can't see what it is.
function test(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var testingTarget = ss.getSheetByName("Testing");
var sheetFormulas = new Array();
for (l=0;l<10;l++) {
sheetRowCount = l + 2;
var monthlyTotalCompanyCosts = '=F' + sheetRowCount + '/$F$29*$I$14';
var monthlyTotalCompanyCostsPerEa = '=IFERROR(H' + sheetRowCount + '/C' + sheetRowCount + ')';
var monthlyMargin = '=D' + sheetRowCount + '-F' + sheetRowCount;
var monthlyMarginPctg = '=IFERROR(J' + sheetRowCount + '/D' + sheetRowCount + ')';
sheetFormulas.push(monthlyTotalCompanyCosts,monthlyTotalCompanyCostsPerEa,monthlyMargin,monthlyMarginPctg);
Browser.msgBox("sheetFormulas.length is: " + sheetFormulas.length);
Browser.msgBox("sheetFormulas is: " + sheetFormulas);
testingTarget.getRange(sheetRowCount,8,1,4).setFormulas(sheetFormulas);
sheetFormulas = [];
}
}
Any help is appreciated,
Phil
First, sheetFormulas has to be a 2D array. So try doing
/* Notice the [] around sheetFormulas */
testingTarget.getRange(sheetRowCount,8,1,4).setFormulas([sheetFormulas]);
If you still see other problems, then put your code inside a try{}catch{} block and print out the exception in the catch block.
I also suggest that you print out the formula using Logger.log() before setting it on the spreadsheet.