How can I position MCs in the scene as words wrapped in a page? Mathematical problem.

Hello world

I am trying to position a few MCs in rows in the scene (dynamically created MCs) in such a way that, when they reach a max width they jump up to a line, such as words wrapped in a page with left alignment, or to explain, as the scheme of image attached. Each MC has a different width.

I tried a lot of things without success. But I guess that I'm almost there. Right now I use a table that retrieves each width of MCs and another who gets the sum of the widths.

Here is my code, important elements in red:

CREATE MENU CONTAINER.

var menuContainer:MovieClip = new MovieClip();

menuContainer.x = 10;

menuContainer.y = 500;

addChild (menuContainer);

CREATE IMAGES CONTAINING MC.

var imagesContainer:MovieClip = new MovieClip();

imagesContainer.x = 10;

imagesContainer.y = 10;

addChild (imagesContainer);

CHARGERS IMAGE.

var imagesLoader:Loader;

var bigImagesLoader:Loader;

TABLES.

var imageLoadArray:Array; stores the respective URL of each image in each button

function sum(array:Array,_ini:int=0,_fin:int=-1):Number {/ / function to sum bays}

fin = (is-1)? array.length: end;

var sumArrays:Number = 0;

for (var u: uint = ini; u < fin; u ++) { }

If (typeof (array [u]) == 'number') { }

sumArrays += array [u];

}

}

return sumArrays;

}

var imgPosArray:Array = new Array (); creates the table that defines the position of the images in the Gallery

var imgPos:Number;

LOAD THE XML.

var xmlLoader:URLLoader = new URLLoader();

xmlLoader.addEventListener (Event.COMPLETE, whenLoaded);

xmlLoader.load (new URLRequest("XML/roiaXML.xml"));

var xml;

function whenLoaded(evt:Event):void {}

xml = new XML (evt.target.data);

var mySetsList:XMLList=xml.children();

/ / / MENU BUTTONS.

/ / POSITIONING of the BUTTONS on the INSIDE OF THE CONTAINER MENU.

var rowMaxWidth:Number = 500;

var totalWidth:Number;

Var: line number;


var cellWidthArray:Array = new Array();

var sumCellWidthArray:Array = new Array();

/ / CREATE BUTTONS.

for (var i: int = 0; i < mySetsList.length (); i ++) {}

var newSetButtonMC:setButtonMC = new setButtonMC();

//

imageLoadArray = new Array();

for (var j: int = 0; j < mySetsList [i].) IMAGE.length (); j++) {

imageLoadArray [imageLoadArray.length] = mySetsList [i]. IMAGE [j]. Attribute ("smallURL");

}

newSetButtonMC.imageArray = imageLoadArray;

//

newSetButtonMC.setButtonText.text = mySetsList.attribute ("setTitle") [i];

newSetButtonMC.setButtonText.autoSize = TextFieldAutoSize.LEFT;

//

cellWidthArray [cellWidthArray.length] = newSetButtonMC.setButtonText.width;

sumCellWidthArray [sumCellWidthArray.length] = sum(cellWidthArray,0,i);

trace(cellWidthArray[i]);

totalWidth = sum(cellWidthArray,0,i);

row = Math.floor (totalWidth/rowMaxWidth);


newSetButtonMC.x = sumCellWidthArray [i] +(i*10);

newSetButtonMC.y = (newSetButtonMC.height + 10) * rank;

newSetButtonMC.buttonMode = true;

newSetButtonMC.addEventListener (MouseEvent.CLICK, onClickButton);

menuContainer.addChild (newSetButtonMC);

}

/ / / MENU BUTTONS ACTIONS.

function onClickButton(mevt:MouseEvent):void {}

/ / LOAD the IMAGES in the GALLERY.

var targetButton:setButtonMC = setButtonMC (mevt.currentTarget);

imgPos = 0;

imgPosArray.length = 0;

for (i = 0; i < targetButton.imageArray.length; i ++) {}

imagesLoader = new Loader();

