PDA

View Full Version : Accordion Question


Scottae
01-12-2006, 08:28 PM
Anybody know if it's possible to get the dimensions of the available area of a section or View of an Accordion component? Here's what I mean.....create new movie, stick Accoridion component in the library, stick this code on the main timeline and test it out:

import mx.core.View;
import mx.containers.Accordion;

// Create an accordion
var my_acc:Accordion = createObject ("Accordion", "my_acc", 1);
my_acc.setSize (400, 300);

// Create the sections for the accordion
var first:View = View (my_acc.createSegment (View, "first", "First"));
var second:View = View (my_acc.createSegment (View, "second", "Second"));
var third:View = View (my_acc.createSegment (View, "third", "Third"));

// Try and see what the width and height are for the first view
checkDimensions ();

// Wait a little bit before checking the width and height
var id:Number = setTimeout (checkDimensions, 1000);

// Function used to check dimesions of the first view
function checkDimensions ()
{
trace ("width : " + first.width);
trace ("height : " + first.height);
trace ("_width : " + first._width);
trace ("_height : " + first._height);
trace ("");
}

I get this in the output window:

width : 100
height : 100
_width : 0
_height : 0

width : 100
height : 100
_width : 0
_height : 0

Obviously not the result I want. How can I get the dimensions of the content area for a View?

goliatone
01-17-2006, 10:58 AM
hi scottae...cant help you, but is not nice when you see one of your post with 0 replies. Heaz'up! Btw, the comp. u work for...visited the page. Nice

Scottae
01-17-2006, 03:29 PM
Appreciate it.

As far as the width and height go for the Accordion View, it seems that it's width and height are of whatever is attached to the View. So if you do this:

import mx.core.View;
import mx.containers.Accordion;

// Create an accordion
var my_acc:Accordion = createObject ("Accordion", "my_acc", 1);
my_acc.setSize (400, 300);

// Create the sections for the accordion
var first:View = View (my_acc.createSegment (View, "first", "First"));
var second:View = View (my_acc.createSegment (View, "second", "Second"));
var third:View = View (my_acc.createSegment (View, "third", "Third"));

var w:Number = 250;
first.beginFill (0xFF0000, 100);
first.lineTo (w, 0);
first.lineTo (w, w);
first.lineTo (0, w);
first.lineTo (0, 0);
first.endFill ();
trace (first._width);
trace (first._height);
trace (first.width);
trace (first.height);


Then you get this output:

250
250
100
100

This is rather worthless for me. I want to know the width and height of the visible area for the view. I guess I could hack my way to it using the width and height of the Accordion component itself, figure out how many sections are on it, figure the height of the header for each view, and then calculate the height for each View. But I was hoping for an easier more straight forward approach.