A very newby question

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default A very newby question

    Hi all,
    I am a new learner of Flex and action script. I just got a very simple
    question that, for example, if i have 3 HBox:
    <mx:HBox id="1" .../>
    <mx:HBox id="2" .../>
    <mx:HBox id="3" .../>

    Then in my action class, for example, if i use:

    var text:Text = new Text();
    ....
    this.1.addChild(text);
    this.2.addChild(text);
    this.3.addChild(text);


    Then my template wont generate, i guess there is an error or something. So if
    i want to create one component and registered it in 3 or more different
    containers, can i do this?

    If can't, then how i can just create one component and use it in multiple
    place instead of creating multiple components and change them one after another?


    Thanks in advance!

    _LJ Guest

  2. Similar Questions and Discussions

    1. Newby Question: hither and yon?
      Hi, I'm new to Shockwave 3D and am trying to work out how to set the hither and yon parameters for my 3D world. At the moment the 3D world is not...
    2. newby question: error log
      hi, how do you define variables (or constants) correctly? my error log ist full with entries like those: PHP Notice: Undefined variable:...
    3. Newby Question: Displaying Excel from within my CGI
      "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message news:bjgepo$iovdq$1@ID-184292.news.uni-berlin.de... Well, he is posting this in a Perl...
    4. Newby question: Good PHP/Web editor
      I have been developping in php for some months. My Web editor is FrontPage. No need to say that editing PHP is far from easy, then. I have tried one...
    5. Another Newby partitioning question
      The primary drive is an old 2GB, slave drive is 10GB. I know I have to install the OS on the primary drive. But is there a way I can load most of...
  3. #2

    Default Re: A very newby question

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="mytest();"
    >
    <mx:Script>
    <![CDATA[
    import mx.controls.Text;

    public var text:Text;
    public function mytest():void
    {
    text = new Text();
    text.height=40;
    text.width = 50;
    text.setStyle("borderColor","Yellow");
    text.setStyle("borderStyle","solid");
    text.setStyle("borderThickness","2");
    text.text="hello";
    h1.addChild(text);
    //h2.addChild(text);
    //h3.addChild(text);

    }



    ]]>
    </mx:Script>
    <mx:HBox x="0" width="100%" height="50" backgroundColor="red" id="h1"
    y="100"/>

    <mx:HBox x="0" width="100%" height="50" backgroundColor="#0000ff" id="h2"
    y="200"/>

    <mx:HBox x="0" width="100%" height="50" backgroundColor="#808040" id="h3"
    y="300"/>

    </mx:Application>




    007none Guest

  4. #3

    Default Re: A very newby question

    you could always may and array of them and do it in afor loop


    var texts:array = new array();

    for( var i:int =0; i < quantity_wanted; i++){

    var tmp:Text = new Text()
    tmp.width = 50;
    tmp.setStyle("borderColor","Yellow");
    tmp.setStyle("borderStyle","solid");
    tmp.setStyle("borderThickness","2");
    ....
    texts.push(tmp);

    }

    that will generate as many as you want


    as for making one and using it over and over again. im not sure you can do
    this. even if you could im not sure you would want it because i would think
    when you put text into one the text would appear in all.

    theNOCer Guest

  5. #4

    Default Re: A very newby question

    Yes, a single instance of a component can only have one parent.

    You are trying to put "text" into three components. Create a new instance for each component.

    Tracy
    ntsiii Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139