Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
If you really like this auto-button trick, check out my JSFL script which automates the process of making them. http://www.stevensacks.net/2008/02/01/using-jsfl-to-create-auto-buttons-in-flash/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Thanks! I had given up on using the _up, _over, _down mc-button method in as3 because of that flicker. Your explaination and solution make perfect sense. jimbo *** REPLY SEPARATOR *** On 3/1/2008 at 9:08 PM Joseph Balderson wrote: Just found this thread while trying to work this out myself. I have tried the same technique as discused here, and my button was flickering too, until I discovered that it's because of the event bubbling and regarding child objects as buttons themselves. What you need to do is set btn_mc.mouseChildren = false; ...and the flickering is solved. When I turned that on I didn't need to use addChild, which I never quite understood the rationale anyways since my movie clip button is already on the timeline. Here's what I have: btn_mc.addEventListener(MouseEvent.CLICK,clickHandler); btn_mc.buttonMode = true; btn_mc.mouseChildren = false; function clickHandler(evtObj:MouseEvent):void { trace(button clicked!); } On my button timeline I have _up, _over, _down frames, plus a few custom states, and each state frame has a movie clip with several child movie clips in turn. You might also encounter flickering if your over and up states are of different sizes, in which case you should define an alpha 0 movie clip containing the hit shape of the button on the bottom layer spanning all frames, and in the code include btn_mc.hitArea = hit_mc; Worked for me. ___ Joseph Balderson, Flash Platform Developer | http://joeflash.ca Writing partner, Community MX | http://www.communitymx.com Abobe Certified Developer Trainer Jim Berkey wrote: Fuomo, One more question, if you have the inclination . . . I put the statement on each frame of the button mc, and it works as expected, but as I mouse over the shape, there is a flicker between the up state to the over state - I thought it might be that part of the graphic was transparent and losing focus, but that is not the case? http://jimbo.us/lab/FinalAssets3.fla http://jimbo.us/lab/FinalAssets3.swf jimbo *** REPLY SEPARATOR *** On 6/28/2007 at 9:48 PM Fumio Nonaka wrote: When the statement you put is processed the play head in the btn_play instance is in the first frame, in which the over_mc instance does not exist. This is what the error tells you. Therefore InteractiveObject.mouseEnabled for over_mc cannot be set. trace(btn_play.over_mc); // Output: null The statement should be placed in the second frame of the btn_play, or inside the over_mc itself. _ Jim Berkey wrote: Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Just found this thread while trying to work this out myself. I have tried the same technique as discused here, and my button was flickering too, until I discovered that it's because of the event bubbling and regarding child objects as buttons themselves. What you need to do is set btn_mc.mouseChildren = false; ...and the flickering is solved. When I turned that on I didn't need to use addChild, which I never quite understood the rationale anyways since my movie clip button is already on the timeline. Here's what I have: btn_mc.addEventListener(MouseEvent.CLICK,clickHandler); btn_mc.buttonMode = true; btn_mc.mouseChildren = false; function clickHandler(evtObj:MouseEvent):void { trace(button clicked!); } On my button timeline I have _up, _over, _down frames, plus a few custom states, and each state frame has a movie clip with several child movie clips in turn. You might also encounter flickering if your over and up states are of different sizes, in which case you should define an alpha 0 movie clip containing the hit shape of the button on the bottom layer spanning all frames, and in the code include btn_mc.hitArea = hit_mc; Worked for me. ___ Joseph Balderson, Flash Platform Developer | http://joeflash.ca Writing partner, Community MX | http://www.communitymx.com Abobe Certified Developer Trainer Jim Berkey wrote: Fuomo, One more question, if you have the inclination . . . I put the statement on each frame of the button mc, and it works as expected, but as I mouse over the shape, there is a flicker between the up state to the over state - I thought it might be that part of the graphic was transparent and losing focus, but that is not the case? http://jimbo.us/lab/FinalAssets3.fla http://jimbo.us/lab/FinalAssets3.swf jimbo *** REPLY SEPARATOR *** On 6/28/2007 at 9:48 PM Fumio Nonaka wrote: When the statement you put is processed the play head in the btn_play instance is in the first frame, in which the over_mc instance does not exist. This is what the error tells you. Therefore InteractiveObject.mouseEnabled for over_mc cannot be set. trace(btn_play.over_mc); // Output: null The statement should be placed in the second frame of the btn_play, or inside the over_mc itself. _ Jim Berkey wrote: Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Adam, Your button works with your assets . . . if you change all of the graphic elements from 'movie clips' on your _up, _over and _down frames to 'graphic' Type - both in the library and above the instance name in the properties panel when selected on stage. Grouping is all right, but no mc can be in any of the frames. With Flash 8 many gurus saw little need for the 'graphic' type, and everything, even graphics, became a movie clip. Now it seems that the lowly 'graphic' type has it's place in a much stricter Actionscript 3. My only query is . . . for the over state, now I cannot design a whiz-bang graphic tween - since it would need to be held in a movie clip container instead of a graphic container? http://jimbo.us/lab/FinalAssets.fla http://jimbo.us/lab/FinalAssets.swf jimbo *** REPLY SEPARATOR *** On 6/27/2007 at 9:22 AM Adam Pasztory wrote: Jim, The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. This works in AS2, but not AS3, so I'm thinking it's a bug in Flash. On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: funny, mine does . . . your setup looks the same? http://jimbo.us/lab/buttonAs3.fla http://jimbo.us/lab/buttonAs3.swf *** REPLY SEPARATOR *** On 6/27/2007 at 8:39 AM Adam Pasztory wrote: Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Fumio, Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() What code to I need to allow a mc to be on one of the frames? http://jimbo.us/lab/FinalAssets2.fla jimbo *** REPLY SEPARATOR *** On 6/28/2007 at 9:33 AM Fumio Nonaka wrote: This works in ActionScript 3.0, too. You should use Graphic instances for your button's states. Otherwise, set the InteractiveObject.mouseEnabled properties of MovieClips for each state to false. _ Adam Pasztory wrote: The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
When the statement you put is processed the play head in the btn_play instance is in the first frame, in which the over_mc instance does not exist. This is what the error tells you. Therefore InteractiveObject.mouseEnabled for over_mc cannot be set. trace(btn_play.over_mc); // Output: null The statement should be placed in the second frame of the btn_play, or inside the over_mc itself. _ Jim Berkey wrote: Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Thanks Fumio, Works like a charm!! jimbo *** REPLY SEPARATOR *** On 6/28/2007 at 9:48 PM Fumio Nonaka wrote: When the statement you put is processed the play head in the btn_play instance is in the first frame, in which the over_mc instance does not exist. This is what the error tells you. Therefore InteractiveObject.mouseEnabled for over_mc cannot be set. trace(btn_play.over_mc); // Output: null The statement should be placed in the second frame of the btn_play, or inside the over_mc itself. _ Jim Berkey wrote: Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Fuomo, One more question, if you have the inclination . . . I put the statement on each frame of the button mc, and it works as expected, but as I mouse over the shape, there is a flicker between the up state to the over state - I thought it might be that part of the graphic was transparent and losing focus, but that is not the case? http://jimbo.us/lab/FinalAssets3.fla http://jimbo.us/lab/FinalAssets3.swf jimbo *** REPLY SEPARATOR *** On 6/28/2007 at 9:48 PM Fumio Nonaka wrote: When the statement you put is processed the play head in the btn_play instance is in the first frame, in which the over_mc instance does not exist. This is what the error tells you. Therefore InteractiveObject.mouseEnabled for over_mc cannot be set. trace(btn_play.over_mc); // Output: null The statement should be placed in the second frame of the btn_play, or inside the over_mc itself. _ Jim Berkey wrote: Can you explain using' InteractiveObject.mouseEnabled' to allow a mc inside a mc acting as a button a little more? I have a mc called button_play, with the three frames (_up, _over, and _down), in the over frame, instead of a graphic, I placed a mc, gave it instance name over_mc, and on the main timeline, put: btn_play.over_mc.mouseEnabled = false; I got this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at FinalAssets2_fla::MainTimeline/FinalAssets2_fla::frame1() Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Have a look at the AS3 components: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/BaseButton.html http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/Button.html - Original Message - From: Adam Pasztory [EMAIL PROTECTED] To: Flashcoders@chattyfig.figleaf.com Sent: Wednesday, June 27, 2007 6:40 AM Subject: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3 In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
One way to instantiate a mc as a button in as3 is: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } jimbo *** REPLY SEPARATOR *** On 6/26/2007 at 9:40 PM Adam Pasztory wrote: In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Thanks Jim, I've set up the AS3 event handler as you've specified, and it does change the cursor from an arrow to a pointer, but the _up, _down and _over states don't work. I pasted the same button symbol into an AS2 FLA file, and it does work, so there isn't anything wrong with the way I've set my frame labels in the button symbol. According to the docs, it should work in AS3: If you use the buttonMode property with the MovieClip class (which is a subclass of the Sprite class), your button might have some added functionality. If you include frames labeled _up, _over, and _down, Flash Player provides automatic state changes (functionality similar to that provided in previous versions of ActionScript for movie clips used as buttons). Can anyone else get this working in AS3??? On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: One way to instantiate a mc as a button in as3 is: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } jimbo *** REPLY SEPARATOR *** On 6/26/2007 at 9:40 PM Adam Pasztory wrote: In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Yes, I can find nothing in as3 docs about support for that shortcut (_up,_over, _down frame labels). The buttonMode=true only affects the cursor - changes it from pointer to hand. afaik, you need to set functions for each event - possible mouse events include: CLICK DOUBLE_CLICK MOUSE_DOWN MOUSE_MOVE MOUSE_OUT MOUSE_OVER MOUSE_UP MOUSE_WHEEL ROLL_OUT ROLL_OVER So I think you need to do this: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } my_btn.addEventListener(MouseEvent.ROLL_OVER, myOverFunction); function myOverFunction(event:MouseEvent):void { //do something } my_btn.addEventListener(MouseEvent.ROLL_OUT, myOutFunction); function myOutFunction(event:MouseEvent):void { //do something } I'd love to learn otherwise, though. Of course, using the simple button component avoids this, maybe you could just skin it to your liking? All of the button states are separate editable mc's in the library. jimbo *** REPLY SEPARATOR *** On 6/27/2007 at 6:24 AM Adam Pasztory wrote: Thanks Jim, I've set up the AS3 event handler as you've specified, and it does change the cursor from an arrow to a pointer, but the _up, _down and _over states don't work. I pasted the same button symbol into an AS2 FLA file, and it does work, so there isn't anything wrong with the way I've set my frame labels in the button symbol. According to the docs, it should work in AS3: If you use the buttonMode property with the MovieClip class (which is a subclass of the Sprite class), your button might have some added functionality. If you include frames labeled _up, _over, and _down, Flash Player provides automatic state changes (functionality similar to that provided in previous versions of ActionScript for movie clips used as buttons). Can anyone else get this working in AS3??? On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: One way to instantiate a mc as a button in as3 is: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } jimbo *** REPLY SEPARATOR *** On 6/26/2007 at 9:40 PM Adam Pasztory wrote: In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Hi Adam, Use the sample below for Button instances: import flash.display.SimpleButton; import flash.display.Sprite; var up:Sprite = new Sprite(); up.graphics.beginFill(0x99); up.graphics.drawRect(50, 50, 50, 50); up.graphics.endFill(); var over:Sprite = new Sprite(); over.graphics.beginFill(0xFF); over.graphics.drawRect(50, 50, 50, 50); over.graphics.endFill(); var down:Sprite = new Sprite(); down.graphics.beginFill(0xCC); down.graphics.drawRect(50, 50, 50, 50); down.graphics.endFill(); var hit:Sprite = new Sprite(); hit.graphics.beginFill(0xCC); hit.graphics.drawRect(50, 50, 50, 50); hit.graphics.endFill(); var botao:SimpleButton = new SimpleButton(up); botao.upState = up; botao.overState = over; botao.downState = down; botao.hitTestState = hit; this.addChild(botao); best regards -- Leandro Amano Digital Bug Chief Creative Officer Adobe Certified Expert Adobe Certified Instructor Adobe User Group Leader On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Yes, I can find nothing in as3 docs about support for that shortcut (_up,_over, _down frame labels). The buttonMode=true only affects the cursor - changes it from pointer to hand. afaik, you need to set functions for each event - possible mouse events include: CLICK DOUBLE_CLICK MOUSE_DOWN MOUSE_MOVE MOUSE_OUT MOUSE_OVER MOUSE_UP MOUSE_WHEEL ROLL_OUT ROLL_OVER So I think you need to do this: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } my_btn.addEventListener(MouseEvent.ROLL_OVER, myOverFunction); function myOverFunction(event:MouseEvent):void { //do something } my_btn.addEventListener(MouseEvent.ROLL_OUT, myOutFunction); function myOutFunction(event:MouseEvent):void { //do something } I'd love to learn otherwise, though. Of course, using the simple button component avoids this, maybe you could just skin it to your liking? All of the button states are separate editable mc's in the library. jimbo *** REPLY SEPARATOR *** On 6/27/2007 at 6:24 AM Adam Pasztory wrote: Thanks Jim, I've set up the AS3 event handler as you've specified, and it does change the cursor from an arrow to a pointer, but the _up, _down and _over states don't work. I pasted the same button symbol into an AS2 FLA file, and it does work, so there isn't anything wrong with the way I've set my frame labels in the button symbol. According to the docs, it should work in AS3: If you use the buttonMode property with the MovieClip class (which is a subclass of the Sprite class), your button might have some added functionality. If you include frames labeled _up, _over, and _down, Flash Player provides automatic state changes (functionality similar to that provided in previous versions of ActionScript for movie clips used as buttons). Can anyone else get this working in AS3??? On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: One way to instantiate a mc as a button in as3 is: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } jimbo *** REPLY SEPARATOR *** On 6/26/2007 at 9:40 PM Adam Pasztory wrote: In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com s ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Also, the client just wants the buttons delivered in a simple graphical format, so they can add code later. They don't want me to send them an FLA with a ton of code in it, like in Leandro's example. I would go ahead and just use button symbols, but my problem is that these buttons also have an inactive state, which can be represented by a SimpleButton object. In AS2, I just would have added an _inactive frame to the button. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
According to the docs, it *is* supported. http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Sprite.html#buttonMode If you use the buttonMode property with the MovieClip class (which is a subclass of the Sprite class), your button might have some added functionality. If you include frames labeled _up, _over, and _down, Flash Player provides automatic state changes (functionality similar to that provided in previous versions of ActionScript for movie clips used as buttons). Yeah, I could use a component, but I don't think the client is going to want that... And we're trying to keep the file size minimal. It would be really annoying if they took out this simple and useful feature. :( ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo *** REPLY SEPARATOR *** On 6/27/2007 at 7:14 AM Adam Pasztory wrote: Also, the client just wants the buttons delivered in a simple graphical format, so they can add code later. They don't want me to send them an FLA with a ton of code in it, like in Leandro's example. I would go ahead and just use button symbols, but my problem is that these buttons also have an inactive state, which can be represented by a SimpleButton object. In AS2, I just would have added an _inactive frame to the button. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
funny, mine does . . . your setup looks the same? http://jimbo.us/lab/buttonAs3.fla http://jimbo.us/lab/buttonAs3.swf *** REPLY SEPARATOR *** On 6/27/2007 at 8:39 AM Adam Pasztory wrote: Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com e ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Jim, The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. This works in AS2, but not AS3, so I'm thinking it's a bug in Flash. On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: funny, mine does . . . your setup looks the same? http://jimbo.us/lab/buttonAs3.fla http://jimbo.us/lab/buttonAs3.swf *** REPLY SEPARATOR *** On 6/27/2007 at 8:39 AM Adam Pasztory wrote: Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
Adam, Please, it sees the archive in the URL: www.leandroamano.com.br/files/button_as3.fla best regards On 6/27/07, Adam Pasztory [EMAIL PROTECTED] wrote: Jim, The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. This works in AS2, but not AS3, so I'm thinking it's a bug in Flash. On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: funny, mine does . . . your setup looks the same? http://jimbo.us/lab/buttonAs3.fla http://jimbo.us/lab/buttonAs3.swf *** REPLY SEPARATOR *** On 6/27/2007 at 8:39 AM Adam Pasztory wrote: Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- -- Leandro Amano Digital Bug Chief Creative Officer Adobe Certified Expert Adobe Certified Instructor Adobe User Group Leader ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
You're right. Unfortunately, there are precious few examples in the flash docs for simple designer-type actionscript - it's all Flex type class structure. jimbo *** REPLY SEPARATOR *** On 6/27/2007 at 9:22 AM Adam Pasztory wrote: Jim, The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. This works in AS2, but not AS3, so I'm thinking it's a bug in Flash. On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: funny, mine does . . . your setup looks the same? http://jimbo.us/lab/buttonAs3.fla http://jimbo.us/lab/buttonAs3.swf *** REPLY SEPARATOR *** On 6/27/2007 at 8:39 AM Adam Pasztory wrote: Didn't work. I posted the FLA in case anyone is bored and feels like taking a look: http://www.pasz.com/xfer/FinalAssets.zip On 6/27/07, Jim Berkey [EMAIL PROTECTED] wrote: Hah, yes, it does work, just need to addChild: my_btn.addEventListener(MouseEvent.CLICK, myFunction); my_btn.buttonMode = true; function myFunction(event:MouseEvent):void { //do something } addChild(my_btn); jimbo ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com i ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
This works in ActionScript 3.0, too. You should use Graphic instances for your button's states. Otherwise, set the InteractiveObject.mouseEnabled properties of MovieClips for each state to false. _ Adam Pasztory wrote: The problem seems to be that each of my button states is a MovieClip. In your version, the buttons states are just raw graphics and text the timeline of the button. Do a convert to symbol on your graphics, and change each button state into a MovieClip. The hit areas will no longer work. Good luck, -- Fumio Nonaka mailto:[EMAIL PROTECTED] http://www.FumioNonaka.com/ My bookshttp://www.FumioNonaka.com/Books/index.html Flash communityhttp://F-site.org/ ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] MovieClip Buttons in Flash CS3 ActionScript 3
In ActionScript 2, I never used button symbols. Instead I would create buttons as MovieClips, give the frames of the buttons labels -- _up, _down, _over -- and assign an event handler to them. I tried this in AS3, but it didn't seem to work. Is there some new secret to MovieClip buttons in Flash 9? thanks, Adam ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com