[Pixlib] [Suggestion] ArrayEvent

zrehmani@gmail.com zrehmani at gmail.com
Fri Jun 22 12:46:15 EDT 2007


I had the same issue;  if I remember correctly, you have to make sure your method handler is accepting the interface as the parameter rather than the event object.  So, onChange(e:IEvent) rather than onChange(e:NumberEvent).  Try that; if not,  I'll look up what I did to resolve that issue but there is a solution.
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: "quinrou ." <quinrou at gmail.com>

Date: Fri, 22 Jun 2007 17:26:40 
To:Pixlib at osflash.org
Subject: Re: [Pixlib] [Suggestion] ArrayEvent


Zameer,<br><br>Thanks for the code snipset it makes much more sense to see it with code than described with words.<br><br>Without knowing it I was always using the push method but I guess it&#39;s good to know that you can also pull the data.
<br>I am pushing the data with BasicEvent and cast it. Tim said it was &quot;bad&quot; practive but certainly works. Yesterday I started using the NumberEvent and StringEvent and it worked very well until I had to update one asset in my Flash. Then I had to recompile the Flash to update the swf. At that point Flash threw an error about NumberEvent not being the correct type...( I guess there&#39;s differences between Flash and Matsc and the way they compile stuff). 
<br>Since I am trying to keep all my project also compatible with the Flash IDE (in case some else has to carry out some work on my project don&#39;t want to use mtasc) so I had to reverse all NumberEvent and StringEvent. Shame as I liked the idea of keeping my data type.
<br><br>thanks for example.<br>seb<br><br><div><span class="gmail_quote">On 6/22/07, <b class="gmail_sendername">Zameer Rehmani</b> &lt;<a href="mailto:zrehmani at gmail.com">zrehmani at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Correction :)<br>the statement in event handler should be:<br>var nID:Number = BasicEvent(e).getTarget().getID();<br>**forgot the parentheses at the end ha ha ha!<br>ciao<br><span class="sg">Zameer</span><div><span class="e" id="q_1135432ce468ccf1_2">
<br><br><div><span class="gmail_quote">On 6/22/07, 
<b class="gmail_sendername">Zameer Rehmani</b> &lt;<a href="mailto:zrehmani at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">zrehmani at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

I think what Tim means is that when you get the basic event in the ui from the model; from within the event handler method in your ui, you can pull the data from the model via its accessor method.<br><br>So here is the model:
<br>public function onChange():Void<br>{<br>&nbsp;&nbsp;&nbsp; _oEB.broadcastEvent( new BasicEvent( new EventType( &quot;onChange&quot;)) );<br>}<br><br>//Accessor Methods<br>public function setID( nID:Number ):Void<br>{<br>&nbsp; _nID = nID;
<br>&nbsp; onChange();<br>}<br>public function getID():Number<br>{<br>&nbsp; return _nID;<br>}<br><br>in the ui listening to the model you have your event handler method:<br>public function onChange(e:IEvent):Void<br>{<br>&nbsp; var nID:Number = BasicEvent(e).getTarget().getID;
<br>}<br><br>This is I guess one way to use it.&nbsp; This would be the &quot;pull&quot; method;&nbsp; I agree with Tim, Push method is more flexible and efficient.<br>Hope I don&#39;t have any syntax errors there, but you will get the idea.
<br><span><br>Zameer</span><div><span><br><br><div><span class="gmail_quote">On 6/22/07, <b class="gmail_sendername">quinrou .</b> &lt;<a href="mailto:quinrou at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

quinrou at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Tim,<br><br>I don&#39;t understand that :<span><br>&quot;Instead, use a reference to the target of the event, and an accessor method at the object that broadcast the event.&quot;<br></span>can you illustrate it with a code snipset?
<br>
<br>This is an interesting concept, would be able to give a code snipset as well of that &quot;pull&quot; method?<br><br>many thanks<div><span><br><br><br><br><br><br><div><span class="gmail_quote">
On 6/22/07, <b class="gmail_sendername">
Tim Will</b> &lt;<a href="mailto:thedigitalartist at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">thedigitalartist at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



Hey there,<br>If you want to use basic event, you can do it..but don&#39;t cast the data.&nbsp; Instead, use a reference to the target of the event, and an accessor method at the object that broadcast the event.<br>This is called the &#39;pull&#39; method of broadcasting.
<br>But I think when you get used to it you will find the &#39;push&#39; method described above to be easier and more efficient.<br>Nice description there, btw.<br><span><br>-tim.</span><div><span>
<br><br><div><span class="gmail_quote">On 6/21/07, 
<b class="gmail_sendername">quinrou .</b> &lt;<a href="mailto:quinrou at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">quinrou at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




aaah ok i am with you thx for the detailed reply.<br>I always use the BasicEvent and cast data when it get to the other side. I guess using this specific events avoid making mistake with the type of data that you need to circulate.
<br><br>thanks very much<div><span><br><br><div><span class="gmail_quote">On 6/21/07, <b class="gmail_sendername">thomas mery</b> &lt;<a href="mailto:thomas.mery at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">




