This content has been marked as final. Show 5 replies
In AS3 there is an event render, actually the hole "render" mechanic has changed. Now it works something like this, the STAGE has a render function witch trigger a render event for every element that's listening to it.
So all you need is to create an event handler and call the stage render function to render all objects on the stage.
yes, flash.events.Event.RENDER is broadcasted before the render of the object and you have to call invalidate() on the stage to force redraw.
but i can't cancel flash.events.Event.RENDER.
I wanna do a Decorator patern, so i have to catch what's drawing my object, stop it, and call it on my encapsulated object.
it's possible to do a dirty workaround with this event or encapsulat the object with a Sprite but i wanna extends the class i wanna encapsulated so ..
i need to know the inside working of the holy beast
I'm not sure what you are trying to do, please explain :)
yes i can explain, i 'll try.
i'm talking about applying theDecorator pattern ( wiki definition) in AS3 on a displayObject subclass (cause we can't directly to DisplayObject :'( ) to add responsibilities to individual graphical objects dynamically and transparently.
for exemple you can have a BorderDecorator subclass of flash.text.TextField that add a border to a text field ... in the patterne way of thinking you ll have to use it like this:
var myDecoratedTextfield : TextField = new BorderDecorator (myTextfield)
BorderDecorator keep an internal ref on myTextfield (let take _component)
from that point you'll use myDecoratedTextfield instead of myTextfield :
myDecoratedTextfield.texte = "je pense donc je suis"
but internally BorderDecorator 'll do _component.texte = "je pense donc je suis" and the texte of myDecoratedTextfield 'll nerver change. so it's the same idea for the graphical render :
stage.addChild (myDecoratedTextfield )
in the same idea myDecoratedTextfield have to never be rendered instead he'll only call the render on _component ( here myTextfield).
And to do this i need to know what append in the rendering process to intercept the call of render on myDecoratedTextfield and call it on myTextfield.
I don't think what you are trying to do is done that way. For what I see in your example you need a class that's call BorderDecorator that has the pattern and the textfield inside.
Looking at the way you want the code to work, I would make this class so it will add to it's own display list the textfield when you call the constructor (This will remove the textfield from stage) and it will add itself instead of the textfield.
This way your class will be a wrapper to the original display class and you'll have control of all the parameters through setters and getters.
I don't think you can HACK into the render process of the flash player though.