Flex DateChooser in chinease and japanease Style - actionscript-3

How I can change the display of Month and Year display to Japanese style (i.e. Year Month) as in Header of Flex DateField. What I would like to convert the style July 2011年 to 2011年 7月.[![enter image description here][1]][2]
How can we change the calender header format ?
i have used DateField in flex.

Try to set
-locale=ja_JP
If you're using Flash Builder, write it below.
Project > Properties > Flex Compiler > Additional Compiler Arguments
If you want to change Japanese Style dynamically, set the locale both English and Japanese.
-locale=en_US,ja_JP
and can change dymamically like this.
private var resource: IResourceManager = ResourceManager.getInstance();
private function changeLocale(): void{
if (user selected JP){
resource.localeChain = ["ja_JP"];
}else{
resource.localeChain = ["en_US"];
}
resource.update();
}

Related

How can I put range, min, max and value in the CSS file

I have a large number of sliders all declared similar to this example.
input class = 'slider' id = 'Slider4' type = 'range' min = '0' max = '100' value = '0' onchange = 'Update(4)'
The 'slider' class contains things like width, height, opacity, etc, but it would simplify my code even more if the "type = 'range' min = '0' max = '100' value = '0'" part could also be put in the 'slider' class.
But my editor (Brackers) rejects this as invalid HTML. Is there a way to do this ?
No. There is no way to express the non-presentational features of the element using CSS.
Repeated chunks of HTML could be inserted using a template powered by whatever server-side programming language you are using (or even a client-side one).
Unless you are using some javascript code to detect and add a class to your desired element based on your min and max value, you can only target the input type by css, like so:
input[type=range] {
background: #FFFFFF;
}

How to put a / in vaadin-date-picker

I am using a vaadin-date-picker with polymer. I would like to put the right slash by default when the user types in a date in US format. So if the user types 01152019, it should auto format the date to 01/15/2019. Right now if I enter date without the / , it wont take recognize the value.
You should set the parseDate method of the i18n property of your date picker so that it does what you want, for example, if you only wanted to accept date strings in US format but without slashes or hyphens you could do something like this:
const datePicker = something; // you probably did something like this.querySelector() to get it
datePicker.i18n = {
// you can also set methods to format the date or the title and a few other things
parseDate: dateString => {
let month = parseInt(dateString.subString(0,2));
let day = parseInt(dateString.subString(2,4));
let year = parseInt(dateString.subString(4,8));
return {day, month, year};
}
};

Customize html output for a field's droplist options

