PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Positioning MCs according to height - Page 2
A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 41

Thread: Positioning MCs according to height

  1. #21
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Test in debug mode or with the debug player. It should tell you a line number.

  2. #22
    Member
    Join Date
    Mar 2007
    Posts
    69
    Ah. Seems to be this line:

    Code:
    column.addChild(newsPost);

  3. #23
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Column is set here:
    Code:
    var column:DisplayObjectContainer = sectionpage.columns[0];
    And sectionpage.columns[0] should be newsPage, because that's what we pushed into the new columns array. BUT, I suspect that the newsPage variable you have declared is NOT the the same as sectionpage.newsColumn. If that's the case, then newsColumn would never have been instantiated and that error would make sense.

    Try removing the newsColumn variable, and using sectionpage.newsColumn where we previously just had newsColumn (should just be the push line).

  4. #24
    Member
    Join Date
    Mar 2007
    Posts
    69
    you are good! that worked.

    So now i've populated the XML file with 8 entries we have 3 columns sitting side by side.. great! Only thing is the 2 columns are sitting about a 3rd lower than the first column.. despite me putting a Y postiion in here..

    Actionscript Code:
    column = new Sprite();
                        column.x = nextX;
                        column.y = 0;

  5. #25
    Member
    Join Date
    Mar 2007
    Posts
    69
    nevermind, just made it -115 and it lined up nicely.

    So i've worked out how to target the columns and slide them by using :

    Code:
    TweenLite.to(sectionpage.columns[0], 5, {x:500,ease:Linear.easeIn});
    What's the best way do you think to get the scrolling buttons working ?

    The only way i think i can do it (with my knowledge) is by using some counter variables. So at the start you have a Right button, and the counter is 0. If counter is 0 then move column[0] to x and column[1] to view, change counter to 1, reveal Left button.

    Seems long winded..

  6. #26
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    More or less something like that. I don't know what would work best for you in that regard.

  7. #27
    Member
    Join Date
    Mar 2007
    Posts
    69
    Ok - Is there a way to target all of the columns as one in its current state, or will i need to create another container?

  8. #28
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    At the moment, the columns are added to the sectionpage. You could manipulate the section page, but that may do stuff you don't want. You could iterate through the columns array and do stuff to each column. But if you wanted to put them in a container just for them, that would let you move and mask them all together.

  9. #29
    Member
    Join Date
    Mar 2007
    Posts
    69
    ok... thanks ever so much for all your help. there's been a lot to take in but i think i've learnt a lot from this.

  10. #30
    Member
    Join Date
    Mar 2007
    Posts
    69
    I'm trying to put the columns into a container to enable me to mask them but im struggling to get the mask to work. Could you tell me if i've correctly put the columns in a container here?

    Actionscript Code:
    public class NewsPage extends AbstractPage
        {

            // Declare instances on stage in NewsPage.fla
            public var bgbutton:SimpleButton;
            public var closebutton:SimpleButton;
           
            public var sectionpage:MovieClip;
            public var containerMC:MovieClip;
            public var newsMask:MovieClip;
           
            public var arrowLeft:SimpleButton;
            public var arrowRight:SimpleButton;

            public var textTitle:TextField;
            public var textBody:TextField;

            public var myXML:XML;

            public function NewsPage()
            {
                super();
            }
            override public function transitionIn():void
            {
                super.transitionIn();
                gotoAndPlay("in");
                sectionpage.containerMC.mask = newsMask;
                sectionpage.textBody.styleSheet = IStyleSheet(Gaia.api.getPage("index").assets.stylesheet).style;

                var myXML:XML = IXml(assets.newsContent).xml;

                sectionpage.textTitle.htmlText = myXML.sectionContent.title;
                sectionpage.textBody.htmlText = myXML.sectionContent.body;


                var dateFormat:TextFormat = new TextFormat();
                dateFormat.color = 0xFFFFFF;
                dateFormat.font = Gaia.api.getFontName("DIN");
                dateFormat.size = 18;

                var posts:Array = [];
                var lastY:Number = 0;
               
                sectionpage.columns = [];
                sectionpage.columns.push(sectionpage.newsColumn);
               
                var columnHeight:Number = 330;

                var column:DisplayObjectContainer = sectionpage.columns[0];

                for (var i:int = 0; i<myXML.news.length(); i++)
                {
                    var date:String = myXML.news.newsDate[i];
                    var title:String = myXML.news.newsTitle[i];
                    var body:String = myXML.news.newsBody[i];
                    var newsPost:NewsPost = new NewsPost(date,title,body,dateFormat);
                    posts.push(newsPost);

                    if (lastY + newsPost.height > columnHeight)
                    {
                        var nextX:Number = column.x + column.width;
                        column = new Sprite();
                        //column.x = nextX;
                        column.x = 300;
                        sectionpage.columns.push(column);
                        sectionpage.containerMC.addChild(column);
                        column.y = -115;
                        lastY = 0;
                    }

                    column.addChild(newsPost);

                    //sectionpage.newsColumn.addChild(newsPost);
                    newsPost.y = lastY;
                    lastY +=  newsPost.height + 40;

                }

    Many thanks.

  11. #31
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    After the first column, that looks right. But since you're putting sectionpage.newsColumn as the first column, it is still outside the containerMC.

  12. #32
    Member
    Join Date
    Mar 2007
    Posts
    69
    Is newsColumn needed? can the first column be created like the other columns are?

  13. #33
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    No, it isn't needed, and yes it can be created just like the others. The only reason it was used in the first place was because I thought you had placed it manually and wanted to fill it first.

    To generate the column like the others, create a new Sprite and push that into the columns array. Also put the sprite on the display list.
    Code:
    var column:DisplayObjectContainer = new Sprite();
    sectionpage.containerMC.addChild(column);
    sectionpage.columns = [];
    sectionpage.columns.push(column);
    //...

  14. #34
    Member
    Join Date
    Mar 2007
    Posts
    69
    Hmm.

    I'm getting TypeError: Error #1010: A term is undefined and has no properties.

    debugger won't give me a line number..

    This is my code now..

    Actionscript Code:
    override public function transitionIn():void
            {
                super.transitionIn();
                gotoAndPlay("in");
                // Prevent main nav from being clicked in background
                bgbutton.useHandCursor = false;

                //Opening page animation
                sectionpage.scaleX = 0.2;
                sectionpage.scaleY = 0.2;
                newsMask.scaleX = 0.2;
                newsMask.scaleY = 0.2;
               
                TweenLite.to(sectionpage, 0.2, {x:388,y:382,scaleX:1,scaleY:1,ease:Linear.easeOut});
                TweenLite.to(newsMask, 0.2, {x:388,y:382,scaleX:1,scaleY:1,ease:Linear.easeOut});

                //CLOSE BUTTON;
                sectionpage.closebutton.addEventListener(MouseEvent.CLICK, closeFunction);

                function closeFunction(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage, 0.2, {alpha:0,ease:Linear.easeIn});
                    Gaia.api.goto(Pages.HOME);
                }
               
                //sectionpage.arrowLeft.cacheAsBitmap = true;
                newsMask.cacheAsBitmap = true;
                sectionpage.containerMC.cacheAsBitmap = true;
                sectionpage.containerMC.mask = newsMask;
               
               
                sectionpage.textBody.styleSheet = IStyleSheet(Gaia.api.getPage("index").assets.stylesheet).style;

                var myXML:XML = IXml(assets.newsContent).xml;

                sectionpage.textTitle.htmlText = myXML.sectionContent.title;
                sectionpage.textBody.htmlText = myXML.sectionContent.body;


                var dateFormat:TextFormat = new TextFormat();
                dateFormat.color = 0xFFFFFF;
                dateFormat.font = Gaia.api.getFontName("DIN");
                dateFormat.size = 18;
               
               
               

                //sectionpage.containerMC.columns = [];
                //sectionpage.containerMC.columns.push(sectionpage.containerMC.newsColumn);
                var posts:Array = [];
                var lastY:Number = 0;
               
                var columnHeight:Number = 330;

                //var column:DisplayObjectContainer = sectionpage.containerMC.columns[0];
                var column:DisplayObjectContainer = new Sprite();

                sectionpage.containerMC.addChild(column);
                sectionpage.columns = [];
                sectionpage.columns.push(column);
               
                for (var i:int = 0; i<myXML.news.length(); i++)
                {
                    var date:String = myXML.news.newsDate[i];
                    var title:String = myXML.news.newsTitle[i];
                    var body:String = myXML.news.newsBody[i];
                    var newsPost:NewsPost = new NewsPost(date,title,body,dateFormat);
                    posts.push(newsPost);

                    if (lastY + newsPost.height > columnHeight)
                    {
                        var nextX:Number = column.x + column.width;
                        column = new MovieClip();
                        //column.x = nextX;
                        column.x = 600;
                        sectionpage.columns.push(column);
                        sectionpage.containerMC.addChild(column);
                        column.y = 0;
                        lastY = 0;
                    }

                    column.addChild(newsPost);

                    //sectionpage.newsColumn.addChild(newsPost);
                    newsPost.y = lastY;
                    lastY +=  newsPost.height + 40;

                }
               
                // Counters to help determine column position
                var activeCol:Number = 0;
                var nextCol:Number = 1;
                var prevCol:Number = -1;
                var totalPosts:Number = sectionpage.containerMC.columns.length-1;
               
               
                sectionpage.arrowLeft.alpha=0;
                sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
                sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
               
                function arrowLOFF():void{sectionpage.arrowLeft.visible=false;}
                function arrowROFF():void{sectionpage.arrowRight.visible=false;}
               
                function scrollLeft(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:600,ease:Linear.easeOut});
                    TweenLite.to(sectionpage.containerMC.columns[prevCol], 0.25, {x:0,ease:Linear.easeOut});
                    activeCol--;
                    nextCol--;
                    prevCol--;
                   
                    if (activeCol == 0)
                    {
                        sectionpage.arrowLeft.removeEventListener(MouseEvent.CLICK, scrollLeft);
                        TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:0,onComplete:arrowLOFF});
                       
                    }
                   
                    if (activeCol == totalPosts-1)
                    {
                        sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
                        sectionpage.arrowRight.visible=true;
                        TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:1});
                       
                    }
                }

                function scrollRight(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:-600,ease:Linear.easeOut});
                    TweenLite.to(sectionpage.containerMC.columns[nextCol], 0.25, {x:0,ease:Linear.easeOut});
                   
                    activeCol++;
                    nextCol++;
                    prevCol++;
                   
                    if (activeCol == totalPosts)
                    {
                        sectionpage.arrowRight.removeEventListener(MouseEvent.CLICK, scrollRight);
                        TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:0,onComplete:arrowROFF});
                    };
                    if (activeCol == 1)
                    {
                        sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
                        sectionpage.arrowLeft.visible=true;
                        TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:1,ease:Linear.easeOut});
                    }
                }

  15. #35
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Sorry, I don't see the error. If you can narrow it to the line, that would help.

  16. #36
    Member
    Join Date
    Mar 2007
    Posts
    69
    I think it might be something in this area as if i comment it out the error doesn't come up:

    Actionscript Code:
    sectionpage.arrowLeft.alpha=0;
                sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
                sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
               
                function arrowLOFF():void{sectionpage.arrowLeft.visible=false;}
                function arrowROFF():void{sectionpage.arrowRight.visible=false;}
               
                function scrollLeft(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:600,ease:Linear.easeOut});
                    TweenLite.to(sectionpage.containerMC.columns[prevCol], 0.25, {x:0,ease:Linear.easeOut});
                    activeCol--;
                    nextCol--;
                    prevCol--;
                   
                    if (activeCol == 0)
                    {
                        sectionpage.arrowLeft.removeEventListener(MouseEvent.CLICK, scrollLeft);
                        TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:0,onComplete:arrowLOFF});
                       
                    }
                   
                    if (activeCol == totalPosts-1)
                    {
                        sectionpage.arrowRight.addEventListener(MouseEvent.CLICK, scrollRight);
                        sectionpage.arrowRight.visible=true;
                        TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:1});
                       
                    }
                }

                function scrollRight(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:-600,ease:Linear.easeOut});
                    TweenLite.to(sectionpage.containerMC.columns[nextCol], 0.25, {x:0,ease:Linear.easeOut});
                   
                    activeCol++;
                    nextCol++;
                    prevCol++;
                   
                    if (activeCol == totalPosts)
                    {
                        sectionpage.arrowRight.removeEventListener(MouseEvent.CLICK, scrollRight);
                        TweenLite.to(sectionpage.arrowRight, 0.25, {alpha:0,onComplete:arrowROFF});
                    };
                    if (activeCol == 1)
                    {
                        sectionpage.arrowLeft.addEventListener(MouseEvent.CLICK, scrollLeft);
                        sectionpage.arrowLeft.visible=true;
                        TweenLite.to(sectionpage.arrowLeft, 0.25, {alpha:1,ease:Linear.easeOut});
                    }
                }

  17. #37
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Not seeing it there either, unless sectionpage.arrowLeft or sectionpage.arrowRight is null.

  18. #38
    Member
    Join Date
    Mar 2007
    Posts
    69
    I think its this line:

    Actionscript Code:
    var totalPosts:Number = sectionpage.containerMC.columns.length-1;

    If i remove the containerMC from that line, it works... but then when i click the arrows, it gives me this error:

    TypeError: Error #1010: A term is undefined and has no properties.
    at Function/<anonymous>()

  19. #39
    Member
    Join Date
    Mar 2007
    Posts
    69
    Got it..

    Removed containerMC from these lines too and that worked.

    Actionscript Code:
    function scrollRight(evt:MouseEvent):void
                {
                    TweenLite.to(sectionpage.containerMC.columns[activeCol], 0.25, {x:-600,ease:Linear.easeOut});
                    TweenLite.to(sectionpage.containerMC.columns[nextCol], 0.25, {x:0,ease:Linear.easeOut});
                   
                    activeCol++;
                    nextCol++;
                    prevCol++;

    Does that make sense or does that highlight that something is wrong?

  20. #40
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    It makes sense. We added columns as a property of sectionpage, not of containerMC. Even though the columns are on the containerMC's display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center