Solved

Referencing the properties of a RichEditableText child of a mxml composite component

Posted on 2010-09-15
4
486 Views
Last Modified: 2012-05-10
Hi, I have been reading about custom and composite components styles and skins, and tbh honest keep going round in circles trying to understand how i do the following.

I require a custom component comprising of a two richeditbabletext sitting within a parent container that will be used as the basis of a heading (like in a book) The size, font, background colour and some other properties on each seperate RET need to be changed independantly based upon incoming xml, which I have already got to the stage where it is ready to be used and is not a problem.

So far I have tried creating a custom mxml component, based upon group  and added two RTE, but when I use this component within the main application, I have no access to the properties of the RET components. The only way so far I have found to get some sort of control over the RET's is by using the setstyle property, but my gut instinct tells me this is the wrong way to do it.

Should I be using skin parts?, styles  or AS classes to declare the wanted properies . Based upon what I have said if someone could give me a generalized view of how to create a composite component it would be very much appreciated.

Regards Mr CONFUSED





0
Comment
Question by:BloodGrinder
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:ChristoferDutz
ID: 33680833
Do you have to access the RETs themselves or you you want to make your custom component set them for you depending on the data it sees (I would prefer the later approach).

If you simply want to access the RTE instances, simply add two public functions to your custom component:

public function getRTE1():RichEditableText 

{

      return rte1;

}



public function getRTE2():RichEditableText 

{

      return rte2;

}



....

<s:RichEditableText id="rte1" .../>

...

<s:RichEditableText id="rte2" .../>

Open in new window

0
 

Author Comment

by:BloodGrinder
ID: 33681106
The second way as the component needs to react to the data. Thanks for your help
0
 
LVL 20

Accepted Solution

by:
ChristoferDutz earned 500 total points
ID: 33681764
Ok ... so the component has to have a property. Let's call it "value". So you have something like this. This is coded in ExpertsExchange and schould be treated as pseudo-code ... Just to give you the idea.

The idea is to give the component the data it should display. You can now do some calculations on that data and set some other internal properties, that you can use to style your RTEs.

Hope this get's you on the way.

<s:Group>

    <fx:Script>



        [Bindable]

        private var _value:Object;



        [Bindable]

        private var myColor:uint;



        public function set value(val:Object):void {

            _value = val;



            if(_value && (_value.property345423 > 3)) {

                myColor = Blue;

            }

        }



    </fx:Script>



    <s:RichEditableText text="{_value.property1}"/>

    <s:RichEditableText backgroundColor="{myColor}" text="{_value.property2}"/>

</s:Group>

Open in new window

0
 

Author Closing Comment

by:BloodGrinder
ID: 33682793
Thank you, its given me the pointers i needed. Regards
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now