Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create a two classes to manage the themes:</p> <p>The first manages the theme name</p> <pre><code>package { public class Styles { public static const DARK:String = "dark"; public static const LIGHT:String = "light"; public static var currentStyleName:String = "dark"; public static function setStyles(styleName:String):void { currentStyleName = styleName; } } } </code></pre> <p>The second one manages the assets</p> <pre><code>package { import flash.events.EventDispatcher; import flash.display.*; import flash.utils.getDefinitionByName; import Styles; public class Assets extends EventDispatcher { public static function setStyles(styleName:String):void { currentStyleName = styleName; } public static function getClass(name:String):Class { var TheClass:Class = getDefinitionByName(name) as Class; return TheClass; } public static function sprite(name:String):Sprite { return new (getClass(name)) as Sprite; } public static function simpleButton(name:String):SimpleButton { return new (getClass(name)) as SimpleButton; } public static function styledName(name:String):String { return name + Styles.currentStyleName.replace(/^\w/, function(firstChar) { return firstChar.toUpperCase(); }); } } } </code></pre> <p>In your Flash Library you need set the linkage name for each symbol something like this:</p> <pre><code>myButtonDark myButtonLight mySpriteDark mySpriteLight </code></pre> <p>Now you must set the current style name</p> <pre><code>Styles.setStyles(Styles.LIGHT); </code></pre> <p>Finally you can create the instances that you need</p> <pre><code>// All the instances created here belong to the Light theme addChild( Assets.simpleButton(Assets.styledName("myButton")) ); addChild( Assets.sprite(Assets.styledName("mySprite")) ); // Changes the theme to dark Styles.setStyles(Styles.DARK); // All the instances created here belong to the Dark theme addChild( Assets.simpleButton(Assets.styledName("myButton")) ); addChild( Assets.sprite(Assets.styledName("mySprite")) ); </code></pre> <p>I hope that it works for you :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload