Hi Abdul,
Thanks a lot for giving breif description on "dispatchEvent".
One more doubt in this, we declared event before imprting specific classes.
Why is it so? I tried doing it in class, but not successfull.
What is the reason?
And at the same time, creating a pure UIComponent in Flasg is a bit different from that in FLex??
Dont we use addEventListener in flex?
Thanks a lot to one and all.
Regards,
Ram
Look at the following code to figure out what you need to do:-<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script>
<![CDATA[
function fun(){
mx.controls.Alert.show("Event dispatched!")
}
]]>
</mx:Script>
<circle xmlns:circle="*" cirPress="fun() "/></mx:Application>
// ActionScript Document[Event("cirPress")]
import mx.core.UIComponent
class circle extends UIComponent{
[Embed(source="cir_sym.swf",symbol="cir_sym")]
var cir_sym:String;
var obj:Object
function circle(){
}
function init():Void{
super.init();
}
function draw():Void{
super.draw();
}
function createChildren():Void{
obj = attachMovie("cir_sym","cir_sym",1);
}
function onPress():Void{
dispatchEvent({type:"cirPress"})
}
}
From: [email protected] [mailto: [email protected]] On Behalf Of Ramu p
Sent: Tuesday, October 18, 2005 4:32 AM
To: [email protected]
Subject: [flexcoders] Is it the right way of using dispatchEvent?
Hi Flex coders,Thanks a lot to all group people for solving my problem on "Issue on Accordion reference".I am stuck up with one more problem.Here is the problem,I have a simple mxml file which uses a component(circle.as) , extends UIComponent.OnPress of this circle I want to invoke a method that user has provided.i.e, I included "circle" component in my xmxl in the following way.<circle xmlns:circle="*" cirPress="fun"/>So here "circle" is an as component which has cirPress event which has to invoke fun method in mxml file.Here is the code of mxml file://**************************************************************************<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script>
<![CDATA[
function fun(){
mx.controls.Alert.show("Event dispatched!")
}
]]>
</mx:Script>
<circle xmlns:circle="*" cirPress="fun"/></mx:Application>
//**************************************************************************
Here is component (circle.as)
//**************************************************************************
// ActionScript Document
import mx.core.UIComponent
import mx.utils.Delegate
import mx.events.*
class circle extends UIComponent{
public var dispatchEvent:Function
[Embed(source="cir_sym.swf",symbol="cir_sym")]
var cir_sym:String;
var obj:Object
var cirPress
function circle(){
}
function init():Void{
super.init();
EventDispatcher.initialize(this);
}
function draw():Void{
super.draw();
}
function createChildren():Void{
obj = attachMovie("cir_sym","cir_sym",1);
addEventListener("cirPressed",Delegate.create(this,tempFun))
}
function tempFun(){
eval("_root."+cirPress).call()
}
function onPress():Void{
dispatchEvent({type:"cirPressed"})
}
}//**************************************************************************
Here the above works well!!!But problem is I shouldnt use "_root." to invoke the method! (coz method my be in a class/somewhere. So everytime method may not be in root)And please suggest me, is it the right way of using dispatchEvent()?I really appreciate one's help on "how to use dispatchEvent in appropriate way".Thanks in advance!Regards,Ramu
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

