RE: [flexcoders] Is it the right way of using dispatchEvent?

2005-10-20 Thread Abdul Qabiz





Hi,

We declared a metadata before class defination. If compiler 
while parsing MXML code sees it, it generates the required actionscript code for 
you, which you had to do yourself in Flash.

Not sure, why isn't it workin for you? Can you post the 
code.

Any component extending UIComponent has event dispatching 
capablity. 

Making components in Flex is much easier than making in 
Flash authoring.


-abdul


From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Ramu pSent: 
Tuesday, October 18, 2005 10:20 PMTo: 
flexcoders@yahoogroups.comSubject: Re: [flexcoders] Is it the right 
way of using dispatchEvent?

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
On 10/19/05, Abdul 
Qabiz [EMAIL PROTECTED] wrote: 

  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:Scriptcircle xmlns:circle="*" 
  cirPress="fun() "/ 
  /mx:Application
  
  
  // ActionScript Document
  [Event("cirPress")]import 
  mx.core.UIComponentclass circle extends UIComponent
  {[Embed(source="cir_sym.swf",symbol="cir_sym")] 
  var cir_sym:String;var 
  obj:Objectfunction 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: flexcoders@yahoogroups.com [mailto: 
  flexcoders@yahoogroups.com] On Behalf Of Ramu pSent: 
  Tuesday, October 18, 2005 4:32 AMTo: flexcoders@yahoogroups.comSubject: [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:Scriptcircle xmlns:circle="*" 
  cirPress="fun"/ 
  /mx:Application
  //**
  Here is component (circle.as)
  //**
  // ActionScript Documentimport mx.core.UIComponentimport 
  mx.utils.Delegateimport mx.events.*class circle extends 
  UIComponent{public var 
  dispatchEvent:Function[Embed(source="cir_sym.swf",symbol="cir_sym")] 
  var cir_sym:String;var 
  obj:Objectvar cirPressfunction 
  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 ListFAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt 
  Search Archives: http://www.mail-archive.co

Re: [flexcoders] Is it the right way of using dispatchEvent?

2005-10-19 Thread Ramu p



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
On 10/19/05, Abdul Qabiz [EMAIL PROTECTED] wrote:

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:Scriptcircle xmlns:circle=* cirPress=fun()
/ 
/mx:Application


// ActionScript Document
[Event(cirPress)]import mx.core.UIComponentclass circle extends UIComponent
{[Embed(source=cir_sym.swf,symbol=cir_sym)] var cir_sym:String;var obj:Objectfunction 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: flexcoders@yahoogroups.com [mailto:
flexcoders@yahoogroups.com] On Behalf Of Ramu pSent: Tuesday, October 18, 2005 4:32 AMTo: 
flexcoders@yahoogroups.comSubject: [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:Scriptcircle xmlns:circle=* cirPress=fun/ 
/mx:Application
//**
Here is component (circle.as)
//**
// ActionScript Documentimport mx.core.UIComponentimport mx.utils.Delegateimport mx.events.*class circle extends UIComponent{public var dispatchEvent:Function[Embed(source=cir_sym.swf,symbol=cir_sym)] 
var cir_sym:String;var obj:Objectvar cirPressfunction 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 ListFAQ: 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








  
  
SPONSORED LINKS
  
  
  

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.



  









[flexcoders] Is it the right way of using dispatchEvent?

2005-10-18 Thread Ramu p



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:Scriptcircle xmlns:circle=* cirPress=fun/ 

/mx:Application
//**
Here is component (circle.as)
//**
// ActionScript Documentimport mx.core.UIComponentimport mx.utils.Delegateimport mx.events.*class circle extends UIComponent{public var dispatchEvent:Function[Embed(source=cir_sym.swf,symbol=cir_sym)] 
var cir_sym:String;var obj:Objectvar cirPressfunction 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








  
  
SPONSORED LINKS
  
  
  

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.



  









RE: [flexcoders] Is it the right way of using dispatchEvent?

2005-10-18 Thread Abdul Qabiz





Hi,

When you extend UIComponent, it comes with event 
dispatching capabilities. So you don't need to use 
EventDispatcher.initialize(this) kind of mixin.

You need to add [Event("eventName")] metadata in your 
class/component and just use dispatchEvent(..) method directly. No need to use 
Delegate inside your class, compile generates the code for you with right 
scope.

Also you don't need to execute the event-handlers in your 
code by getting the reference of event-handler. Everything is done 
automatically...

Check out following link to see how to dispatch event 
correctly. You probably need to less code that you write than you write 
pure Flash becauseFlex makes your life little easier 
:)

http://livedocs.macromedia.com/flex/15/flex_docs_en/0985.htm

If you still have any problem, let us 
know.

-abdul




From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Ramu pSent: 
Tuesday, October 18, 2005 4:32 AMTo: 
flexcoders@yahoogroups.comSubject: [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:Scriptcircle xmlns:circle="*" 
cirPress="fun"/ 
/mx:Application
//**
Here is component (circle.as)
//**
// ActionScript Documentimport mx.core.UIComponentimport 
mx.utils.Delegateimport mx.events.*class circle extends 
UIComponent{public var 
dispatchEvent:Function[Embed(source="cir_sym.swf",symbol="cir_sym")] 
var cir_sym:String;var 
obj:Objectvar cirPressfunction 
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








  
  
SPONSORED LINKS
  
  
  

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.



  









RE: [flexcoders] Is it the right way of using dispatchEvent?

2005-10-18 Thread Abdul Qabiz





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:Scriptcircle xmlns:circle="*" 
cirPress="fun()"/ 
/mx:Application


// ActionScript Document
[Event("cirPress")]import 
mx.core.UIComponentclass circle extends UIComponent
{[Embed(source="cir_sym.swf",symbol="cir_sym")] 
var cir_sym:String;var 
obj:Objectfunction 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: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Ramu pSent: 
Tuesday, October 18, 2005 4:32 AMTo: 
flexcoders@yahoogroups.comSubject: [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:Scriptcircle xmlns:circle="*" 
cirPress="fun"/ 
/mx:Application
//**
Here is component (circle.as)
//**
// ActionScript Documentimport mx.core.UIComponentimport 
mx.utils.Delegateimport mx.events.*class circle extends 
UIComponent{public var 
dispatchEvent:Function[Embed(source="cir_sym.swf",symbol="cir_sym")] 
var cir_sym:String;var 
obj:Objectvar cirPressfunction 
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.