0 Replies Latest reply on Jul 24, 2011 11:19 AM by MintDouble

    Flash Builder 4.5.1 for mobile devices and HSlider

    MintDouble

      Background: According to Narciso Jaramillo, ( http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html ) it is not a good idea to use MX components in mobile projects.  OK.  So this goes along with other guidance not to use VSlider, and to prefer HSider with a spark library to back it up.  With these cautions and suggestions in mind, I have made a really simple bit of actionscript code.  My goal is to use an HSlider in an actionscript mobile project.  My problem is the failure of the HSlider to ever show up on the simulator screen.  Fortunately, the compiler throws and error - "Initial content not found".  The guidance offered by the examples in the ActionScript(R) 3.0 Reference fo the Adobe Flash platform includes a code example for some markup language.  There is no example for using the HSlider in actionscript.

       

      Question: How can the slider be made visible, and therefore useful in actionscript.   The app-xml has a line that sets visible to true.  Here is my  actionscript code:

       

       

      package
      {
          import flash.display.Sprite;
          import flash.display.*;
          import flash.display.StageAlign;
          import flash.display.StageScaleMode;
         
      //  See http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html   
          // "We don't recommend using MX components in mobile projects"
      //    import mx.core.DPIClassification;
      //    import mx.core.mx_internal;
         
          import spark.components.*;
          import spark.components.HSlider;
          import spark.components.Image;
          import spark.components.VSlider;
          import spark.preloaders.SplashScreen;
          import spark.skins.*;
          import spark.transitions.ZoomViewTransitionMode;
         
      //    use namespace mx_internal;
         
          public class HSliderBug extends Sprite
          {
              public function HSliderBug()
              {
                  super();
                 
                  // support autoOrients
                  stage.align = StageAlign.TOP_LEFT;
                  stage.scaleMode = StageScaleMode.NO_SCALE;
                 
                 
                  var hSlider:HSlider = new HSlider;
                  hSlider.minimum = 0;
                  hSlider.maximum = 100;
                  hSlider.value = 1;
                  hSlider.stepSize = 0.1;
                  hSlider.snapInterval = 0.1;
                  hSlider.move(30, 40);
                  hSlider.width = 125;
                  hSlider.height = 30;
                 
                  addChild(hSlider);           
             
              }
          }
      }