Not sure why your change event isn't getting fired; try doing 2 things: - in Flash, when you associate the ActionScript class to a movie clip, put a copy of the UIComponent on frame 2 with a stop(); action on frame 1 to prevent it from ever getting to frame 2. - change your code from:
dispatchEvent({type: "change"}); to: dispatchEvent({type: "change", target: this}); ----- Original Message ----- From: "Ketan Bengali" <[EMAIL PROTECTED]> To: <flexcoders@yahoogroups.com> Sent: Thursday, March 31, 2005 2:10 AM Subject: Re: [flexcoders] Using Components in Flash Let me put my question in a different way. The code that I posted in earlier mail doesnt fire the change event On the change event of the component in the flash app nothing happens. I am able to capture the value on the click of a button but I want to capture that value on the click of the component. Any idea ?? Regards, Ketan Bengali. Scott Barnes wrote: >I can't see anything below that will prevent you from using it inside FLASH >IDE. > >You can do one of two things. > >1) You can copy your assets/code into FLASH IDE, and make a component >that way by cutting and pasting + importing assets. That based on what >i've seen below would work out ok as the mx.framework is very >similiar in its design with FLASH IDE... i'd only flag things if you >used flex specific components like Panel etc... > >2) Take your FLEX MXML and using the compc compile it to a SWC file, >then copy it to your Flash IDE Program Files - again since your using >the basics of the framework you should be right. I think when you use >your component, FLASH IDE will tell its compiler to load the FLASH MX >2004 framewor as opposed to the FLEX version (thats if you have >FlexForFlash installed inside your ide...if you haven't then ignore >the above and just compile your mxml to a swc and use it like that) > >Under the Flash Docs, do a serach for "Creating SWC files" it will >give you a step by step how to. > >Other than that, I'm not sure what else is doable. > > >On Thu, 31 Mar 2005 11:13:26 +0530, Ketan Bengali <[EMAIL PROTECTED]> >wrote: > > >>Heres the code i have in my as file: >> >>import mx.controls.* >>import mx.core.UIObject >>import mx.events.EventDispatcher >>[Event("change")] >>[Event("click")] >> >>class CineRating extends mx.core.UIObject { >> >> static var symbolName:String = "CineRating"; >> static var symbolOwner:Object = CineRating; >> var className:String = "CineRating"; >> >> private var _rating:Number; >> >> private var starsCount:Number = 5; >> var movieRS:MovieClip; >> var _starNumber:Number; >> >> function CineRating() {} >> >> function init() { >> super.init(); >> movieRS._visible = true; >> } >> >> public function set rating(nRating:Number):Void { >> if(nRating%2 != 0 || nRating%2 != 1) { >> if(nRating - Math.floor(nRating) > 0 && nRating - >>Math.floor(nRating) < 0.5) { >> nRating = Math.floor(nRating) >> } else { >> nRating = Math.ceil(nRating); >> } >> } >> >> this._rating = nRating; >> invalidate(); >> //draw(); >> dispatchEvent({type: "change"}); >> } >> >> public function draw() { >> >> if(!_parent["star"+(starsCount-1)]) { >> >> for(var i:Number = 0; i < starsCount;i++) { >> this.movieRS.duplicateMovieClip("star"+i, i+1); >> this["star"+i]._x = i * this["star"+i]._width/0.95; >> this["star"+i].starNumber = i; >> >> if(i < _rating) { >> this["star"+i].gotoAndStop("select"); >> } >> else { >> this["star"+i].gotoAndStop("default"); >> } >> >> /* RollOver Event Declaration */ >> >> this["star"+i].onRollOver = function() { >> >> // mx.controls.Alert.show("Inside RollOver") >> >> var tname:Number; >> tname = this._name.charAt(this._name.length - 1); >> >> //mx.controls.Alert.show(); >> if(tname <= (_parent._rating - 1)) >> return; >> >> if(tname > _parent._rating - 1) { >> for(var k:Number = _parent._rating; k <= tname; >>k++) { >> var myStar = eval(_parent + "." + "star" + k); >> >> myStar.gotoAndStop("hover"); >> } >> } >> } >> >> /* RollOut Event Declaration */ >> >> this["star"+i].onRollOut = function() { >> var tname:Number; >> tname = Number(this._name.charAt(this._name.length - >>1)); >> >> if(tname <= (_parent._rating - 1)) { >> return; >> } >> >> for(var j:Number = _parent._rating; j < >>_parent.starsCount; j++) { >> var myStar = eval(_parent + "." + "star" + j); >> myStar.gotoAndStop("default"); >> } >> } >> >> /* Press Event Declaration */ >> >> this["star"+i].onPress = function() { >> var tname:Number; >> tname = Number(this._name.charAt(this._name.length - >>1)); >> >> if(tname == ((_parent._rating - 1 < 0)?0: >>_parent._rating - 1)) { >> return; >> } >> >> if(tname > (_parent._rating-1)) { >> for(var x:Number = ((_parent._rating-1)<0)?0: >>_parent._rating-1;x <= tname; x++) { >> var myStar = eval(_parent + "." + "star" + x); >> myStar.gotoAndStop("select"); >> _parent._rating = x+1; >> _parent._starNumber = _parent._rating; >> //mx.controls.Alert.show("_parent._rating = >>" + _parent._rating); >> _parent.dispatchEvent({type: "change"}); >> _parent.dispatchEvent({type: "click"}); >> } >> } else { >> for(var x:Number = _parent._rating - 1;x > >>tname; x--) { >> var myStar = eval(_parent + "." + "star" + x); >> myStar.gotoAndStop("default"); >> _parent._rating--; >> _parent._starNumber = _parent._rating; >> _parent.dispatchEvent({type: "change"}); >> _parent.dispatchEvent({type: "click"}); >> } >> } >> } >> >> } >> >> } >> } >> >> [ChangeEvent("change")] >> public function get rating():Number { >> return this._rating; >> } >>} >> >>Regards, >> >>Ketan Bengali >> >>Scott Barnes wrote: >> >> >> >>>Not sure on how you built your rating component but first hing popped >>>in my head was to make sure you don't use the default v2 framework >>>that comes with Flash MX 2004 when you compile your app, but instead >>>make sure it points to the FlexForFlash framework... >>> >>>(ie under ActionScript 2.0 settings just change the ordering). >>> >>> >>> >>> >>>On Thu, 31 Mar 2005 10:43:05 +0530, Ketan Bengali <[EMAIL PROTECTED]> >>>wrote: >>> >>> >>> >>> >>>>Hi All, >>>> >>>>I had made a rating component in Flash MX 2004 to be used in Flex >>>>and it works fine. >>>> >>>>What if I have to use the same component in one of my Flash apps. >>>>I tried using that component in my app. It works but am not able >>>>to get the rating value in the flash app the way I was getting in >>>>my Flex app. >>>> >>>>Can anybody throw some light on this? >>>>Do I need to change anything somewhere so that I can use >>>>the same component in my Flash app. >>>> >>>>Thanks >>>> >>>>-- >>>>Regards, >>>> >>>>Ketan Bengali >>>> >>>> >>>>Yahoo! Groups Links >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>Yahoo! Groups Links >> >> >> >> >> >> >> > > > > Yahoo! Groups Links Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/