I have a field called icon, which is a droplist sourced from folder in the content tree. I would like the list to not just show the text value(shown in the screen shot) but also to utilize an icon font and display what the actual icon would look like. Basically customizing the content editor's droplist for this field from:
<option value="gears">gears</option>
to
<option value="gears">gears <span class="my-icon-font-gears"></span></option>
Is there any documentation on how to modify the outputted html for a droplist, and to modify the content editor page to load another link, in this case a font-file.
I created a module on the marketplace that does something similar. You can have a look here. There is some documentation on there explaining how to use it.
The code is also on Git if you want to have a look.
Suggest you use the Droplink field type instead of the Droplist, since the value is stored by GUID and this will lead to less longer term problems if the link item is renamed or moved. In any case you need a custom field, inherit from Sitecore.Shell.Applications.ContentEditor.LookupEx (which is the DropLink field type) and override the DoRender() method with the custom markup you require.
It's not possible to embed a span tag since the option tag cannot contain other tags as it is invalid HTML. Adding it will cause the browser to strip it out. You can however set the class on the option itself and style that.
`<option value="gears" style="my-icon-font-gears">gears</option>`
Here is some sample code to achieve the field.
using System;
using System.Web.UI;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
namespace MyProject.CMS.Custom.Controls
{
public class StyledLookupEx : Sitecore.Shell.Applications.ContentEditor.LookupEx
{
private string _styleClassField;
private string StyleClassField
{
get
{
if (String.IsNullOrEmpty(_styleClassField))
_styleClassField = StringUtil.ExtractParameter("StyleClassField", this.Source).Trim();
return _styleClassField;
}
}
// This method is copied pasted from the base class apart from thhe single lined marked below
protected override void DoRender(HtmlTextWriter output)
{
Assert.ArgumentNotNull(output, "output");
Item[] items = this.GetItems(Sitecore.Context.ContentDatabase.GetItem(this.ItemID, Language.Parse(this.ItemLanguage)));
output.Write("<select" + this.GetControlAttributes() + ">");
output.Write("<option value=\"\"></option>");
bool flag1 = false;
foreach (Item obj in items)
{
string itemHeader = this.GetItemHeader(obj);
bool flag2 = this.IsSelected(obj);
if (flag2)
flag1 = true;
/* Option markup modified with class added */
output.Write("<option value=\"" + this.GetItemValue(obj) + "\"" + (flag2 ? " selected=\"selected\"" : string.Empty) + " class=\"" + obj[StyleClassField] + "\" >" + itemHeader + "</option>");
}
bool flag3 = !string.IsNullOrEmpty(this.Value) && !flag1;
if (flag3)
{
output.Write("<optgroup label=\"" + Translate.Text("Value not in the selection list.") + "\">");
output.Write("<option value=\"" + this.Value + "\" selected=\"selected\">" + this.Value + "</option>");
output.Write("</optgroup>");
}
output.Write("</select>");
if (!flag3)
return;
output.Write("<div style=\"color:#999999;padding:2px 0px 0px 0px\">{0}</div>", Translate.Text("The field contains a value that is not in the selection list."));
}
}
}
This field adds a custom properties to allow you to specify the linked field to use for the style class. The assumption is that you have another single line text field on the linked item to specify the CSS class.
Usage: Set the source property of the field in the following format:
Datasource={path-or-guid-to-options}&StyleClassField={fieldname}
e.g. Datasource=/sitecore/content/lookup/iconfonts&StyleClassField=IconClassName
To use this new field compile the above code in to project, switch over to the core database and then create a new field type – you can duplicate the existing Droplink field located in /sitecore/system/Field types/Link Types/Droplink. Delete the existing Control field and instead set the ASSEMBLY and CLASS fields to point to your implementation.
You also need to load a custom CSS stylesheet with the style defintions into the Content Editor, which you can achieve that by following this blog post.

Combining a variable with a number

I'm trying to make a inventory using an array in a game I'm making.
What I need is a way to combine a number with a variable, something like this:
itemBoxNumber = "itemBox" + currentItemBox;
//In this case itemBoxNumber would say itemBox1
that I could use to replace the itemBox1.
function itemsMenuUpdate():void
{
for (var a:int = 0; a<maxInventory; a++){
var currentItemBox:Number = 1;
if(~inventory.indexOf("Potion")){
mainMenu.itemBox1.gotoAndStop("Potion");
}
if(~inventory.indexOf("Hi-Potion")){
mainMenu.itemBox1.gotoAndStop("Hi-Potion");
}
}
}
I can only find working methods for AS2. Any help is appreciated with this.
If I remember right, you can call a method from a String in AS3.
For example, if you want to call the method itemBox1 on mainMenu you can do:
mainMenu["itemBox1"]
Which is the same as:
mainMenu.itemBox1
So in your example you could do this:
mainMenu[itemBoxNumber].gotoAndStop("Potion");
You can retrieve the child display object via a name (which you need to set prior). So:
var itemBoxNumber = "itemBox" + currentItemBox;
mainMenu.getChildByName(itemBoxNumber).gotoAndStop("Potion"); //TODO ensure the child was given such a name
Make a LabelNumber Class, which has both a String label and a Number. You can then add a method that returns a String of the label and the number combined, while keeping the values independent of one another.

How to remove a particular text in TextInput in Flash?

Design a Text Input by using components in flash and its InstanceName is listChat. In that text input I added a text by Dynamically. While I am adding text it displays with null.
For Example I added "apple" it Displays like nullapple
How to remove that null?
You can use the String's replace method.
If you want to remove only the first encounter of 'null' you can use this:
listChat.text = listChat.text.replace("null", "");
If you want to remove all encounters of 'null' this will do it:
var stripNullPattern:RegExp = /null/gi;
listChat.text = listChat.text.replace(stripNullPattern, "");
If you only want to remove null if it's in the first four characters use something like this:
if(listChat.text.substring(0, 4) == "null")
{
listChat.text = listChat.text.replace("null", "");
}
Check the AS3 reference for more info:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/String.html#replace()