thomas.mery at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
hi,<br><br>You can use these events when you need to use a Number or a String as the information you&#39;ll be using in your event handler function.<br><br>for instance<br><br>if I have a View that will respond to a model broadcasting an event and what I need to use in my view is a Number I will use in my model: 
<br><br>_oEB.broadcastEvent(new NumberEvent(myEventTypeEVENT, theNumberIneedInMyView));<br><br>given my view is listening to this model&#39;s event<br><br>if I need to get an id from a model for instance : <br><br><span style="font-weight: bold;">






//in my model </span><br><br>public static var onGetQuestionIdEVENT:EventType = new EventType(&quot;onGetQuestionIdEVENT&quot;);<br><br>public function getQuestionId() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; _oEB.broadcastEvent(new NumberEvent(onGetQuestionIdEVENT,&nbsp; 1234586 ));//the number&nbsp; would be dynamic here but I put a hard coded number for the example
<br>&nbsp;&nbsp;&nbsp; <br>}<br><br style="font-weight: bold;"><span style="font-weight: bold;">//somewhere make the view listen to the event<br><br></span>myModel.addEventListener(MY_MODEL_CLASS.onGetQuestionIdEVENT, myView, myView.onGetQuestionId






);<br><br><span style="font-weight: bold;">//in my view (listening to my model)<br><br></span>public function onGetQuestionId( e : NumberEvent ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //trace the number with the getNumber method of the NumberEvent instance
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PixlibDebug.INFO(&quot; this is the number i receive : &quot; + e.getNumber());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>}<br><br>same with a case where you need a string as the main info being broadcasted but then use StringEvent<br>





<br>
to me pixlib events are like packets with specific infos being wrapped in them<br>and specific functions to retrieve those infos<br><br>you know what you send and you know what you receive<br><br>if you need specific infos =&gt; create your own events extending BasicEvent
<br><br>that&#39;s how I understand it the best<br><br>hope it helps<br>and please anyone correct me if something&#39;s wrong<br><br>thomas<div><span><br><br><br><div><span class="gmail_quote">
On 6/21/07, <b class="gmail_sendername">
quinrou .</b> &lt;<a href="mailto:quinrou at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">quinrou at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">






Hi,<br><br>I have seen those classes in the framework i.e. NumberEvent, StringEvent but I have no idea to when and to use them.<br><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Can anyone shine any light? 
<br><br>thanks<br></span></font><br><div><span class="gmail_quote">On 6/20/07, <b class="gmail_sendername">Pedro Taranto</b> &lt;<a href="mailto:ptaranto at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">






ptaranto at gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
that is the point, let&#39;s wait the next revision<br><span><br>--Pedro Taranto</span><div><span><br><br><br><div><span class="gmail_quote">On 6/20/07, <b class="gmail_sendername">
Zameer Rehmani</b> &lt;<a href="mailto:zrehmani at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">zrehmani at gmail.com
</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Pedro,<br>You can also extend the basic event to create your own events.&nbsp; But I understand what you are saying; if you just want to send an array or movieclip, why not have a few more basic events that do just that by definition like point and number.&nbsp; It&#39;s francis call :)
<br>Zameer<br><br><div><div><span><span class="gmail_quote">On 6/19/07, <b class="gmail_sendername">Pedro Taranto</b> &lt;<a href="mailto:ptaranto at gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">








ptaranto at gmail.com</a>&gt; wrote:</span></span></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span>

this one is for Francis<br><br>as the Pixlib already provide the events for the basic types (Boolean,<br>Number, String and Point), it should provide an ArrayEvent too and maybe<br>more basics events for Date, MovieClip and TextField.
<br><br>--Pedro Taranto<br><br></span></div>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">








Pixlib at osflash.org</a><br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br></blockquote></div><br>
<br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a><br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">








http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a>






<br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
<br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a><br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">






http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br><br clear="all"><br></span></div><span>-- <br>----------------------------------------------------------<br><a href="http://www.myspace.com/thomasmery" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">






http://www.myspace.com/thomasmery</a><br><a href="http://www.thomas-mery.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.thomas-mery.net</a><br>----------------------------------------------------------
</span><br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a><br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">





http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a>



<br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a>


<br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>Pixlib mailing list<br><a href="mailto:Pixlib at osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Pixlib at osflash.org</a>

<br><a href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>
</span></div></blockquote></div><br>
</span></div><br>_______________________________________________<br>Pixlib mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Pixlib at osflash.org">Pixlib at osflash.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://osflash.org/mailman/listinfo/pixlib_osflash.org" target="_blank">
http://osflash.org/mailman/listinfo/pixlib_osflash.org</a><br><br></blockquote></div><br>

_______________________________________________
Pixlib mailing list
Pixlib at osflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org



More information about the Pixlib mailing list