5 Replies Latest reply on Jan 30, 2008 11:43 PM by etnot96

    How to adding text to canvas?

      I am doing AS3 programactically so I have a one mxml file that calls to my application.

      I am running in to issues when I try to display text inside the Canvas of a view in the ViewStack(The view stack is displaying correctly with links for the navbar). See code below. What am I doing wrong? Any help is welcome!

      BTW, I know I posted a lot of code but I really want some help on this as I am very new to AS3. The real meat of the code is in the AccountView class.

      Thanks in Advance!

      Tonté Pouncil
        • 1. Re: How to adding text to canvas?
          Peter deHaan Level 4

          What if you try using a Canvas or VBox container instead of a UIComponent in your AccountView?

          • 2. Re: How to adding text to canvas?
            etnot96 Level 1
            Peter, first of all, I would like to thank you for taking the time to respond. Thanks!

            AccountView extends View which is a Canvas. I have since change my AccountView.as class see below. I have tried using both mx.controls.Text and mx.core.UITextField but neither works when it come to displaying the text in the canvas. Again the ViewStack is showing the LinkBar appropriately. Do you know why it is not working?

            Thanks again!

            package com.pouncilt.chuckspic3.views{
            import mx.controls.Text;
            import mx.core.UITextField;

            internal class AccountView extends View{

            public function AccountView(label:String){
            var welcomeText:UITextField = new UITextField();
            welcomeText.text = "Account Page";
            • 3. Re: How to adding text to canvas?
              Jason Szeto Level 3
              If you are using a ViewStack, you might want to play around with setting the creationPolicy property of the ViewStack's children to a value of "all". ViewStacks will defer the instantiation of its non-selected children until that child is requested to be viewed.
              • 4. Re: How to adding text to canvas?
                etnot96 Level 1
                Thanks for the post Jason Szeto.

                I tried what you suggested but no luck. Again my link nav bar works fine but the view related to the links does not show my simple mx.controls.Text on the screen. I am using Flex2/ActionScript 3.0. Can you or somebody try compile my code so they can see exactly what issue I am having?


                • 5. Re: How to adding text to canvas?
                  etnot96 Level 1
                  OK folks I figured out what I was doing wrong. In my Main.as class I have a method called createNavigationBar() and in this method is where I add the Linkbar (I refer to LinkBar as NavBar in my code) to the Panel. Because I am a newbie and tbecause of the lack of documentation of working with Flex programmatically, I didn't know I had to also added the ViewStack to the Panel. This was not so clear to me because I had already added the ViewStack to the LinkBar as my DataProvider. So I thought since I already connected my ViewStack to the LinkBar via DataProvider and then adding the LinkBar to the Panel I should see both aspects of the ViewStack (the navbar and the main view). But this is where I was wrong. See Code snippet below:

                  Its funny that no body spotted this. But many thanks to all who took the time to help with suggestion and links. I learn a lot about Flex/ActionScript3 while debugging this issue.