<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Turning Components From MXML To Actionscript &#8211; Part 2</title>
	<atom:link href="http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/</link>
	<description>Blog on technology and software development typically around Adobe Flash, Flex, and AIR.</description>
	<lastBuildDate>Wed, 25 Jan 2012 11:21:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Flex learner &#124; Blog &#124; Turning Components From MXML To Actionscript – Part 2 &#124; UnitedMindset</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-802</link>
		<dc:creator>Flex learner &#124; Blog &#124; Turning Components From MXML To Actionscript – Part 2 &#124; UnitedMindset</dc:creator>
		<pubDate>Thu, 13 Jan 2011 21:23:06 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-802</guid>
		<description>[...] See the rest here: Turning Components From MXML To Actionscript – Part 2 &#124; UnitedMindset [...]</description>
		<content:encoded><![CDATA[<p>[...] See the rest here: Turning Components From MXML To Actionscript – Part 2 | UnitedMindset [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Campos</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-45</link>
		<dc:creator>Jonathan Campos</dc:creator>
		<pubDate>Sat, 01 Aug 2009 00:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-45</guid>
		<description>Here is your event code:

&lt;code lang=&quot;actionscript&quot; width=&quot;490&quot;&gt;
package events
{
    import flash.events.Event;

    public class OtherContentClicked extends Event
    {
        //public var canServ:CanvasServices;
        public static const OTHER_CONTENT_CLICK:String = &quot;otherContentClick&quot;;
        public var link:String;

        public function OtherContentClicked(type:String,link:String=null,bubbles:Boolean=true, cancelable:Boolean=false)
        {
            this.link = link;
            super(type, bubbles, cancelable);

        }

        /*public override function clone():Event
        {
            retutn new OtherContentClicked();


        }*/

    }
}
&lt;/code&gt;

And here another version with just a few changes I would make that I think you would agree help things work a bit better. I included note through the code.

&lt;code lang=&quot;actionscript&quot; width=&quot;490&quot;&gt;
package events
{
    import flash.events.Event;

    public class OtherContentClicked extends Event
    {
        //public var canServ:CanvasServices;
        public static const OTHER_CONTENT_CLICK:String = &quot;otherContentClick&quot;;

        private var _link:String;
        //we make it so the link can&#039;t be changed as the event moves through the event flow.
        public function get link():String{
             return _link;
        }

        public function OtherContentClicked(type:String,link:String=null,bubbles:Boolean=true, cancelable:Boolean=false)
        {
            _link = link;
            super(type, bubbles, cancelable);

        }

        public override function clone():Event
        {
            // you need to include the vars from the current event to the new clone
            return new OtherContentClicked(type, link, bubbles, cancelable);
        }

    }
}
&lt;/code&gt;

Hope that helps!</description>
		<content:encoded><![CDATA[<p>Here is your event code:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package events<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> OtherContentClicked <span style="color: #0066CC;">extends</span> Event<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//public var canServ:CanvasServices;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OTHER_CONTENT_CLICK:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;otherContentClick&quot;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> link:<span style="color: #0066CC;">String</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> OtherContentClicked<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>,link:<span style="color: #0066CC;">String</span>=<span style="color: #000000; font-weight: bold;">null</span>,bubbles:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, cancelable:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">this</span>.<span style="color: #006600;">link</span> = link;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*public override function clone():Event<br />
&nbsp; &nbsp; &nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retutn new OtherContentClicked();<br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; }*/</span><br />
<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>And here another version with just a few changes I would make that I think you would agree help things work a bit better. I included note through the code.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">package events<br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">Event</span>;<br />
<br />
&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> OtherContentClicked <span style="color: #0066CC;">extends</span> Event<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//public var canServ:CanvasServices;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OTHER_CONTENT_CLICK:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;otherContentClick&quot;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _link:<span style="color: #0066CC;">String</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//we make it so the link can't be changed as the event moves through the event flow.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">get</span> link<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">return</span> _link;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> OtherContentClicked<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>,link:<span style="color: #0066CC;">String</span>=<span style="color: #000000; font-weight: bold;">null</span>,bubbles:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">true</span>, cancelable:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _link = link;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> override <span style="color: #000000; font-weight: bold;">function</span> clone<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:Event<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// you need to include the vars from the current event to the new clone</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> OtherContentClicked<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, link, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DK</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-44</link>
		<dc:creator>DK</dc:creator>
		<pubDate>Fri, 31 Jul 2009 22:32:16 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-44</guid>
		<description>I got it!  Your steps helped me to figure it out.  I created the custom event, but I didn&#039;t use the clone, but I did use the super.  Thanks so much!  I&#039;ll send you the custom event code so you can see if I may need the clone!  Thanks so much!</description>
		<content:encoded><![CDATA[<p>I got it!  Your steps helped me to figure it out.  I created the custom event, but I didn&#8217;t use the clone, but I did use the super.  Thanks so much!  I&#8217;ll send you the custom event code so you can see if I may need the clone!  Thanks so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Campos</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-43</link>
		<dc:creator>Jonathan Campos</dc:creator>
		<pubDate>Fri, 31 Jul 2009 14:00:56 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-43</guid>
		<description>If you don&#039;t mind, email your code directly and I will make my changes and test, I am sure we can get this working. jonbcampos at gmail

I am noticing that your implementation of the custom event is missing a constant and also missing variables passed in the clone function. You need to pass on the variables from the currently constructed event to the cloned event so those variables are available to the new event.</description>
		<content:encoded><![CDATA[<p>If you don&#8217;t mind, email your code directly and I will make my changes and test, I am sure we can get this working. jonbcampos at gmail</p>
<p>I am noticing that your implementation of the custom event is missing a constant and also missing variables passed in the clone function. You need to pass on the variables from the currently constructed event to the cloned event so those variables are available to the new event.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DK</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-42</link>
		<dc:creator>DK</dc:creator>
		<pubDate>Fri, 31 Jul 2009 12:27:29 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-42</guid>
		<description>Hello,

The above post removed my mxml tag that I had originally posted.  That was the &quot;example above&quot; that never showed up in the comment.  I apologize if that was confusing.  So, I removed the start and end tags

local:CanvasServices  x=&quot;10&quot; y=&quot;20&quot; OtherContentClick=&quot;ChangeStateServices()&quot;

The event shows up and I can use the event using this method, but like I said above the htmlText property shows up without line breaks and without the bulleted lists, but using the addChild method it renders perfectly. So, I would like to set the event listener in the code.

Thanks!</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>The above post removed my mxml tag that I had originally posted.  That was the &#8220;example above&#8221; that never showed up in the comment.  I apologize if that was confusing.  So, I removed the start and end tags</p>
<p>local:CanvasServices  x=&#8221;10&#8243; y=&#8221;20&#8243; OtherContentClick=&#8221;ChangeStateServices()&#8221;</p>
<p>The event shows up and I can use the event using this method, but like I said above the htmlText property shows up without line breaks and without the bulleted lists, but using the addChild method it renders perfectly. So, I would like to set the event listener in the code.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DK</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-41</link>
		<dc:creator>DK</dc:creator>
		<pubDate>Thu, 30 Jul 2009 22:47:53 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-41</guid>
		<description>Thank you so much  for the clarification! A lot of those terms I knew and used once or twice, but it put some light on it.  I still cannot get my function that just shows an alert that says &quot;please work!&quot; to fire.  I did the

ServicesContent.addEventListener(&quot;OtherContentClick&quot;,ChangeStateServices);

and that didn&#039;t work but the mxml version does work.:

&#039;&#039;

The reason I don&#039;t just do the example above is that I have about 5 of those components that I am going to addchild and remove child to all of them.  Also, the htmlText doesn&#039;t render the same in the mxml tag version, but renders correctly in the addChild version.
So, what could be the deal?  I have tried the extended event and couldn&#039;t quite get the syntax
here it is:
package events
{
	import flash.events.Event;

	public class OtherContentClicked extends Event
	{
		public var canServ:CanvasServices;

		public function OtherContentClicked(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
		{
			super(type, bubbles, cancelable);
			this.canServ;
		}

		public override function clone():Event
		{
			retutn new OtherContentClicked();


		}

	}
}</description>
		<content:encoded><![CDATA[<p>Thank you so much  for the clarification! A lot of those terms I knew and used once or twice, but it put some light on it.  I still cannot get my function that just shows an alert that says &#8220;please work!&#8221; to fire.  I did the</p>
<p>ServicesContent.addEventListener(&#8220;OtherContentClick&#8221;,ChangeStateServices);</p>
<p>and that didn&#8217;t work but the mxml version does work.:</p>
<p>&#8221;</p>
<p>The reason I don&#8217;t just do the example above is that I have about 5 of those components that I am going to addchild and remove child to all of them.  Also, the htmlText doesn&#8217;t render the same in the mxml tag version, but renders correctly in the addChild version.<br />
So, what could be the deal?  I have tried the extended event and couldn&#8217;t quite get the syntax<br />
here it is:<br />
package events<br />
{<br />
	import flash.events.Event;</p>
<p>	public class OtherContentClicked extends Event<br />
	{<br />
		public var canServ:CanvasServices;</p>
<p>		public function OtherContentClicked(type:String, bubbles:Boolean=false, cancelable:Boolean=false)<br />
		{<br />
			super(type, bubbles, cancelable);<br />
			this.canServ;<br />
		}</p>
<p>		public override function clone():Event<br />
		{<br />
			retutn new OtherContentClicked();</p>
<p>		}</p>
<p>	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Campos</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-40</link>
		<dc:creator>Jonathan Campos</dc:creator>
		<pubDate>Thu, 30 Jul 2009 17:51:33 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-40</guid>
		<description>Okay, I see what the real problem is. The thing to know is that the intellisense (the code completion helper) doesn&#039;t &quot;know all&quot;. Some times there is a class it can&#039;t find or an event it doesn&#039;t know. Part of this problem is the intellisense, part of it is how you set up your component to work with the intellisense.

The short answer is: Add in your event listener with:

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
ServicesContent.addEventListener(&quot;OtherContentClick&quot;,_yourHandler);
&lt;/code&gt;

I bet you everything will work just as you expect and you won&#039;t receive any errors.

That is the short answer, the long answer doesn&#039;t take a ton of time, but it does take being very exact with your component setup.

1. Usually all variables are camel case. ServicesContent, should be servicesContent.
2. Event names are also camel case. OtherContentClick should be otherContentClick.
3. The intellisense is trying to find your event, but what it is doing is looking at the type and finding Event. Then it is trying to show the OTHER_CONTENT_CLICK constant from the event. It isn&#039;t finding this information, so it just doesn&#039;t show anything. What you would have to do to get everything to show the way you want is to create your own custom event (extended from the Event base class) and include a constant like so...

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
public static const OTHER_CONTENT_CLICK:String = &quot;otherContentClick&quot;;
&lt;/code&gt;

Don&#039;t forget to update your metatag!

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
[Event(name=&quot;otherContentClick&quot;, type=&quot;com.your.packaged.events.CustomEvent&quot;)]
&lt;/code&gt;

Then in your event you would dispatch.

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
dispatchEvent(new CustomEvent(CustomEvent.OTHER_CONTENT_CLICK));
&lt;/code&gt;

and THEN (long way, I know) your intellisense will work in your actionscript for:

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
servicesContent.addEventListener(CustomEvent.OTHER_CONTENT_CLICK, _handler);
&lt;/code&gt;

With the CustomEvent automatically in your drop down list.

Remember, short answer is: It&#039;s there, the intellisense just doesn&#039;t know it. And all that event listeners are really looking for in the event stream is a string, so just make sure the strings match. That is why people use constants, makes it easier to reduce string mistype.</description>
		<content:encoded><![CDATA[<p>Okay, I see what the real problem is. The thing to know is that the intellisense (the code completion helper) doesn&#8217;t &#8220;know all&#8221;. Some times there is a class it can&#8217;t find or an event it doesn&#8217;t know. Part of this problem is the intellisense, part of it is how you set up your component to work with the intellisense.</p>
<p>The short answer is: Add in your event listener with:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ServicesContent.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;OtherContentClick&quot;</span>,_yourHandler<span style="color: #66cc66;">&#41;</span>;</div></div>
<p>I bet you everything will work just as you expect and you won&#8217;t receive any errors.</p>
<p>That is the short answer, the long answer doesn&#8217;t take a ton of time, but it does take being very exact with your component setup.</p>
<p>1. Usually all variables are camel case. ServicesContent, should be servicesContent.<br />
2. Event names are also camel case. OtherContentClick should be otherContentClick.<br />
3. The intellisense is trying to find your event, but what it is doing is looking at the type and finding Event. Then it is trying to show the OTHER_CONTENT_CLICK constant from the event. It isn&#8217;t finding this information, so it just doesn&#8217;t show anything. What you would have to do to get everything to show the way you want is to create your own custom event (extended from the Event base class) and include a constant like so&#8230;</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> const OTHER_CONTENT_CLICK:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;otherContentClick&quot;</span>;</div></div>
<p>Don&#8217;t forget to update your metatag!</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#91;</span>Event<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>=<span style="color: #ff0000;">&quot;otherContentClick&quot;</span>, <span style="color: #0066CC;">type</span>=<span style="color: #ff0000;">&quot;com.your.packaged.events.CustomEvent&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div></div>
<p>Then in your event you would dispatch.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dispatchEvent<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CustomEvent<span style="color: #66cc66;">&#40;</span>CustomEvent.<span style="color: #006600;">OTHER_CONTENT_CLICK</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div></div>
<p>and THEN (long way, I know) your intellisense will work in your actionscript for:</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">servicesContent.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>CustomEvent.<span style="color: #006600;">OTHER_CONTENT_CLICK</span>, _handler<span style="color: #66cc66;">&#41;</span>;</div></div>
<p>With the CustomEvent automatically in your drop down list.</p>
<p>Remember, short answer is: It&#8217;s there, the intellisense just doesn&#8217;t know it. And all that event listeners are really looking for in the event stream is a string, so just make sure the strings match. That is why people use constants, makes it easier to reduce string mistype.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DK</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-39</link>
		<dc:creator>DK</dc:creator>
		<pubDate>Thu, 30 Jul 2009 16:26:44 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-39</guid>
		<description>Wow, thanks for the response, but I am thrown off track a bit.  I will try to break it down and clarify.  I really appreciate your input as I am on a deadline.  You are awesome!

I made a component called  CanvasServices.mxml.  In this component I have this click handler that dispatches the event called &quot;OtherContentClick&quot;

public function LinkClicked(event:MouseEvent):void{

var linkinfo:String = event.target.id.toString();

switch (linkinfo)
{
	case &quot;maskedImage&quot;:
	LinkInformation = &quot;Contact&quot;;
	break;

	case &quot;maskedImageLower&quot;:
LinkInformation = &quot;Form&quot;;
	break;

	}

	var eventObj:Event = new Event(&quot;OtherContentClick&quot;);
	dispatchEvent(eventObj);

}

In the component I have this metadata tag


   [Event(name=&quot;OtherContentClick&quot;, type=&quot;flash.events.Event&quot;)]


Now normally I would just call out the mxml component in tag form and if I typed in OtherCon- the event would show up in the code help and I would just handle as an attribute of the tag, but if I call it out and Addchild to another canvas in the script, I can&#039;t get to the property of the event.

var ServicesContent:CanvasServices = new CanvasServices();
ServicesContent.y = 20;
ServicesContent.x = 10;
CanvasOtherContent.addChild(ServicesContent);
//I want to addeventlistener to the CanvasOtherContent, but can&#039;t access the event

So, what does adding the mxml  () do  in the background that allows me to get to the event that I can&#039;t do in the script?

Thanks again!
DK</description>
		<content:encoded><![CDATA[<p>Wow, thanks for the response, but I am thrown off track a bit.  I will try to break it down and clarify.  I really appreciate your input as I am on a deadline.  You are awesome!</p>
<p>I made a component called  CanvasServices.mxml.  In this component I have this click handler that dispatches the event called &#8220;OtherContentClick&#8221;</p>
<p>public function LinkClicked(event:MouseEvent):void{</p>
<p>var linkinfo:String = event.target.id.toString();</p>
<p>switch (linkinfo)<br />
{<br />
	case &#8220;maskedImage&#8221;:<br />
	LinkInformation = &#8220;Contact&#8221;;<br />
	break;</p>
<p>	case &#8220;maskedImageLower&#8221;:<br />
LinkInformation = &#8220;Form&#8221;;<br />
	break;</p>
<p>	}</p>
<p>	var eventObj:Event = new Event(&#8220;OtherContentClick&#8221;);<br />
	dispatchEvent(eventObj);</p>
<p>}</p>
<p>In the component I have this metadata tag</p>
<p>   [Event(name="OtherContentClick", type="flash.events.Event")]</p>
<p>Now normally I would just call out the mxml component in tag form and if I typed in OtherCon- the event would show up in the code help and I would just handle as an attribute of the tag, but if I call it out and Addchild to another canvas in the script, I can&#8217;t get to the property of the event.</p>
<p>var ServicesContent:CanvasServices = new CanvasServices();<br />
ServicesContent.y = 20;<br />
ServicesContent.x = 10;<br />
CanvasOtherContent.addChild(ServicesContent);<br />
//I want to addeventlistener to the CanvasOtherContent, but can&#8217;t access the event</p>
<p>So, what does adding the mxml  () do  in the background that allows me to get to the event that I can&#8217;t do in the script?</p>
<p>Thanks again!<br />
DK</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Campos</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-38</link>
		<dc:creator>Jonathan Campos</dc:creator>
		<pubDate>Thu, 30 Jul 2009 13:54:20 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-38</guid>
		<description>I am suspecting from your question that your component is what actually fires your custom event. With that assumption you are wanting your main application to listen for this custom event. My question is: Is this component directly off of the main app? Or nested down in the view hierarchy?

I ask because if it is nested you will probably have to make sure the event bubbles if you are wanting to listen for it at the main app level. If it is not nested then the procedure is pretty simple. I am going to make many assumptions about your app right now, but let&#039;s just say that your component is of type &quot;MyComponent&quot;, with a custom event typed &quot;CustomEvent&quot;, and the event type &quot;MY_EVENT&quot;. And let&#039;s say on the creationComplete handler you want to add your &quot;MyComponent&quot; and set up your listener. In the script block, that would look like....

&lt;code lang=&quot;actionscript&quot; width=&quot;480&quot;&gt;
private function _creationComplete_Handler(event:FlexEvent):void{
     var c:MyComponent = new MyComponent();
     c.addEventListener(CustomEvent.MY_EVENT,_customEvent_Handler);
     addChild(c);
}

private function _customEvent_Handler(event:CustomEvent):void{
     Alert.show(&quot;custom event fired&quot;);
}
&lt;/code&gt;

Obviously this is at it&#039;s simplest, but hopefully you see what I am thinking. Is this where you were going with it or did I miss something?</description>
		<content:encoded><![CDATA[<p>I am suspecting from your question that your component is what actually fires your custom event. With that assumption you are wanting your main application to listen for this custom event. My question is: Is this component directly off of the main app? Or nested down in the view hierarchy?</p>
<p>I ask because if it is nested you will probably have to make sure the event bubbles if you are wanting to listen for it at the main app level. If it is not nested then the procedure is pretty simple. I am going to make many assumptions about your app right now, but let&#8217;s just say that your component is of type &#8220;MyComponent&#8221;, with a custom event typed &#8220;CustomEvent&#8221;, and the event type &#8220;MY_EVENT&#8221;. And let&#8217;s say on the creationComplete handler you want to add your &#8220;MyComponent&#8221; and set up your listener. In the script block, that would look like&#8230;.</p>
<div class="codecolorer-container actionscript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="actionscript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _creationComplete_Handler<span style="color: #66cc66;">&#40;</span>event:FlexEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> c:MyComponent = <span style="color: #000000; font-weight: bold;">new</span> MyComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;c.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>CustomEvent.<span style="color: #006600;">MY_EVENT</span>,_customEvent_Handler<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp;addChild<span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> _customEvent_Handler<span style="color: #66cc66;">&#40;</span>event:CustomEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp;Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;custom event fired&quot;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></div></div>
<p>Obviously this is at it&#8217;s simplest, but hopefully you see what I am thinking. Is this where you were going with it or did I miss something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DK</title>
		<link>http://www.unitedmindset.com/jonbcampos/2009/03/10/turning-components-from-mxml-to-actionscript-part-2/#comment-37</link>
		<dc:creator>DK</dc:creator>
		<pubDate>Thu, 30 Jul 2009 12:52:50 +0000</pubDate>
		<guid isPermaLink="false">http://unitedmindset.com/jonbcampos/?p=219#comment-37</guid>
		<description>I made a a custom component in MXML and I bring it into my application using Actionscript, how can I add my custom event to the main application so I can use a handler?  I have the metadata tag in the component, but I can&#039;t set the custom event on the main app?  What am I missing?</description>
		<content:encoded><![CDATA[<p>I made a a custom component in MXML and I bring it into my application using Actionscript, how can I add my custom event to the main application so I can use a handler?  I have the metadata tag in the component, but I can&#8217;t set the custom event on the main app?  What am I missing?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

