[Flashcoders] [as2] problem with super class on Tweener callback
Hello there! Here's the deal: I have the following class hierarchy MovieClip // adobe - BasicMovieClip // as2lib -- GenericMovieClip --- EventMulticasterMovieClip GenericSection - DropdownSection // abstract class, private constructor -- *Several classes extending DropdownSection That GenericSection is part of a section handling. It has basically two functions: load() and unload(), both public, and they basically dispatch an event, so my section handler can act properly. Ok, so I have several sections who behave almost the same, so I'm writing generic code in DropdownSection, so I can generalize it more cleanly. Here comes the code: When I have this on DropdownSection: public function load():Void { super.load(); } public function unload():Void { super.unload(); } (these are not necessarily needed, but just to clarify) then everything works perfectly, when my section handler calls load() and unload() on any of the classes that extends DropdownSection. However, when I code something like this: public function load():Void { var obj:Object = new Object({ _y: 200, time: 1, onComplete: super.load }); Tweener.addTween(this, obj); } (and the equivalent for the unload() function) * Tweener is Zeh Fernando's tween class - http://code.google.com/p/tweener/ Well, what that does, in the same situation as above, is that when Tweener is done, that very own load() function is called again. I've tried using Delegate, delegating to himself, to the superclass, nothing did it. I've also tried creating a local function that just calls super.load() and delegating to that, but no luck either. My guess at the moment is that it's a side-effect to the weird AS2 implementation of static classes. However I'm curious. Am I doing something completely wrong and not noticing it? Is my implementation flawed? Or there is a way to work that around? Thank you very much for your time! -- Wagner Amaral Agência Ginga - Brazil www.agenciaginga.com.br ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] [as2] problem with super class on Tweener callback
Hey there Zeh! On Tue, Mar 4, 2008 at 12:18 PM, Zeh Fernando [EMAIL PROTECTED] wrote: Hm.. that's a good question. It runs functions inside of the instance using .apply, but if you pass the super.load without wrapping it, I'm sure exactly how the function reference is handled by actionscript. Yeah, I've looked at Tweener's code, even tried to tweak a little bit to see if I could get through it, then I realized it's not Tweener's fault. By issuing a: trace(tScope); on line 754, right before: tTweening.onComplete.apply(tScope, tTweening.onCompleteParams); it traces my current instance correctly. Anyway, have you tried this instead? public function load():Void { var obj:Object = new Object({ _y: 200, time: 1, onComplete: function() { super.load(); } }); Tweener.addTween(this, obj); } Yes, I tried that. Just tried again right now to make sure I wasn't missing anything ;) Still, no success... I've just pasted the code from the superclass inside the onComplete handler (it's just a event dispatch anyway, works for now), but I really hate myself for doing this, specially because this is a refactoring of some old crappy code, and it's supposed to be made the right way. Anyway, still trying to come up with something. (Boy, I really wish the boss would let me use AS3 already, I'm sure these things wouldn't happen. AS2 really isn't made to serious programming) Thanks for the help so far, Zeh! Valeu! -- Wagner Amaral Agência Ginga - Brazil www.agenciaginga.com.br ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] [as2] problem with super class on Tweener callback
I don't have a solution, but I have an arguably less ugly workaround that I've used in similar cases. public class Superclass { public function load():Void { __load(); } protected function __load():Void { // Base class functionality here } } public class Subclass extends Superclass { public function load():Void { Tweener.addTween(this, {onComplete: __load}); } } On 3/4/08, Wagner Amaral [EMAIL PROTECTED] wrote: Hey there Zeh! On Tue, Mar 4, 2008 at 12:18 PM, Zeh Fernando [EMAIL PROTECTED] wrote: Hm.. that's a good question. It runs functions inside of the instance using .apply, but if you pass the super.load without wrapping it, I'm sure exactly how the function reference is handled by actionscript. Yeah, I've looked at Tweener's code, even tried to tweak a little bit to see if I could get through it, then I realized it's not Tweener's fault. By issuing a: trace(tScope); on line 754, right before: tTweening.onComplete.apply(tScope, tTweening.onCompleteParams); it traces my current instance correctly. Anyway, have you tried this instead? public function load():Void { var obj:Object = new Object({ _y: 200, time: 1, onComplete: function() { super.load(); } }); Tweener.addTween(this, obj); } Yes, I tried that. Just tried again right now to make sure I wasn't missing anything ;) Still, no success... I've just pasted the code from the superclass inside the onComplete handler (it's just a event dispatch anyway, works for now), but I really hate myself for doing this, specially because this is a refactoring of some old crappy code, and it's supposed to be made the right way. Anyway, still trying to come up with something. (Boy, I really wish the boss would let me use AS3 already, I'm sure these things wouldn't happen. AS2 really isn't made to serious programming) Thanks for the help so far, Zeh! Valeu! -- Wagner Amaral Agência Ginga - Brazil www.agenciaginga.com.br ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] STEAM/SMOKE
Any smoke /steam particle effects not done in as3 but in aS 2? _ Helping your favorite cause is as easy as instant messaging. You IM, we give. http://im.live.com/Messenger/IM/Home/?source=text_hotmail_join___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Re: AS2 vs. AS3: instantiate library symbols with a loop string concatenation
Sorry - somehow triggered the send mail hotkey before I was finished: On Tue, Mar 4, 2008 at 3:25 PM, jonathan howe [EMAIL PROTECTED] wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1:sym = new sym1(); case 2: sym =new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? Was I doing myself a disservice by using this technique in AS2 anyway? Thanks, -jonathan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] AS2 vs. AS3: instantiate library symbols with a loop string concatenation
Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1: new sym1(); case 2: new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? -- -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] positioning along bezier curve
Thanks everyone, looks great - definitely have some things to go on. That method looks to be exactly what I needed Keith - will look at the other links as well. Jason Merrill Bank of America GTO LLD Solutions Design Development eTools Multimedia Bank of America Flash Platform Developer Community Are you a Bank of America associate interested in innovative learning ideas and technologies? Check out our internal GTO Innovative Learning Blog subscribe. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS2 vs. AS3: instantiate library symbols with a loop string concatenation
for( var i:uint = 0; i30; i++ ) { var sym:MovieClip = new Item(); sym.name = sym+i; someContainer.addChild( sym ); } ... someContainer.getChildAt( nIndex ); etc. On Tue, Mar 4, 2008 at 3:25 PM, jonathan howe [EMAIL PROTECTED] wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1: new sym1(); case 2: new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? -- -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101 ___ 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] Re: AS2 vs. AS3: instantiate library symbols with a loop string concatenation
Hi Jonathon, Your AS2 method is tried and true. Here's the new and improved AS3 way of doing it. for (var i:Number = 0; i 30; i ++) { // build the String name var symbol:String = sym + i; // locate the class var symbolClass:Class = getDefinitionByName(symbol) as Class; // instantiate the clip using the class var new_mc:MovieClip = new symbolClass() as MovieClip; // add clip to stage addChild(new_mc); // do stuff with clip } You may or may not need the as MovieClip bit on the instantiation, depending on how your class is actually defined. hth, Bob jonathan howe wrote: Sorry - somehow triggered the send mail hotkey before I was finished: On Tue, Mar 4, 2008 at 3:25 PM, jonathan howe [EMAIL PROTECTED] wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1:sym = new sym1(); case 2: sym =new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? Was I doing myself a disservice by using this technique in AS2 anyway? Thanks, -jonathan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Thanks, ~ Bob Leisle Headsprout Software Engineering http://www.headsprout.com Where kids learn to read! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Hit Object Question
I think it's a typo but your BdrRep has no rectangle drawn, and even if you did have the rectangle, toggling the alpha of Sprite underneath will not give you any visual feedbacks... Kenneth Kawamoto http://www.materiaprima.co.uk/ anuj sharma wrote: Hi all I am trying to implement hit object in my project. I have sprite class and I am loading multiple instances of UI Loader in my sprite class and displaying it on the main screen. The user can drag and drop those UILoaders on the main stage wherever they want.My aim was that if user drops one UIloader on top of already placed UiLoader, then the already placed UILoader will be replaced with the dropped UILoader. I am successful in implementing that by hitting hitTestObject method. All of my UIloaders are having green color border. Now my requirement is that as soon as the user places UILoader on top of already existing UILoader , the UILoader which is going to be replaced changes border color from green to red showing the user that the UIloader is being replaced and on Mouse release the UiLoader is going to be replaced. In short on mouse over, the border color has to be changed and on mouse release, object has to be replaced. I am adding my rectangle(in Sprite Container) as the border to the UILoader. Below is some code to make things little clearer Please help me in figuring out the problem. Any help will be appreciated. Thanks Anuj /*CODE //UILoader Being Created function CreateUILoaderObject(num:Number):DisplayObject { var myUILoader:UILoader = new UILoader(); var container:Sprite=new Sprite(); myUILoader.name=myUILoader; myUILoader.source = /video/pic_+(num+1)+.swf; myUILoader.load(); //Defining Border for the Selected Camera var ldrBdr:Sprite = new Sprite(); ldrBdr.name = border; ldrBdr.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); //Defining Border for the replaced Camera var BdrRep:Sprite=new Sprite(); BdrRep.name=RepBorder; BdrRep.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); myUILoader.addChild(ldrBdr); myUILoader.addChild(BdrRep); container.addChild(myUILoader); //Enabling Dragging Dropping of Video Loader Anywhere myUILoader.addEventListener(MouseEvent.MOUSE_DOWN,dragUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_UP,dropUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_OVER,showBorder); myUILoader.addEventListener(MouseEvent.MOUSE_OUT,hideBorder); return myUILoader; } //Show the selected Camera with green Border function showBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=1; } function hideBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=0; } //UILoader to be replaced function dropUILoader(e:MouseEvent):void { if(e.targetis UILoader) { var myUILoader:UILoader = e.target as UILoader; if (mouseY746) { myUILoader.stopDrag(); var trackChild:Number=container.getChildIndex(myUILoader); var childContainer:DisplayObject= container.getChildAt (trackChild); for (var z:Number=0; z=container.numChildren-1; z++) { var restChild:DisplayObject=container.getChildAt (z); if ((childContainer!=restChild)( childContainer.hitTestObject(restChild))==true) { container.removeChild(restChild); } } } ___ 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] AS2 vs. AS3: instantiate library symbols with a loop string concatenation
for(var i:uint = 0; i30; i++){ var sym:MovieClip = new (getDefinitionByName(Sym + i) as Class)(); parent_mc.addChild(sym); } Kenneth Kawamoto http://www.materiaprima.co.uk/ jonathan howe wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1: new sym1(); case 2: new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Hit Object Question
Hi Kenneth Thanks for the reply. So what's the solution of my problem? Thanks Anuj On Tue, Mar 4, 2008 at 1:01 PM, Kenneth Kawamoto [EMAIL PROTECTED] wrote: I think it's a typo but your BdrRep has no rectangle drawn, and even if you did have the rectangle, toggling the alpha of Sprite underneath will not give you any visual feedbacks... Kenneth Kawamoto http://www.materiaprima.co.uk/ anuj sharma wrote: Hi all I am trying to implement hit object in my project. I have sprite class and I am loading multiple instances of UI Loader in my sprite class and displaying it on the main screen. The user can drag and drop those UILoaders on the main stage wherever they want.My aim was that if user drops one UIloader on top of already placed UiLoader, then the already placed UILoader will be replaced with the dropped UILoader. I am successful in implementing that by hitting hitTestObject method. All of my UIloaders are having green color border. Now my requirement is that as soon as the user places UILoader on top of already existing UILoader , the UILoader which is going to be replaced changes border color from green to red showing the user that the UIloader is being replaced and on Mouse release the UiLoader is going to be replaced. In short on mouse over, the border color has to be changed and on mouse release, object has to be replaced. I am adding my rectangle(in Sprite Container) as the border to the UILoader. Below is some code to make things little clearer Please help me in figuring out the problem. Any help will be appreciated. Thanks Anuj /*CODE //UILoader Being Created function CreateUILoaderObject(num:Number):DisplayObject { var myUILoader:UILoader = new UILoader(); var container:Sprite=new Sprite(); myUILoader.name=myUILoader; myUILoader.source = /video/pic_+(num+1)+.swf; myUILoader.load(); //Defining Border for the Selected Camera var ldrBdr:Sprite = new Sprite(); ldrBdr.name = border; ldrBdr.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); //Defining Border for the replaced Camera var BdrRep:Sprite=new Sprite(); BdrRep.name=RepBorder; BdrRep.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); myUILoader.addChild(ldrBdr); myUILoader.addChild(BdrRep); container.addChild(myUILoader); //Enabling Dragging Dropping of Video Loader Anywhere myUILoader.addEventListener(MouseEvent.MOUSE_DOWN,dragUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_UP,dropUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_OVER,showBorder); myUILoader.addEventListener(MouseEvent.MOUSE_OUT,hideBorder); return myUILoader; } //Show the selected Camera with green Border function showBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=1; } function hideBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=0; } //UILoader to be replaced function dropUILoader(e:MouseEvent):void { if(e.targetis UILoader) { var myUILoader:UILoader = e.target as UILoader; if (mouseY746) { myUILoader.stopDrag(); var trackChild:Number=container.getChildIndex(myUILoader); var childContainer:DisplayObject= container.getChildAt (trackChild); for (var z:Number=0; z=container.numChildren-1; z++) { var restChild:DisplayObject= container.getChildAt (z); if ((childContainer!=restChild)( childContainer.hitTestObject(restChild))==true) { container.removeChild(restChild); } } } ___ 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: AS2 vs. AS3: instantiate library symbols with a loop string concatenation
import flash.utils.getDefinitionByName; for (var i:uint = 0; i 30; ++i) { var sym:MovieClip = new (getDefinitionByName(sym + i) as Class)(); // rest } On 3/4/08, jonathan howe [EMAIL PROTECTED] wrote: Sorry - somehow triggered the send mail hotkey before I was finished: On Tue, Mar 4, 2008 at 3:25 PM, jonathan howe [EMAIL PROTECTED] wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1:sym = new sym1(); case 2: sym =new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? Was I doing myself a disservice by using this technique in AS2 anyway? Thanks, -jonathan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Hit Object Question
To make your approach work, you can draw a rectangle in ldrBdr and bdrRep (one in red and one in green) and toggle the alpha of one of them sits above the other (if you addChild() it goes above everything already in the display list). Or just change the colour of one border Sprite instead. Kenneth Kawamoto http://www.materiaprima.co.uk/ anuj sharma wrote: Hi Kenneth Thanks for the reply. So what's the solution of my problem? Thanks Anuj On Tue, Mar 4, 2008 at 1:01 PM, Kenneth Kawamoto [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I think it's a typo but your BdrRep has no rectangle drawn, and even if you did have the rectangle, toggling the alpha of Sprite underneath will not give you any visual feedbacks... Kenneth Kawamoto http://www.materiaprima.co.uk/ anuj sharma wrote: Hi all I am trying to implement hit object in my project. I have sprite class and I am loading multiple instances of UI Loader in my sprite class and displaying it on the main screen. The user can drag and drop those UILoaders on the main stage wherever they want.My aim was that if user drops one UIloader on top of already placed UiLoader, then the already placed UILoader will be replaced with the dropped UILoader. I am successful in implementing that by hitting hitTestObject method. All of my UIloaders are having green color border. Now my requirement is that as soon as the user places UILoader on top of already existing UILoader , the UILoader which is going to be replaced changes border color from green to red showing the user that the UIloader is being replaced and on Mouse release the UiLoader is going to be replaced. In short on mouse over, the border color has to be changed and on mouse release, object has to be replaced. I am adding my rectangle(in Sprite Container) as the border to the UILoader. Below is some code to make things little clearer Please help me in figuring out the problem. Any help will be appreciated. Thanks Anuj /*CODE //UILoader Being Created function CreateUILoaderObject(num:Number):DisplayObject { var myUILoader:UILoader = new UILoader(); var container:Sprite=new Sprite(); myUILoader.name=myUILoader; myUILoader.source = /video/pic_+(num+1)+.swf; myUILoader.load(); //Defining Border for the Selected Camera var ldrBdr:Sprite = new Sprite(); ldrBdr.name = border; ldrBdr.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); //Defining Border for the replaced Camera var BdrRep:Sprite=new Sprite(); BdrRep.name=RepBorder; BdrRep.alpha=0; ldrBdr.graphics.lineStyle(2, 0x00ff00); ldrBdr.graphics.drawRect(myUILoader.x+23, myUILoader.y+45, myUILoader.width, myUILoader.height); myUILoader.addChild(ldrBdr); myUILoader.addChild(BdrRep); container.addChild(myUILoader); //Enabling Dragging Dropping of Video Loader Anywhere myUILoader.addEventListener(MouseEvent.MOUSE_DOWN,dragUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_UP,dropUILoader); myUILoader.addEventListener(MouseEvent.MOUSE_OVER,showBorder); myUILoader.addEventListener(MouseEvent.MOUSE_OUT,hideBorder); return myUILoader; } //Show the selected Camera with green Border function showBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=1; } function hideBorder(e:MouseEvent):void { e.target.getChildByName(border).alpha=0; } //UILoader to be replaced function dropUILoader(e:MouseEvent):void { if(e.targetis UILoader) { var myUILoader:UILoader = e.target as UILoader; if (mouseY746) { myUILoader.stopDrag(); var trackChild:Number=container.getChildIndex(myUILoader); var childContainer:DisplayObject= container.getChildAt (trackChild); for (var z:Number=0; z=container.numChildren-1; z++) { var restChild:DisplayObject=container.getChildAt (z); if
Re: [Flashcoders] [as2] problem with super class on Tweener callback
Hello, Cory! That is a nice one, I believe it would work for now! Oh, the wonders AS2 forces you to do... Thanks! -- Wagner Amaral Agência Ginga - Brazil www.agenciaginga.com.br On Tue, Mar 4, 2008 at 3:52 PM, Cory Petosky [EMAIL PROTECTED] wrote: I don't have a solution, but I have an arguably less ugly workaround that I've used in similar cases. public class Superclass { public function load():Void { __load(); } protected function __load():Void { // Base class functionality here } } public class Subclass extends Superclass { public function load():Void { Tweener.addTween(this, {onComplete: __load}); } } On 3/4/08, Wagner Amaral [EMAIL PROTECTED] wrote: Hey there Zeh! On Tue, Mar 4, 2008 at 12:18 PM, Zeh Fernando [EMAIL PROTECTED] wrote: Hm.. that's a good question. It runs functions inside of the instance using .apply, but if you pass the super.load without wrapping it, I'm sure exactly how the function reference is handled by actionscript. Yeah, I've looked at Tweener's code, even tried to tweak a little bit to see if I could get through it, then I realized it's not Tweener's fault. By issuing a: trace(tScope); on line 754, right before: tTweening.onComplete.apply(tScope, tTweening.onCompleteParams); it traces my current instance correctly. Anyway, have you tried this instead? public function load():Void { var obj:Object = new Object({ _y: 200, time: 1, onComplete: function() { super.load(); } }); Tweener.addTween(this, obj); } Yes, I tried that. Just tried again right now to make sure I wasn't missing anything ;) Still, no success... I've just pasted the code from the superclass inside the onComplete handler (it's just a event dispatch anyway, works for now), but I really hate myself for doing this, specially because this is a refactoring of some old crappy code, and it's supposed to be made the right way. Anyway, still trying to come up with something. (Boy, I really wish the boss would let me use AS3 already, I'm sure these things wouldn't happen. AS2 really isn't made to serious programming) Thanks for the help so far, Zeh! Valeu! -- Wagner Amaral Agência Ginga - Brazil www.agenciaginga.com.br ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.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] positioning along bezier curve
Hello Keith is there a way to calculate a point midway along the curve? private function findPointOnCurve(p1x:Number, p1y:Number, cx:Number, - this method can return midway along the curve if bezier curve is symmetrical only. finding point on curve by time iterator is very different thing than finding point by distance along the curve. It is difficult calculation using bisection of Newton algorithm: http://bezier.googlecode.com/svn/trunk/bezier/src/flash/geom/Bezier.as look at getTimeByDistance possible way using Bezier class: var myBezier:Bezier = new Bezier(.); var midwayTime:Number = myBezier.getTimeByDistance(myBezier.length/2); var midwayPoint:Point = myBezier.getPoint(midwayTime); also analog of findPointOnCurve is presented in Bezier class as getPoint method. good luck! -- iv http://www.bezier.ru http://bezier.googlecode.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Re: AS2 vs. AS3: instantiate library symbols with a loop string concatenation
Thanks to everyone who chimed in with the answer! Seems like there is a little disagreement between getDefinitionByName and getClassByName. From some basic searches it looks like getClassByName has been replaced by getDefinitionByName, and I could only find flash.utils.getDefinitionByNamein the Adobe LiveDocs. Either way, thanks for those who helped - I didn't quite know where to loock in my trusty moock. -jonathan On Tue, Mar 4, 2008 at 4:31 PM, Cory Petosky [EMAIL PROTECTED] wrote: import flash.utils.getDefinitionByName; for (var i:uint = 0; i 30; ++i) { var sym:MovieClip = new (getDefinitionByName(sym + i) as Class)(); // rest } On 3/4/08, jonathan howe [EMAIL PROTECTED] wrote: Sorry - somehow triggered the send mail hotkey before I was finished: On Tue, Mar 4, 2008 at 3:25 PM, jonathan howe [EMAIL PROTECTED] wrote: Imagine I have in my library a series of MovieClips with linkage identifiers like so: sym0 sym1 sym2 ... sym29 In AS2, if I wanted to create instances of each one (or perhaps decide which symbol to use based on XML data, for example), I could use a for loop: for (var i:Number = 0; i 30; i ++) { var new_mc:MovieClip = parent_mc.attachMovie(sym + i, sym + i, i); // do stuff with clip } and create each symbol via passing a concatenated string as symbolName. Now, in AS3, I can't think of a way to do this efficiently. In our simple example, I can only think of the following: for (var i:int = 0; i 30; i ++) { var sym:MovieClip; switch (i) { case 0: sym = new sym0(); case 1:sym = new sym1(); case 2: sym =new sym2(); ... } // do stuff with clip } Is there a more efficient way to do this in AS3? You can't really instantiate a class based on a stringname, can you? Was I doing myself a disservice by using this technique in AS2 anyway? Thanks, -jonathan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- -jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] ASDocDesktop - Easy documentation generation
Hello guys, I just developed a little application to easly generate the AS documentation of a project. You can find it herehttp://www.astorm.ch/blog/blogFiles/ASDocDesktop_bundle.zip(or on my blog http://www.astorm.ch/blog - FR). I'd like to have maybe some return about it ;) I tried to take out the files linked to asdoc from the FlexSDK and I have now a bundle of about 30Mo... maybe is there a way to do that more light :) Regards, Cedric ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Lightweight Collision for Platform Game
What is the best collision system for a platform game? I've currently looked at box2D, but I think it runs amazingly slow on afew macs and other machines. Therefore I wonder if there is anything faster lightweight? I think I may need move towards a ray placed under the character instead of actually box-to-box collision. Any ideas? Thanks Elia ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Lightweight Collision for Platform Game
Hello, http://www.harveycartel.org/metanet/tutorials.html -- iv http://www.bezier.ru http://bezier.googlecode.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Lightweight Collision for Platform Game
http://lab.polygonal.de/ Elia Morling wrote: What is the best collision system for a platform game? I've currently looked at box2D, but I think it runs amazingly slow on afew macs and other machines. Therefore I wonder if there is anything faster lightweight? I think I may need move towards a ray placed under the character instead of actually box-to-box collision. Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Lightweight Collision for Platform Game
On Tue, Mar 4, 2008 at 11:34 PM, Elia Morling [EMAIL PROTECTED] wrote: What is the best collision system for a platform game? I've currently looked at box2D, but I think it runs amazingly slow on afew macs and other machines. Therefore I wonder if there is anything faster lightweight? I think I may need move towards a ray placed under the character instead of actually box-to-box collision. Any ideas? The Flashplayer's native hitTest() is a fast bounding box test for two specific clips, or pixel-exact test for a point and a clip. But if you have several objects you need to test against each other, then minimizing the total number of tests should come first. A quad tree helps with that: http://en.wikipedia.org/wiki/Quadtree That should give you a small number of potential hits, which you can then test with a more exact (and expensive) operation. Mark ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders