Solved

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

Posted on 2010-09-15
4
481 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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.

743 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

16 Experts available now in Live!

Get 1:1 Help Now