6 Replies Latest reply on Sep 3, 2009 5:11 AM by David_F57

    Why is my hslider invisible

    ron71nl

      Hi all,

       

      I'm trying to instantiate a HSlider programmatically and place it on the stage.

      Whatever I do, it remains invisible... I'm just wondering if I miss a skin library or something.

       

      If I replace the HSlider with the old fl.controls.Slider, it all works fine (But I want the HSlider because I want tick labels).

       

      var _slider:HSlider = new HSlider();

       

      _slider.x = 10;

      _slider.y = 10;

      _slider.width = 200;

      _slider.height = 30;

       

      _slider.value = 0;

      _slider.snapInterval = 0.01;

      _slider.minimum = 0;

      _slider.maximum = 10;

      _slider.tickInterval = 1;

      _slider.allowTrackClick = true;

      _slider.visible = true;

       

      stage.addChild(_slider)

       

      See the attachment for the libs/swc's I've incorporated in my project.

       

      Anyone any clues?

       

      Ronaldo

       

      PS: It's really hard to find out what libs/swc's you need when there's a class that cannot be found. Is there any overview of the swc's content or a library finder utility for a specific class? Now it's just trial and error.

        • 1. Re: Why is my hslider invisible
          David_F57 Level 5

          use this.addElement instead of stage.addchild, this should fix your problem.

           

          David

          1 person found this helpful
          • 2. Re: Why is my hslider invisible
            ron71nl Level 1

            Hmm. Thanks for the reply.

            I'm adding the HSlider to a Sprite, and the Sprite doesn't have the addElement method...

             

            Seems like I also use an older version of the flash.display.Sprite...

            Even though I can see the flash.display.Sprite is in the /Applications/Adobe Flash Builder Beta/sdks/4.0.0/frameworks/libs/player/10/playerglobal.swc lib.

             

            Ronaldo

            • 3. Re: Why is my hslider invisible
              David_F57 Level 5

              try placing a group into the sprite and then add the slider to the group, you need to load the slider as a visualelement.

               

              David

               

              [edit] also make sure your sprite is being displayed with both a width and height, do you need a sprite ?

              1 person found this helpful
              • 4. Re: Why is my hslider invisible
                ron71nl Level 1

                Ok, I used a Group and used the addElement method to add the HSlider,

                but it seems like I need to investigate http://livedocs.adobe.com/flex/gumbo/html/WS2db454920e96a9e51e63e3d11c0bf69084-7f8c.html,

                as I have no syles according to the following error:

                 

                Error: No class registered for interface 'mx.styles::IStyleManager2'.

                at mx.core::Singleton$/getInstance()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\ Singleton.as:111]

                at mx.styles::StyleManager$/get impl()[E:\dev\beta1\frameworks\projects\framework\src\mx\styles\StyleManager.as:92]

                at mx.styles::StyleManager$/get b....

                 

                Thank you so far for replying.

                • 5. Re: Why is my hslider invisible
                  David_F57 Level 5

                  Without more info on what you are trying to do (i.e. are you creating the sprite as well, are you using a separate class..) i am not sure what your problem is, the following code programatically adds a group and a slider to the application (no sprite)without a problem.

                   

                   

                   

                  <?xml version="1.0" encoding="utf-8"?>

                  <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                                 xmlns:s="library://ns.adobe.com/flex/spark"

                                 xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"

                                 creationComplete="application1_creationCompleteHandler(event)">

                  <fx:Script>

                  <![CDATA[

                    import mx.events.FlexEvent;

                    import spark.components.HSlider;

                    import spark.components.Group;

                    private var myGroup :Group = new Group();

                    private var mySlider:HSlider = new HSlider();

                   

                  protected function application1_creationCompleteHandler(event:FlexEvent):void

                     myGroup.width=300;

                     myGroup.height=400;

                     myGroup.x=0;

                     myGroup.y=0;

                     this.addElement(myGroup);

                     mySlider.width=300;

                     mySlider.height=25;

                     myGroup.addElement(mySlider);

                  }

                   

                  ]]>

                  </fx:Script>

                  </s:Application>

                   

                   

                  [Edit] i just realised you are not using the spark hslider but the mx one, i will look at the problem again.

                  • 6. Re: Why is my hslider invisible
                    David_F57 Level 5

                    <?xml version="1.0" encoding="utf-8"?>

                    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                    xmlns:s="library://ns.adobe.com/flex/spark"

                    xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" creationComplete="application1_creationCompleteHandler(event)">

                    <fx:Script>

                    <![CDATA[

                    import mx.controls.HSlider;

                    import mx.events.FlexEvent;

                    import spark.components.HSlider;

                    import spark.components.Group;

                    private var myGroup :Group = new Group();

                    private var aSlide:mx.controls.HSlider= new mx.controls.HSlider(); <----- mx hslider that supports ticks

                     

                    protected function application1_creationCompleteHandler(event:FlexEvent):void

                    {

                    myGroup.width=300;

                    myGroup.height=400;

                    myGroup.x=0;

                    myGroup.y=0;

                    this.addElement(myGroup);

                    aSlide.width=300;

                    aSlide.height=25;

                    aSlide.tickInterval=5;

                    myGroup.addElement(aSlide);

                    }

                    ]]>

                    </fx:Script>

                    </s:Application>