imagesLoader.load (new URLRequest (targetButton.imageArray [i]));

imagesLoader.contentLoaderInfo.addEventListener (Event.INIT, getImageWidth);

imagesLoader.x = i 200;

imagesContainer.addChild (imagesLoader);

/ / BIG LOAD IMAGE WHEN click ON the IMAGE OF the GALLERY.

imagesLoader.addEventListener (MouseEvent.CLICK, loadBigImage);

}

}

function getImageWidth(evt:Event):void {/ / this function get the widths of images}

imgPos = evt.currentTarget.width;

/ / trace (imgPos);

imgPosArray [imgPosArray.length] = imgPos;

trace (imgPosArray);

}

function loadBigImage(evt:MouseEvent):void {}

trace ("ok");

}

}

Thank you very much

Abstrato

If one is your array of movieclips and space is white space between the end of a movieclip and the start of the next leading is the space between adjacent lines and width is the maximum width of your lines and you want your movieclips begin to startX, startY, you can use the function below to organize your movieclips:

function arrangeMCF (a: startX:uint, startY: uint, space: uint, attack: uint, table, width: uint) {}

var curentX:Number = startX;

var YCourant: Number = startY;

for (var i: uint = 0; i<>

If (a [i] .width + currentX<>

a [i] .x = currentX;

a [i] there = currentY;

currentX += [i] .width + space;

} else {}

currentX = startX;

+= currentY leading;

a [i] .x = currentX;

a [i] there = currentY;

currentX += [i] .width + space;

}

}

}

Tags: Adobe Animate

