Re: [Flashcoders] Erasing areas with the drawing API?
Thanks very much Helen and Claus for your responses! OK DAH Huh, that was easy. Turns out that if you don't call endFill(), you can just draw the polygon, moveTo() the hole, and lineTo() the outline of the hole, and it fills itself in. I found an example of this in this article: http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html Specifically in the drawGear() example. OK DAH On Feb 16, 2007, at 4:54 PM, David Ham wrote: Does anyone know how to erase part of an area that was created with the drawing API? I need to be able to draw a polygon, and then draw another polygon inside it and "punch" it out. For example, I need to draw a square and then punch a square hole in it. Anyone ever done this before? OK DAH -- David Ham http://davidham.com :: [EMAIL PROTECTED] ___ 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@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] Erasing areas with the drawing API?
Huh, that was easy. Turns out that if you don't call endFill(), you can just draw the polygon, moveTo() the hole, and lineTo() the outline of the hole, and it fills itself in. I found an example of this in this article: http://www.adobe.com/devnet/flash/articles/adv_draw_methods.html Specifically in the drawGear() example. OK DAH On Feb 16, 2007, at 4:54 PM, David Ham wrote: Does anyone know how to erase part of an area that was created with the drawing API? I need to be able to draw a polygon, and then draw another polygon inside it and "punch" it out. For example, I need to draw a square and then punch a square hole in it. Anyone ever done this before? OK DAH -- David Ham http://davidham.com :: [EMAIL PROTECTED] ___ 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] Erasing areas with the drawing API?
Does anyone know how to erase part of an area that was created with the drawing API? I need to be able to draw a polygon, and then draw another polygon inside it and "punch" it out. For example, I need to draw a square and then punch a square hole in it. Anyone ever done this before? OK DAH -- David Ham http://davidham.com :: [EMAIL PROTECTED] ___ 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] UIObject without MM Components
Bryan, You're awesome! In 100 years that would not have occurred to me. What a bizarre program Flash is! Thanks very much for the tip, OK DAH On Feb 9, 2007, at 6:25 PM, Bryan Thompson wrote: Try adding the UIObject MovieClip to your library. You'll find it (Win XP, Flash8) in Program Files\Macromedia\Flash 8\en\Configuration\ComonentFLA\StandardComponents.fla I use that when creating custom V2 components by putting it on stage in frame 2 after a stop() action. Works fine. Bryan I am working on an app that has many view classes that extend mx.core.UIObject. Until recently I was using Macromedia components as placeholders, but the production app will use a different library, the FlashLoaded BJC components, which are incompatible with the Macromedia components. I removed all the MM components from the library, and now my app won't run. The first class that loads extends UIObject, and even though that class is in my classpath, my view class that extends it will not run. However, when I add a single MM component to my Library--I have tried it with the Label and the Button--it compiles and my UIObject subclasses work as intended. What gives? Is it possible to use UIObject without using the MM components? Thanks for any help you can offer, OK DAH ___ 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] UIObject without MM Components
Hi, I am working on an app that has many view classes that extend mx.core.UIObject. Until recently I was using Macromedia components as placeholders, but the production app will use a different library, the FlashLoaded BJC components, which are incompatible with the Macromedia components. I removed all the MM components from the library, and now my app won't run. The first class that loads extends UIObject, and even though that class is in my classpath, my view class that extends it will not run. However, when I add a single MM component to my Library--I have tried it with the Label and the Button--it compiles and my UIObject subclasses work as intended. What gives? Is it possible to use UIObject without using the MM components? Thanks for any help you can offer, OK DAH ___ 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] hooking up GUI in pure OO code...
Ha ha, this is why we love Flash so much, and why it makes us want to put a bucket on our head, and have our children whack the bucket with sticks. So here's the thing. Your class has a method called doStuff(), and a button mc called button_mc. You want it to fire doStuff() when you click button_mc. Here is how I do it: In your class file: button_mc.owner = this; // the mc now has a new property 'owner' which is a reference to the class button_mc.onRelease = function() { this.owner.doStuff(); } This refers to the movieclip, owner refers to the class. Using UI components is a little better but not much: In the class file: button_btn.addEventListener( "click", Delegate.create( this, doStuff ) ); Annoying but it works. Enjoy! OK DAH PS If anyone has a better way to do this, I am SO all ears. On Feb 4, 2007, at 3:56 PM, Jason Boyd wrote: OK this is making me nuts. It seems to be an impossible scope problem, to do something that ought to be very very possible, and in fact common. The basic problem: I want to have initialization code in a Main class that hooks up GUI controls to methods in this class (acting as a controller class essentially). For various reasons, I do not want to use components; the GUI elements are either Buttons or MovieClips. Again, this ought to be possible, right? So here's the problem case: class Main { var myButton:Button; // placed on stage in authoring time function init() { myButton.onRelease = function() { doSomething(); } } function doSomething() { trace("something"); } } This does not work, nor is there any way I can wrap my head around getting it to work, as the anonymous function assigned to the button event handler has "this" scoped as the button itself, so "doSomething()" refers to a non-existent function myButton.doSomething(). Simply assigning the member function to the button event handler directly doesn't help, as this function is then unable to call other member functions for the same reason. E.g.: function init() { myButton.onRelease = doSomething(); } function doSomething() { // this will be called now, but "this" still refers to the button, not objects of this class } There has *got* to be some way around this issue. Right? ___ 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 -- David Ham http://anthropomorphy.org :: +1 630 297 1273 http://davidham.com :: [EMAIL PROTECTED] ___ 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] class confusion
Yeah I'm reading Essential Actionscript (Moock) right now, and he does somewhat reduce confusion. Part of the problem is that older methods that have sort of been practically deprecated by AS 2 are still given out by others (#initclip and registerObject() ) are confusing as they appear completely reduntant to extending MovieClip). That's true. Since I started writing AS2 code I have never used #initclip, and registerClass only rarely. The trend is definitely toward a more standard OO programming style. The load order still confuses me. More precisely than my first post, I am wanting in general to be able to develop applications where ALL actionscript is in external .as files (which I generally edit in better editors than the Flash IDE, and then the FLA file simply #include's some main code, or creates a single instance of class Main, and calls Main.main(). The FLA file is then used solely for media assets. If I do this, how can I be sure, for instance, that class Main is actually initialized before any other classes and can then control the initialization order from Main? I suppose I could simply avoid static initializers, but I don't like running away from a supported language feature simply because I'm unclear about its runtime behavior. It sounds like you might be confusing initializing with loading. When you set your classes to load on a frame other than frame #1, in my experience anyway, it's so that you can make sure that your whole app is loaded in the browser before it starts executing. This is an issue because Flash loads progressively. For example, you could have your preloader code (checking _framesloaded against _totalframes, say) running in frames 1-10, and have your classes set to export to frame 11. When your preloader determines that all frames have loaded, it can gotoAndPlay() to, say, frame 20, where your app code is. I would bet that static classes are initialized as soon as they are loaded, but they are only instantiated when you tell them to, as in var foo:MySingleton = MySingleton.getInstance(); That's just a prediction though; I'd verify it with trace statements. Hmm so I could change the export frames for classes to explicitly order their loading, but this forces a multple frame main movie ( a minor annoyance). Still, does a static property get initialized when the class loads? E.g: class MySingleton { static private var instance = new MySingleton(); private function MySingleton() { // whatever init code } public function getSingleton() { return instance; } } I am wondering exactly when does the instance come into existence. For that matter, with the default loading of classes at frame 1, are classes then loaded only after all exported library assets are loaded? I believe your app loads and executes in timeline order. I usually do like I describe above: have preloader code on frames 1-10 or so, export classes and symbols to load at frame 11, and start the app on frame 20. You are smart to keep as much of your AS code in external class files as possible. But this being Flash, a little bit of timeline setup is usually necessary. Moock has a good bit about this in EAS2. In general, 'this' refers to the object of current scope. When used in a class, it refers to the class; when used on a frame in the Flash editor, it refers to the current timeline; when used in a callback, it refers to the object that owns the callback. This has been my understanding, but it seems I've run into a few situations where the behavior is different, and one case where "this" turned out to be undefined! Unfortunately I cannot remember the case, but it still bothers me. When would this == undefined? I believe it was within a class method that was given as a callback from code running on the main timeline, and I had assumed this would refer to my class, or at least to the main timeline. Yeah, scope is a recurring problem for me too, like with callbacks and event listeners. Not sure when this would return undefined though. One thing that sometimes helps is using Delegate.create() in your addEventListener statements; it lets you scope the event to a class instead of to the thing generating the event, which is a pain in the ass. This does seem the way to go, when the attached stuff is generating multiple attached clips. Would be nice if AS had some way to *actually* attach to to the next depth. Could easily write a function to do this I suppose, by checking subsequent depths for the presence of a clip... Just seems like not having to specify any depth would be good, where you could assume that all subsequently added clips stack above previous ones. Sometimes you want to control this manually though. If it's a few clips that are unlikely to change, I often hardcode the depth; if it's a dynamic number, like from an array, I key the depth to an array iterator, and if it's more chaotic than that I use getNextHighestDepth. W
Re: [Flashcoders] class confusion
1. Load/init ordering: When do classes load, and when do static initializers execute? If a class has a static property that is assigned outside a constructor, is this initialized when the class loads (presumably frame 1?) or the first time it is accessed, or what? If class A refers to a static property of class B, how do I ensure that class B is initialized before class A? What if each class refers to a static property of the other class? (These are somewhat silly examples to illustrate the grey area I'm trying to root out.) I believe classes load on whatever frame they are set to export to (under Actionscript 2 in Publish Settings). The default is frame 1 but you can set a different frame. Other properties of the class initialize when the class is instantiated; as to specific order for your situation, I would test with a series of trace statements. 2. Timeline/clip context: I am looking for corrections to a few asserstions here: - "this" (always?) refers to a movie clip when the code is outside any class; often the main movie when in the movie's timeline. - "this" refers to an object when inside any class method, with one exception, which is when defining a function within a method, like so: function classMethod() { var loader = new loadVars(); loader.onData = function(text) { this.foo(); /// "this" here does not refer to our class, but as far as I can tell, to nothing } } - "this" is dynamic; within the same function, it may take on different meanings at run time depending on where the function is called. (In which case I'm fuzzy on when and what.) In general, 'this' refers to the object of current scope. When used in a class, it refers to the class; when used on a frame in the Flash editor, it refers to the current timeline; when used in a callback, as in: foo_mc.onRollOver = function() { trace(this._x); } it refers to the object that owns the callback. In your example above, 'this' refers to your 'loader' variable, as it occurs in the onData function, which is a method of the loader object. 3. Associating MovieClips and classes: Can a class simply extend MovieClip? And what exactly is happening when a library symbol is linked to a class, at runtime? You can indeed extend MovieClip. However, I often find it better to create movieclip-related classes by composition rather than extension. To link a class to an mc, you need to do two things: 1. your class must extend MovieClip 2. Your library symbol must be linked to the class name via its Linkage... panel in the Flash editor. You can create instances of this sort of class in two ways: by dragging one onto the stage, or by doing an attachMovie() on the class symbol's linkage ID. I tend to favor composition regardless, but there is something ugly to me about having multiple classes which logically correspond to movie clips in the library having to hard-code attachMovie(), which also introduces an architectural problem that seems to break encapsulation. If I have, for instance, 3 classes that handle different aspects of a GUI, or perhaps sprites, and each class in its constructor uses attachMovie() to create graphics from library symbols, if they all attach to _root, then they must make sure to each use distinct depths, which forces each class to know what depths the others are using (or *always* using _root.getNextHighestDepth(), which isn't always desirable). First, the attachMovie business is indeed kind of kludgey; why can't I just do var foo:MovieClip = new MovieClip(); But that's Flash for you. If you like this sort of setup, you can use movieclips via composition and do: var foo:MyClass = new MyClass(); and have MyClass handle the attachMovie() and depth setting jazz. But even so, MyClass will have to know what depth to create its clips at, and what movieclip to attach them to, so you'll probably have to pass them in to MyClass as parameters when you instantiate it. Alternatively, I could place container clips on the stage at author time corresponding to each class, so depths are segregated in this way, but this feels like its adding unnecessary complexity. One way to tackle the depth management problem is to have each class have its own base movieclip, and attach its sub-clips to that base clip. For example, if your app has, say, three UI panels, each panel could have its own base clip (maybe created by createEmptyMovieClip() in your class file). Then each panel class only needs to keep track of its own clips, and your main application only needs to keep track of the panel clips. The depths for each are thus encapsulated in the appropriate class. Finally, if a class uses a singleton pattern, where it has one and only one static instance of itself, but also requires a movie clip, I am confused as to when this instance gets added to the main timeline, which then affects depth stacking order (see question #1). Singletons are instantiated like any other
Re: [Flashcoders] Re: more bitmap data questions...
I don't think so. I think you'd just have to removeMovieClip() to take it off of one parent and then do a new attachMovie() on the new parent. OK DAH On Feb 3, 2007, at 1:58 PM, [p e r c e p t i c o n] wrote: thanks...while i'm at it...does anyone know of a way to change a movieclips parent? say i attach a clip to level0 then want to attach it to a movieclip later can this be done? thanks ___ 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] Q:Hittest and transparent PNG's
You could also create another movieclip in the shape of the area you want to hitTest, and set the hitArea of your main movieclip to point to it. OK DAH On Feb 1, 2007, at 8:20 PM, Cay Garrido H. wrote: You could convert it to a bitmapData and check the transparency level with getPixel32... [EMAIL PROTECTED] escribió: Hi Does anyone know if there is a way to get hitTest to ignore transparent areas in dynamically loaded PNG's? [e] jbach at bitstream.ca [c] 416.668.0034 [w] www.bitstream.ca "...all improvisation is life in search of a style." - Bruce Mau,'LifeStyle' ___ 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 -- David Ham http://anthropomorphy.org :: +1 630 297 1273 http://davidham.com :: [EMAIL PROTECTED] ___ 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] Flash diagnostic tools
I am working on a Flash app and it is starting to exhibit some performance problems. Is there any tool or technique people use to analyze Flash apps as they are running? Aside from the beloved trace () of course? Thanks for any advice you can offer, OK DAH ___ 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] Q: offset x,y in StartDrag()
The problem is this mc ( in _root ) is offset from the Mouse position by the x,y coordinates of the nested MovieClip. How can I update the x,y coordinates of the _root mc so that it 1-initially mimics the exact position of the nested MC and 2-follows the mouse using StartDrag Hope this makes sense...I'm wondering if I should even try simulating a StartDrag using Mouse listeners and converting local to global coordinates. Any help appreciated. I had this exact problem recently. To create the mirror clip, my code does this, more or less: function onFirstItemPress() { var p:Point2D = new Point2D(item_mc._x, item_mc._y); item_mc._visible = false; // translate coordinates from one local coordinate system to another layout_mc.localToGlobal( p ); dragLayer.globalToLocal( p ); dragItem = dragLayer.attachMovie( foo, foo + "_mc", 0, { _x: p.x, _y: p.y } ); dragItem.owner = this; dragItem.onRelease = function() { var evt:Object = { type: "newObjectRelease", target: this }; this.owner.dispatchEvent( evt ); } dragItem.startDrag(); } Basically, you were correct, you'll need to translate the coordinates using some localToGlobal action. Hope this helps, OK DAH ___ 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] Flair Pattern bad mixins good (?)
Been a while since I've posted here, a few years I think. I miss the geek tangents / debates. =) Good man! Seriously, the world affords precious few opportunities to truly geek out on design patterns and such. Internet mailing lists excepted of course. I have the Head First Design Patterns book, and I have to say I like it, in spite of its profusion of clip art and cheesy humor. Despite these stylistic affronts, it presents the material in a way that is easy to learn. What's the consensus on the GoF book? I know it's a classic, but so is Ulysses and dog if I can read that. I don't have a CS background-- Flash is about as far as my programming expertise extends--so the Head First style works for me. Is GoF accessible for people who don't program in C++? OK DAH ___ 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] full screen window
The best user experience would be two windows: have a launch page with a link that would open a new JavaScript child window, and tell the user that the course is going to open in fullscreen. Then you can control the size and properties of the window as much as you like, and the user doesn't get the surprise of his/her browser opening way up unexpectedly. OK DAH ___ 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] Flair Pattern bad mixins good (?)
OK, this is helping a lot. And Steven I see what you mean, poor Flair is starting to look a little meager now. In my app, I have several different states. Each state sets itself up by initializing variables and drawing its various pieces, and the final piece is to subscribe various parts of the app to events that happen in other parts. So in one state I have methods like: onRoomObjectPress() onRoomObjectRelease() that are triggered by onPress and onRelease events in my object movieclips. These onSomething() methods contain the core logic of the app--code to resize clips or process values or what have you. This structure is good because I know where to look to track down where things happen, but its bad because sometimes a bunch of things are supposed to happen at once and those onSomething() methods get hairy. So in this new mixin strategy (which does look a lot like Strategy, thanks James!), should I design my Snappable class to have methods that would map to movieclip events, such as: startObjectDrag triggered by obj_mc.onPress checkForSnap triggered by setInterval or onEnterFrame type of event, in this case onObjectDrag stopObjectDrag triggered byobj_mc.onRelease Am I headed in the right direction? Thank you again, this OK DAH The theory of mixins originated from multiple inheritance programming languages such as C++. So for example: Say you wanted to make an object dragable, clickable and resizable. You would then create separate classes called: Dragable, Clickable and Resizable (common naming convention for a mixin). Then your base class would just inherit form those 3 classes. Since AS2 doesn't support multiple inheritances you can emulate a mixin using interfaces and composed classes. For example: IClickable, IDragable, IResizable So then your AS2 class would say: Class MyClass extends Whatever implements IClickable, IDragable, IResizable Those interfaces just specify what methods your class has to support. From there you could have a class (or a consolidated class) implement that functionality private var clickable:Clickable = new Clickable(); private var dragable:Dragable = new Dragable(); private var resizeable:Resizeable = new Resizeable(); from there you just forward / wire the appropriate methods to its corresponding instances. public function startResize() { this.resizeable.startResize(); } Or for arguments: public function startResize() { this.resizeable.apply.(this.resizeable.startResize, arguments); } You could get even more fancy by externalizing those classes so based on various rules you could pass in different resize logic, etc. Anyhow, hope that gets the gears turning. =) DISCLAIMER: Didn't spell check or test anything in the compiler so maybe some typos. =) -erik -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, January 29, 2007 7:12 PM To: Flashcoders mailing list Subject: Re: [Flashcoders] Flair Pattern bad mixins good (?) Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind mixins in general. In my app, i have objects that can be dragged around in a Room, and they have a "snapping" behavior that lets them snap to the walls of the room, and in some cases, rotate themselves so that a given side of the object is always to the wall. Currently, my snapping behavior is in a separate class like the one at the top of this thread. If the room object has snapping enabled, the SnapFlair class adds an object with a bunch of methods and properties to it. The snapping methods are triggered by an event that is broadcast as the room object is being dragged. How would I implement this as a mixin? Many thanks fellas! As for Steven, sounds like HE'S got a case of the Mondays! *smirk* OK DAH ___ 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 -- David Ham http://anthropomorphy.org :: +1 630 297 1273 http://davidham.com :: [EMAIL PROTECTED] __
Re: [Flashcoders] Flair Pattern bad mixins good (?)
Anyhow I tend not to use decorators (matter of personal taste). I prefer to not Frankenstein an object at runtime and rather use mixins (composition + interfaces). Ah, thank you, now we are getting somewhere! Tell me about mixins. I have used EventDispatcher before, but I am unfamiliar with the theory behind mixins in general. In my app, i have objects that can be dragged around in a Room, and they have a "snapping" behavior that lets them snap to the walls of the room, and in some cases, rotate themselves so that a given side of the object is always to the wall. Currently, my snapping behavior is in a separate class like the one at the top of this thread. If the room object has snapping enabled, the SnapFlair class adds an object with a bunch of methods and properties to it. The snapping methods are triggered by an event that is broadcast as the room object is being dragged. How would I implement this as a mixin? Many thanks fellas! As for Steven, sounds like HE'S got a case of the Mondays! *smirk* OK DAH ___ 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] Flair Pattern?
For my part, I have the Head First book, and the Decorator section did not answer the particular questions I had. Nor did the other sources I read. Whether something is a "true" design pattern or not is kind of beside the point, for me; what I want to know is if a particular approach is good for what I am trying to accomplish: in this case, adding and removing functionality to an object at runtime. As for Steve's earlier comment, "It's not a design pattern, it's a class that uses another design pattern, and poorly, too," thanks for the reply, but it does nothing to explain why the code is bad, or what a better approach would be. My approach is working so far; if it's no good, I'm sure the code will tell me, soon enough. For the common good I move that we put this thread to bed, OK DAH ___ 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] Flair Pattern?
I've never heard of an OOP design pattern called Flair. From the class you've pasted, it looks like a novice attempt at implementating (sic) a design pattern known as Decorator. Perhaps they were trying to be funny with a reference to the movie Office Space where buttons decorating a TGIFriday's uniform were called Flair? I know that comedy helps when teaching dry material, but renaming a design pattern like that seems to me to be confusing at best. The pattern is similar to Decorator (as they acknowledge in the book) but different in that it allows you to add and remove functionality at runtime. I decided against Decorator because not all objects in the app will need this functionality, and the ones that do can have it turned on and off by the user. So I figured a separate class would be a good way to encapsulate this functionality, and I remembered this pattern from their book. I don't have a lot of background in design patterns so I was curious if other people have used it. Incidentally, you are correct about the Office Space reference. Here is a post from Branden Hall, the book's author, from this very list: http://chattyfig.figleaf.com/pipermail/flashcoders/2003-January/ 060703.html OK DAH ___ 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] Flair Pattern?
Hey FlashCoders: In the app I am building, I have a need to add and remove functionality to an object at runtime--specifically, functionality that will snap the object to a border. I have puzzled on this for awhile, and the method that seems most applicable to me is the Flair pattern described in "OOP with ActionScript" by Hall & Wan. If you don't have the book, the pattern, in short, is a static class that dynamically creates a child object on the class it is modifying, and then adds methods and properties to that object. My question is: has anyone else used this pattern in AS2 projects? Is it even the best way to achieve what I am trying to achieve? An outline of my SnapFlair class follows below. Any input you can offer is greatly appreciated, as always, OK DAH SNAPFLAIR CLASS Implemented as a Singleton class SnapFlair { private static var _obj:SnapFlair; private function SnapFlair() {} /** * @param target The MovieClip being 'flaired' * @param source The source of the event that the flair functionality is listening for * @param eventName The name of the event that the flair is listening for */ public function snapOn( target:MovieClip, source:Object, eventName:String ) { target.mc.$snapFlair = new Object(); target.mc.$snapFlair._obj = target; source.addEventListener( eventName, target.$snapFlair ); target.mc.$snapFlair[eventName] = onEvent; } public static function getObj():SnapFlair { if (SnapFlair._obj == null) { SnapFlair._obj = new SnapFlair(); } return _obj; } public function snapOff( target:MovieClip, source:Object, eventName:String ) { source.removeEventListener(eventName, target.$snapFlair) delete target.mc.$snapFlair; } public function onEvent( evt:Object ) { // do stuff } public function toString():String { return "Class SnapFlair"; } } ___ 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 size change onRotate?
I'm having a thorny Flash problem and I was wondering if you've seen anything like it before. In the tool I am building, you can place an object on the stage and do a free transform kind of operation on it; you can scale X, scale Y, and rotate it around its center. So far, I can: * rotate * scale X and scale Y from zero rotation My problem is when I rotate first and then scale. My resize handles change the _width and _height of the target object, but when I rotate the object and THEN scale it, it goes all fubar. When I set the _width on an object that has been rotated, it seems to set the width of the bounding box rather than the clip itself, so that visually, I am dragging, say, the width handle, but the item scales a little bit on both axes. What I need to be able to do is set the width and height of an object, independent of each other, at any rotation, at runtime. I had something working where I was changing the _xscale and _yscale, but it didn't look right; it needs to be the _width and _height. Thanks for any help you can offer, OK DAH ___ 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] FLVPlayback redraw problems with Firefox and opacity filter--help!
Hi, I have an FLVPlayback component playing a progressive download FLV video. The component is on a page whose background image is at a 10% opacity using a CSS filter. The stylesheet code is like this: #background img { filter: alpha(opacity=10); } In Firefox, this is causing some weird redraw issues on my FLVPlayback component. When I use the SteelExternalPlaySeekMute skin, the controls show up when the screen loads, but when I start the movie, they redraw in a blocky way and are partially invisible. I blame this on the opacity filter because when I turn off the stylesheet, the component behaves as it should. Has anyone else seen this? Any workarounds to recommend? Thanks, OK DAH ___ 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] Re: Using components in MovieClips
Everyone, Thank you for the responses. Attila's suggestion to do the addEventListener() in an onLoad function worked perfectly, thanks Attila! To answer someone else's question about why I was calling it createChildren(): my class is a subclass of UIObject, the base class of all v2 components. UIObjects run the following methods in the following order: constructor (usually left empty) init() (runs only once) createChildren() (used to create sub-movieclips and components, called only once) ** a frame passes ** draw() (called whenever the component needs to redraw, usually in response to a invalidate() call) In my code, onLoad appears to fire after createChildren fires, so I put my addEventListener calls there, and they work like a champ. Thanks very much to everyone who responded! OK DAH PS Chafic Kazoun wrote an excellent introduction to UIObject and UIComponent. It's at Ultrashock.com and is called "Introduction to the V2 Component Architecture." http://www.ultrashock.com/ff.htm?http://www.ultrashock.com/tutorials/flashmx 2004/v2a-01.php On 12/19/06 10:22 AM, "David Ham" <[EMAIL PROTECTED]> wrote: > Hi, > > I was having trouble with some components yesterday. I am writing a > NavigatonView class that extends UIObject. I linked it to a symbol in the > library that had four Button components in it. The symbol had no code in it; > the code for the class was entirely in an external .as file. > > Here is the trouble: the Button components appear on stage, but only as > Movieclips, they do not respond to component commands like move(), and they do > not register calls to addEventListener(). However, they respond visually when > I roll over them, and I can attach functions to their onRelease. What gives? > > Here is the code from the class: > > private function createChildren():Void { > trace("CREATECHILDREN"); > roomShape_btn.toggle = true; > //roomShape_btn.addEventListener( "click", this ); > //resizeRoom_btn.addEventListener( "click", this ); > //editCorners_btn.addEventListener( "click", this ); > //placeObjects_btn.addEventListener( "click", this ); > roomShape_btn.onRelease = click; > resizeRoom_btn.onRelease = click; > editCorners_btn.onRelease = click; > placeObjects_btn.onRelease = click; > > } > > function click(evt:Object) { > trace( this ); > } > > The commented lines do not work (and yes, I did try uncommenting them first, > har har) but the onRelease ones do. > > Incidentally, component instances that I create dynamically with > createClassObject() work as expected. > > Thanks for any help you can offer, > > OK > DAH > -- David Ham http://anthropomorphy.org:: +1 630.297.1273 http://davidham.com:: [EMAIL PROTECTED] ___ 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] Using components in MovieClips
Hi, I was having trouble with some components yesterday. I am writing a NavigatonView class that extends UIObject. I linked it to a symbol in the library that had four Button components in it. The symbol had no code in it; the code for the class was entirely in an external .as file. Here is the trouble: the Button components appear on stage, but only as Movieclips, they do not respond to component commands like move(), and they do not register calls to addEventListener(). However, they respond visually when I roll over them, and I can attach functions to their onRelease. What gives? Here is the code from the class: private function createChildren():Void { trace("CREATECHILDREN"); roomShape_btn.toggle = true; //roomShape_btn.addEventListener( "click", this ); //resizeRoom_btn.addEventListener( "click", this ); //editCorners_btn.addEventListener( "click", this ); //placeObjects_btn.addEventListener( "click", this ); roomShape_btn.onRelease = click; resizeRoom_btn.onRelease = click; editCorners_btn.onRelease = click; placeObjects_btn.onRelease = click; } function click(evt:Object) { trace( this ); } The commented lines do not work (and yes, I did try uncommenting them first, har har) but the onRelease ones do. Incidentally, component instances that I create dynamically with createClassObject() work as expected. Thanks for any help you can offer, OK DAH ___ 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] flash applicatin and database
Have you looked at OpenAMF? http://openamf.com I used it on a project a couple of years ago, and it works great. It's free, and our developers evaluated it and found it to be functionally indistinguishable from Flash Remoting. OK DAH ___ 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] UIObject/UIComponent: Getting started
I am working on a Flash app that will be set up in an MVC architecture. It will have draggable objects, a menu, a property inspector, and other UI pieces. In the past I have built my Views with composition; that is, by including the MovieClip as a property instead of subclassing it. But I have been looking at the UIObject and UIComponents and wondering if subclassing them would be a better move. So: * Do you recommend these for this kind of development, or are they best for straight up component development? Is the extra overhead/learning curve worth it? * Does anyone have any Flash 8 tutorials they'd recommend? I have read the Chafic Kazoun piece at UltraShock and have seen the Jesse Warden tutorials (both excellent! Thanks gentlemen!) but can use all the help I can get. Best regards, OK DAH ___ 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