Skip to main content
Participant
November 23, 2010
Question

Is this a bug, or am I missing something?

  • November 23, 2010
  • 1 reply
  • 636 views

In a custom Image component, I want to embed the image. When I do this, the ability to click the icon stops working. Below are two snippets of code. The first where I embed the image, the second where I don't. The first will not allow clicking the component, the second works fine.

Is this a bug? or am I missing something?

I am using v3.5 of the compiler.


==================================

public class HelpIcon extends Image

{

     [Embed(source="/assets/Info.png")]

    public var thisIcon:Class;
    public function HelpIcon()

    {
        super();
        this.addEventListener(MouseEvent.CLICK, helpClicked,true,5); // so we know when help has been asked for
        this.source = thisIcon;
     }

==================================

public class HelpIcon extends Image

{

     [Embed(source="/assets/Info.png")]

    public var thisIcon:Class;
    public function HelpIcon()

    {
        super();
        this.addEventListener(MouseEvent.CLICK, helpClicked,true,5); // so we know when help has been asked for
        this.source = "assets/Info.png";
     }

This topic has been closed for replies.

1 reply

Inspiring
November 24, 2010

What is the Image class? What does it extend? What is the datatype of  this.source?

Also try:

this.source = new thisIcon();

aceincAuthor
Participant
November 24, 2010

public

class HelpIcon extends Image

The attached snippets showed it extending "mx:Image.

class HelpIcon extends Image

[

Embed(source="/assets/Info.png")]public var thisIcon:Class;

The attached snippets showed a type of class.

Not precisely sure what you are asking. I added the code as you suggested, it still will not honor the click event on the image.

Here is the code modified as you suggested;

 

public class HelpIcon extends Image
{
  [Embed(source="/assets/Info.png")]
  public var thisIcon:Class;

  public function HelpIcon()
  {
   super();
   this.source = new thisIcon();
   this.addEventListener(FlexEvent.CREATION_COMPLETE,initHelp)
  }
 
  private function initHelp(event:Event):void
  {
   this.removeEventListener(FlexEvent.CREATION_COMPLETE,initHelp);
   this.addEventListener(MouseEvent.CLICK, helpClicked,true,5); 
  }
 
It still does not honor the click event.

Paul

Inspiring
November 24, 2010

I am asking what class Image class extends - not Helpicon.