Similar Questions

  • How can I get rid of the coding that adds more than one page to print email?

    I now get more than just the sender, date, and issue information in emails. What information from "source"? Is it possible that I can print the email without printing the part "source"? I tried to copy what I would get if I printed the e-mail, but it's beyond my skill level. I hope that there is a switch somewhere that I can change to fix this problem.
    Thank you

    View | Headers | Normal

    I think that yours is set to "All".

  • How can I get rid of the summer in stationary Beach scene. I would like to clearly except for special occasions.

    How can I get rid of the beach scene in stationary yahoo. It returns automatically when I press on answer or dial. HE's NOT been in the NO. I prefer a white sheet with the exception of the times. Thank you.

    The different sections of this Yahoo help section help you return to a blank message body or go to a model you like best?

    Stationery in Yahoo Mail
    https://help.Yahoo.com/kb/SLN25498.html

  • When I create two keyframes at the same position between keyframes at different positions this way adds a loop. How can I get rid of the loop?

    When I create two keyframes at the same position between keyframes at different positions this way adds a loop. How can I get rid of the loop? I was just by dragging the handles on the vertex point, but I want to get rid of the loop together.

    Focus on the Bezier handles on the motion path in the Composition window. You can select the tool pen (g) and hold down the Alt/Option key to select the tool convert Vertex (it looks like a V on the side) and then fix the handle manually or click on the top of the trajectory to change it to a straight line. You can also play with spatial interpretation Keyframe.

    To avoid this, you can change the interpolation of keyframes in space to linear preferences. Most of the time I don't like straight so I keep my default value of Bézier.

  • How can I get rid of the big blue circle in maps 2.0 El Capitan

    How can I get rid of the big blue circle in Maps 2.0 OSX El Capitan

    Disable location or to put services in place of a localization solution better (circle will shrink, but does not completely disappear). The blue circle shows the uncertainty of the position. There will always be a degree of uncertainty.

  • How can I get rid of the message air play?

    How can I get rid of the message air play on 4th gen apple tv?

    MSG continuously appears on the television screen while screen saver is turned on by using apptv 4th gen

  • How can I restart firefox with the same tabs and windows?

    How can I restart firefox with the same tabs and windows?

    It is not in the file menu or tools. I get nothing when searching for help. FF still knows how to do it, say to update extensions.

    I know that I can do by saving my session, coming out, reboot and restore the session but is there a single command to do this?

    Thank you. -David

    I have attached a screenshot showing how to select restore automatic session just above the setting of the Home Page where it says "When Firefox starts".

    With this set, you can restart Firefox manually out using the menu-

    • "3-bar" menu button > button "power".
    • (menu bar) File > Exit

    -and then restart Firefox.

    If you want a real reboot with a click of button, you can check something on the Add-ons site: https://addons.mozilla.org/firefox/

  • How can I find out what the file extension is an attachment to an email?

    I get an email with an attachment, I can not open with any of the applications that I have in my Ubuntu 14.04. How can I find what is the extension of the attached document, so I can find an attachment that can open and store?

    I can't save it on the disk without the aid of an application

    I am really curious what you could not do. There is no problem with saving a file on the disk without file extension.

    I don't like when a program hides important details of me

    I don't think that there is nothing that Thunderbird is hiding from you. Most likely the attachment is not a file extension - for any reason.

  • How can I disable one of the menus looking desktop?. Right SWIP

    How can I disable one of the menus looking desktop?. Right SWIP

    Hi mzdbid,

    I understand that you want to change some of the search results you see featured on your iPhone. I know it's important to have your iPhone to work more efficient for you, so I'm happy to provide advice to help with this.

    See the steps on how to change the apps are included in Spotlight Suggestions here:

    Use the search on your iPhone, iPad or iPod touch - Apple Support

    Change search settings

    Go to settings > general > Spotlight search.

    From there, you can enable or disable the Suggestions of Siri and choose which applications to include in your search. For example, if you don't want to see the results of the research in your Messages app, you can deselect Messages.

    If you don't want Siri or Spotlight to suggest close places, go to settings > privacy > location Services. Then click on System Services and disable Safari & Suggestions of Spotlight. Find out where you can use the Spotlight Suggestions.

    Thank you for using communities of Apple Support, cheers!

  • How can I do to get the Apple CERT?

    How can I do to get the Apple CERT?

    http://training.Apple.com

  • I have a site designed iWed which I can't = up to date. I want to design a new Web site with a different place (everweb?) How can I get rid of the current site? I want to use the same domain name.

    I have a designed iWeb site I need to update. I know I can't use iWeb so want to design and publish a new Web site. I want to use my current domain name. How can I get rid of the existing site?

    So, you want to delete this Web site. That's right?
    If so, you can make trought accessing the website 'admin panel' or 'FTP '.

    An administration panel (or "administration panel") is a site that your host/domain provides to you, where you can change everything you want - even is for 'FTP', 'FTP' is a server where you access your Web site and change what you want, and that includes delete the current Web site.

    Questions please ask.

  • How can you save data of the iCloud on an external hard drive?

    How can I record data of the iCloud on an external hard drive?

    Is not possible. iCloud requires a Wi - Fi connection to synchronize data. Cannot do it on an external drive.

  • In Plugins, I have two versions of Adobe Acrobat - how can I get rid of the old?

    In Plugins (and Applications), it shows two Adobe Acrobat version: 10.1.13.16 and 11.0.10.32, how can I get rid of the old?

    Fix. If you think there may be a problem, follow these instructions;

    Take uninstaller from here:
    Uninstall Flash Player | Windows
    Uninstall Flash Player | Mac
    Reinstall the latest version.

    Flash Player Version 16.0.0.305
    https://www.Adobe.com/products/flashplayer/distribution3.html

    Shockwave Director Version 12.1.7.157 http://get.adobe.com/shockwave/

    Opps, Sorry, wrong instructions.

    Remove the two programs. Then install the current.

  • How can I get rid of the pesky "what's new in Pages '?

    How can I get rid of the pesky "what's new in Pages '?

    Unless there is a check box on that, what's new dialogue to prevent future events, and then create and save a Pages document. In both cases, who must still remove the instances of that message. There is no preferences, or the menu setting.

  • How can I remove links to the latest features of the homepage of FF

    How can I remove links to the latest features of the homepage of FF. See screenshot. I want deleted url.
    Sorry screenshot has not shown the first time


Maybe you are looking for