Honeycomb arrangement Type

Source: Internet
Author: User
Tags addchild

Abstract: According to the different parameters, intelligent display cellular layout, the effect of:

Production steps:

1. Build a MC binding name "MYMC" in the Library

2, build a document class, the code is as follows:

1  Package2 {3     ImportFlash.display.Sprite;4 5     /**6 * @author ChB7 * @data 2015-8-268 * @email [email protected]9      */Ten  One      Public classReseaulayoutextendsSprite A     { -         Private varContainer:sprite; -          Public functionreseaulayout () the         { - init (); -         } -  +         Private functionInit ():void -         { +container =NewSprite (); A              This. AddChild (container); atcontainer.x = stage.stagewidth * 0.5; -CONTAINER.Y = 200; -SetLayout (15,175,3); -         } -         /* - * @param number of _count hexagons in * @param itemw hexagon Width - * @param gap interval to * @param type of honeycomb, a group of how many hexagons + * @param num number in each group -         * the         */ *  $         Private functionSetLayout (_count: Number, ITEMW: Number, Gap: Number, type: Number= 3,num: Number= 1):voidPanax Notoginseng         { -             if(_count > 10) the             { +Type = 5; A             } the  +             varItemy: Number= ITEMW * Math.Cos (30*math.pi/180);//Represents the y-axis gap between every two hexagons -             varItemX: Number= ITEMW * 0.5;//represents the X-axis gap between each of the two hexagons $  $              for(varI Number= 0; i<_count; i++) -             { -                 varItem:sprite =NewMYMC ();//hexagon Unit, inside the library bound the container.addchild (item); -                 varGroupnum: Number= Int (i/Type);Wuyi                 if(num = = 1) the                 { -item.x = groupnum* (itemw+gap); WuITEM.Y = Itemy * 2; -                 } About                 Else if(num = = 2) $                 { -  -Item.x = ITEMW/2+groupnum* (ITEMW+GAP); -ITEM.Y = Itemy * 2-itemy-Gap; A  +                 } the                 Else if(num = = 3) -                 { $Item.x = ITEMW/2+groupnum* (ITEMW+GAP); theITEM.Y = Itemy * 2 + itemy +Gap; the                 } the                 Else if(num = = 4) the                 { -Item.x = ITEMW/2+groupnum* (ITEMW+GAP) + ITEMW/2 +Gap; inITEM.Y = Itemy * 2-itemy * 2-gap*2; the                 } the                 Else if(num = = 5) About                 { theItem.x = ITEMW/2+groupnum* (itemw+3) + ITEMW/2 +Gap; theITEM.Y = Itemy * 2 + itemy * 2 + gap*2; the                 } +num++; -                 if(num = = (type+1)) the                 {Bayinum = 1; the                 } the             } -         } -  the     } the  the}

Honeycomb arrangement Type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.