- Home
- Tutorials
- Flash
- Intermediate
- Pseudo HTML Framesets in Flash MX

Page 3 of 3
Peter Strømberg
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by Peter StrømbergThe background’s are not resized. We need to trigger myFrameAdjust continually while we drag the border, and if we don’t want it to snap back to it’s start position onRelease we need to also change the widthPercent to reflect the new position.
The myMouseDown Boolean will be used to prevent the function being triggered when the frameborder isn’t being dragged, to save on CPU, as follows.
this.onEnterFrame = function() {
if (_root.myMouseDown) {
_root.widthPercent = _root._xmouse/(Stage.height/100);
myFrameAdjust();
}
_root.cursorV._x = _root._xmouse;
_root.cursorV._y = _root._ymouse;
};
on (rollOver, dragOver) {
_root.cursorV._visible = 1;
Mouse.hide();
}
on (rollOut, dragOut) {
_root.cursorV._visible = 0;
Mouse.show();
}
And hide the cursor in the first frame of the movie
_root.cursorV._visible = 0;
The Text Object allows us to create scalable text fields on-the-fly.
Add the following code to the first frame to create a text field in each Doc.
//Set up page margins
myLeftmargin = 10;
myTopMargin = 10;
//create a text format. A text format can be applied to a text field
myTextFormat = new TextFormat();
//Many attributes of the text can be specified.
myTextFormat.size = 16;
myTextFormat.font = "_sans";
myTextFormat.color = 0xFFFFFF;
//An alternative text format
myTextRight = new TextFormat();
//If you use an exotic font, be sure to export it with your movie
myTextRight.font = "_sans";
myTextRight.align = "right";
//Create a text field in the lefthand doc
_root.leftDoc.createTextField("theText", 1, myleftMargin, myTopMargin,
_root.leftDoc.bg._width-(2*_root.myLeftMargin), 100);
_root.leftDoc.theText.wordWrap = true;
_root.leftDoc.theText.html = true;
_root.leftDoc.theText.htmlText = "This is a right justified text that wraps to fit the
window in the same way as HTML in a framesetFlash can accept the following HTML tags:
<I>Italic</I><B>Bold</B><u>Underline</u><FONT SIZE=\"50\" COLOR=\"#FF0000\">Size and Colour
</FONT>Linebreakand Links <FONT COLOR=\"#0000FF\"><U><A HREF=\"http://www.cv-e.com\">My Home
Page</A></U></FONT><b>NOTE:</b> Text style tags in HTML are ignored if the styleis set
explicitly in Flash via the TextFormat object.";
_root.leftDoc.theText.autoSize = true;
_root.leftDoc.theText.setTextFormat(myTextRight);
//Create a text field in the righthand doc
_root.rightDoc.createTextField("theText", 1, myleftMargin, myTopMargin,
_root.rightDoc.bg._width-(2*_root.myLeftMargin), 100);
_root.rightDoc.theText.wordWrap = true;
_root.rightDoc.theText.html = true;
_root.rightDoc.theText.htmlText = "This is a left justified text that wraps to fit
the window in the same way as HTML in a framesetAdjust the frame width and see how the
text conforms to the window size.There's no scrollbar in this version, so at some point
the text won't fit in the window boundries";
_root.rightDoc.theText.autoSize = true;
_root.rightDoc.theText.setTextFormat(myTextFormat);
//Set up the stage when the movie first opens
myFrameAdjust();
Quite a mouthful, but I believe the comments explain what’s going on.
The most important line as far as our HTML-style frameset goes is
_root.leftDoc.theText.autoSize = true;
as this is what enables the text field to change size to accommodate the frameset.
Before you test it and find it doesn’t work, you need to add the following two lines to myFrameAdjust so that the text fields scale along with their document backgrounds.
_root.rightDoc.theText._width = Stage.height-borderV._x-(2*_root.myLeftMargin);
_root.leftDoc.theText._width = borderV._x-(2*_root.myLeftMargin);
I’ll cover the text object more thoroughly in another tutorial.
That’s about it. Just for fun here’s an example with a horizontal frame border as well and its FLA
I hope this tutorial has given you an incite into some new possibilities in MX, and maybe at the same time heightened your appreciation of the built-in functionality HTML offers. It’s taken over 70 lines of code here just to simulate a couple of HTML’s powerful, yet deceptively simple features in Flash MX.
This tutorial and all materials are Copyright © Peter Strømberg 2002 and may not be reproduced without the permission of the author.(Just ask him , he'll probably say yes ;o)
