On Apr 26, 2015 5:27 PM, "WelshAndy" <a...@eazyweb.net> wrote: > > Hi, > Is it possible to add custom labels to a ToggleSwitch in a mobile project > using AS3 rather than MXML? I need to add custom labels & add via AS3. Im > using Flex 4.14 & FB4.7. > Ive created the external package (using the usual MyToggleSwitch sample out > there) and that works just fine when calling via MXML, but for my project I > add the controls in AS3, & need to change the default labels to On & Off in > AS3. Is this possible? > Thanks
It should be possible, but in a bit of a tedious way. The ToggleSwitch component documents says this: The ToggleSwitch control uses the following default values for * the unselected and selected labels: OFF (unselected) and ON (selected). * Define a custom skin to change the labels, or to change other visual * characteristics of the control.</p> * * <p>The following skin class, defined as a subclass of * spark.skins.mobile.ToggleSwitchSkin, changes the labels to Yes and No:</p> * * <pre> * package skins * // components\mobile\skins\MyToggleSwitchSkin.as * { * import spark.skins.mobile.ToggleSwitchSkin; * * public class MyToggleSwitchSkin extends ToggleSwitchSkin * { * public function MyToggleSwitchSkin() * { * super(); * // Set properties to define the labels * // for the selected and unselected positions. * selectedLabel="Yes"; * unselectedLabel="No"; * } * } * } Thanks, Om > > > > > -- > View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Custom-ToggleSwitch-in-code-tp46201.html > Sent from the Apache Flex Development mailing list archive at Nabble.com.