Issue with dynamic resizing

I am pulling a blog into flash through an XML sheet. I have a clip in the library that gets attached per blog entry. The issue I am having right now is not all the posts are the same length so I am trying to adjust the clips background to the height of the post text box, but they are all reading as the same height so they aren’t properly adjusting. I even have the text boxes set to autoSize = true;

Here is my code…the resizeBlog function is where I am trying to resize it and then I want to adjust its y property accordingly.


stop();
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(success)
{
    if (success)
    {
        var pagelength = xml.firstChild.childNodes.length;
        var depth = 100;
        for (var i = 0; i < pagelength; i++)
        {
            var mc = newsHolder.scrollContent.eventHolder.attachMovie("newsclip", "newsclip" + i, depth++);
            var node = xml.firstChild.childNodes*.attributes;
            var title = node.title;
            var author = node.author;
            var date = node.date;
            var post = xml.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
            mc.titletxt.text = title;
            mc.authordatetxt.text = "Posted by " + author + " on " + date;
            mc.posttxt.html = true;
            mc.posttxt.htmlText = post;
            mc.id = i;
            resizeBlog(mc.id);
        }
    } else
    {
        trace("cant load xml");
    }
};
xml.load("loadblog.php");

function resizeBlog(itemID)
{
    var mc = newsHolder.scrollContent.eventHolder["newsclip" + itemID];
    mc.newsbg._height = mc.newsbg._height + mc.posttxt._height;
    trace(mc.newsbg._height);
    //mc._y = itemID * mc.posttxt._height + 100;
}

Anyone have an idea how to do that?

I’m not an advanced scripter at all, but the first thing my brain is troubleshooting:

could it be that the text is not yet loaded at the moment of calculating the height of the movieclip it resides in?
The function seems properly written. Might just be an order problem.

Have you tried different combination?
If you make a post with only on line of text, are all the following post will have this same tiny height?
Or if you post a 20 lines paragraph, will the all the other clips be tall…

or it is just its default height all the time no matter what the post length is?

My point here is if you get the first height generate from the post length, this means that the clip gets resized accordingly. Then you would have to set up an array of background clips for each post.

I hope I’m clear… I understand Flash mechanics, since I have been using it for almost 10 years, but still don’t speak its language!

[quote=artriste;2343733]Have you tried different combination?
If you make a post with only on line of text, are all the following post will have this same tiny height?
Or if you post a 20 lines paragraph, will the all the other clips be tall…

or it is just its default height all the time no matter what the post length is?

My point here is if you get the first height generate from the post length, this means that the clip gets resized accordingly. Then you would have to set up an array of background clips for each post.

I hope I’m clear… I understand Flash mechanics, since I have been using it for almost 10 years, but still don’t speak its language![/quote]

If I trace out the height of the text box in my resizeBlog function, the text box height are the same on all, so it would say:


104.7
104.7
104.7
104.7

etc...

I do have the fields set to autoSize, but maybe that doesn’t adjust the height.

im at work right now and dont have my files, but I think I might of figured it out. So my attached movie clip has the AS on it that sets the text field autoSize to true. I made a simple little example here at work and put the autoSize attribute in the for loop and it traced out the correct height for each one. I think I may have found my solution.

Great, hope it is working.

I’d be interested in seeing this project when it’s live. There are not too many flash blogs around. Are you using Worpress or another service and build your flash based on it, or you come up with your own code?

Nah this is all my code…using mysql and php. I use PHP to create the XML then I bring the xml into flash…its live right now, just a work in progress.

http://drewestate.com/new/2008/

Click Twani on the left to see the blog. Nothing too crazy. The site is very heavy on using a database and php too. Has a complete custom backend cms too that ive been working on.

Very impressive.
Will there be comments added to the blog?

It seems that you managed to fix the height issue.

to solve the problem:
onLoadInit {resize}

[quote=artriste;2344260]Very impressive.
Will there be comments added to the blog?

It seems that you managed to fix the height issue.[/quote]

I doubt it. It wouldnt be hard to do though. If the client requests it I will.

[quote=Macsy;2344276]to solve the problem:
onLoadInit {resize}[/quote]

No use of movieClipLoader here. Its through XML.

i see. thought it was about loading a MC.
Then you make like a 100 ms delay before you show the loaded xml data.

its all good I figured it out alreayd.