Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8068931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:50:47+00:00 2026-06-05T12:50:47+00:00

May be this is very simple but right now I am unable to put

  • 0

May be this is very simple but right now I am unable to put a solution for it. Here is brief description of my problem:

I have a dictionary of clipart objects as:

clipartDict['cat'] = Cat; //Cat.mxml
clipartDict['dog'] = Dog; //Dog.mxml

Cat.mxml:

<s:Graphic>
    <s:Path x="2.86723" y="-0.000106812" data="M3.45943 80.3419C3.06051 77.3605 0.002399>
    </s:Path>
</s:Graphic>

MyView.mxml (relevant code):

<s:SkinnableDataContainer width="300" dataProvider="{clipArts}">
    <s:layout>
        <s:TileLayout requestedColumnCount="1"/>
    </s:layout>
    <s:itemRenderer>
        <fx:Component>
            <s:ItemRenderer>
                <fx:Script>
                    <![CDATA[
                        import models.vo.ClipArtVO;
                        // (data as ClipArtVO).clipArtFileName represents the 'key' in dictionary.
                        // Now, how can I display the relevent clipart from dict based on the key
                        // this.addElement throws an Type Coercion error

                    ]]>
                </fx:Script>

            </s:ItemRenderer>
        </fx:Component>
    </s:itemRenderer>
</s:SkinnableDataContainer>

Can anyone suggest me a solution or any idea to implement it in any different way?
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:50:50+00:00Added an answer on June 5, 2026 at 12:50 pm

    What you’ve put in that Dictionary are Class references and not instances. You’ll have to create an instance of the desired Graphic to add it to the displayList. So there are two methods to fix your issue.

    Method 1

    Put instances of the Graphics in the Dictionary (instead of Class references):

    clipartDict['cat'] = new Cat();
    clipartDict['dog'] = new Dog();
    

    Then simply add it to the displayList:

    var graphic:Graphic = clipartDict[(data as ClipArtVO).clipArtFileName];
    addElement(graphic);
    

    Method 2

    Create an instance of the Class reference on the fly. We keep the Dictionary as it was:

    clipartDict['cat'] = Cat;
    clipartDict['dog'] = Dog;
    

    and create an instance and add it to the displayList like this:

    var Graphic:Class = clipartDict[(data as ClipArtVO).clipArtFileName];
    addElement(new Graphic());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may sound like a very generic question but here it goes. I have
This may be very simple, but it's late in the night... I have two
This may be very simple question but I have been looking around for a
This may be very simple question,But please help me. i wanted to know what
this may be a very simple question, but is it possible to force a
This may seem a very silly question. Consider this: I have a simple Boolean
This may be have a better name than custom tab completion, but here's the
this may seem like a very simple question, but I want to dump some
This may be a very mundane question, but this is the first jQuery plugin
This may seem to be an academic question, but still I would be very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.