CURRENT PROJECTS
loading
CATEGORIES AND POSTS
loading
overset
DEVELOPMENT LOG FOR JIM PALMER
Posted 07/20/2006 in flash


I found an issue attempting to finish a new component. When attempting to display the risizing of a component as it's on the stage in said component's live preview movie if you redraw a TextField with type='input' the live preview movie will be broken. Instead attempt to soft-remove the TextField where it's declared in the actionscript.

I add the following code to the stage's actionscript in the live preview movie so that the component will re-size appropriately to the size of the drag-n-dropped component and it's reflected properly in the stage where the user drops the component:
Stage.align = "TL";
Stage.scaleMode = "noScale"
obj = new Object ();
obj.onResize = function () {
	xchInputBox.__width = xch.__height = Stage.width;
	xchInputBox.__height = xch.__height = Stage.height;
	// re-render the component
	xchInputBox.init();
}
Stage.addListener (obj);

xchInputBox is the instance name of the dropped component in the live preview movie. The xch object refers to a blank MovieClip in the library that magically acts as the parent MovieClip as it's modified in the later IDE as a component - it is the faux object where all the component parameters will reside during design-time so that the live preview movie can on-the-fly handle the component parameter changes. This is where the function onUpdate() { } call comes into play. This function resides in the stage's _root actionscript on frame 1 after a call to stop();

Back to the topic at hand... if you want the resizing of the parent MovieClip affect the size of the TextField with a type='input' in the live preview you'll need to delete the TextField before every single redraw. In my case the onResize function applied to the live preview's Stage set's the component's width and height as per the resized stage's and then makes a call to my init() function which draws the component. At the top of the init function it's wise to clear all the dynamic items. Again, in my case I need to remove the TextField that gets created every time init() is called:
function init ():Void {
//...
	this["input"].removeTextField();
	this.createTextField("input", this.getNextHighestDepth(), 0, 0, this.__width, this.__height);
//...
}
.. which is a soft-delete. What I mean is that a compiler error will not be thrown for non-existant object for the first call to init(); This quietly kills the variable and then immediately recreates it - and this only happens in the live-preview.

Another important note is in these redraw functions heavily used in your live-preview update functions, use the this.clear() call to remove all MovieClip drawings - just something to watch out for if you ever use lineTo() or curveTo().
comments
loading
new comment
NAME
EMAIL ME ON UPDATES
EMAIL (hidden)
URL
MESSAGE TAGS ALLOWED: <code> <a> <pre class="code [tab4|tabX|inline|bash]"> <br>
PREVIEW COMMENT
TURING TEST
gravatar