How to add dynamic names to MC in AS3?

Hello

I am trying to create a script simple enough image for a flash site. What it does is create a container named mc and then load a picture in the mc of XML. It traverses the XML file as in a loop for each. But the problem I have is that each container image then gets the name mc. So now when I try to compile the function that allows to press one of the containers image to enlarge, it is the last great picture because it's the last of them to be created with the name mc. So, how can I give each movieclip that I create a different name as mc1, mc2 etc.

This is my XML:

<? XML version = "1.0" encoding = "utf-8"? >

< entries >

< Entry >

< phpText > title < / phpText >

IMG/500.png < image > < / image >

< phpWidth > 500 < / phpWidth >

< phpHeight > 400 < / phpHeight >

< / Entry >

< Entry >

< phpText > title 3 < / phpText >

IMG/300.png < image > < / image >

< phpWidth > 300 < / phpWidth >

< phpHeight > 900 < / phpHeight >

< / Entry >

< Entry >

< phpText > Title2 < / phpText >

IMG/1440.png < image > < / image >

< phpWidth > 1440 < / phpWidth >

< phpHeight > 900 < / phpHeight >

< / Entry >

< Entry >

< phpText > title < / phpText >

IMG/500.png < image > < / image >

< phpWidth > 500 < / phpWidth >

< phpHeight > 400 < / phpHeight >

< / Entry >

< / input >

AS3 code:

import flash.events.Event;

Import fl.text.TLFTextField;

import flash.text.TextFieldAutoSize;

import flash.text.TextFormat;

import flash.display.Sprite;

import flash.display.MovieClip;

var iX:int = 15;

var iY:int = 15;

var tX:int = 15;

var tY:int = 100;

var id: int = 0;

var urlRequest:URLRequest = new URLRequest ("data.xml");

var urlLoader:URLLoader = new URLLoader();

urlLoader.addEventListener (Event.COMPLETE, urlLoaded);

urlLoader.load (urlRequest);

function urlLoaded(e:Event) {}

If {(urlLoader.data)

var entriesData = new XML (urlLoader.data);

var entries = entriesData.entry;

for each {(var entrée: XML entrées)}

Add variables

Shall var = entry.image;

var oText = entry.phpText;

var oWidth = entry.phpWidth;

var oHeight = entry.phpHeight;

Create image GraphHolder

var cont = ["mc" + id];

var mc:MovieClip = new MovieClip();

mc.graphics.beginFill (0xffffff);

mc.graphics.drawRect (0, 0, oWidth, oHeight);

mc.graphics.endFill ();

MC.x = iX;

MC.y = iY;

this.addChild (mc);

Add images to the GraphHolder

var urlReq1:URLRequest = new URLRequest (shall);

var urlLoad1:Loader = new Loader();

urlLoad1.load (urlReq1);

mc.addChild (urlLoad1);

MC. Width = 100;

MC. Height = 80;

mc.addEventListener (MouseEvent.CLICK, onClickHandler);

var origX = mc.x;

var origY = mc.y;

function onCloseHandler(myEvent:MouseEvent) {}

MC. Width = 100;

MC. Height = 80;

MC.x = origX;

MC.y = origY;

myTextField.visible = true;

mc.removeEventListener (MouseEvent.CLICK, onCloseHandler);

}

function onClickHandler(myEvent:MouseEvent) {}

If {(oWidth > 1060)

var allowedW = oWidth - 1060;

oWidth = oWidth - allowedW;

oHeight = oHeight - allowedW;

}

If {(oHeight > 700)

var allowedH = oHeight - 700;

oWidth = oWidth - allowedH;

oHeight = oHeight - allowedH;

}

myTextField.visible = false;

var picPosX = 1100 - oWidth;

var picPosY = 730 - oHeight;

MC.x = (picPosX / 2)-194;

MC.y = (picPosY / 2)-148;

MC. Width = oWidth;

MC. Height = oHeight;

mc.addEventListener (MouseEvent.CLICK, onCloseHandler);

}

Format textfield

var myFormat:TextFormat = new TextFormat();

myFormat.color = 0 x 000000;

myFormat.font = "Arial";

myFormat.size = 13;

Create new textfield

var myTextField:TextField = new TextField ();

myTextField.width = 100;

myTextField.x = tX;

myTextField.y = tY;

myTextField.selectable = true;

myTextField.type = TextFieldType.DYNAMIC;

myTextField.multiline = false;

myTextField.border = false;

myTextField.wordWrap = false;

myTextField.autoSize = TextFieldAutoSize.CENTER;

myTextField.defaultTextFormat = myFormat;

Add text to a textfield

myTextField.text = oText;

Add textfield

addChild (myTextField);

iX = iX + (mc.width + 15);

tX = tX + (mc.width + 15);

If {(iX > 650)

iX = 15;

iY = iY + 115;

tX = 15;

tY = tY + 115;

}

}

}

}

Very grateful for the help!

Best,

Linus

In the features that your buttons/mcs call when they get clicked is where you can use the event.currentTarget to target the.  Points to the object that was clicked event.currentTarget which has the event listener are entrusted to him.

Tags: Adobe Animate

Similar Questions

  • How to add the name of the title of graph in Excel

    Dear friends

    I'm using LabVIEW 8.0.I need how to add the name of the title of graph in Excel.

    You have the report generation tool? If so, the VI of graph Easy Excel has an entry for this.

    If you don't have the Toolbox, then you need to use ActiveX. Please do a search on the use of the ActiveX (there are examples provided with LabVIEW) to control Excel. Also, there are many examples in the thread Excel. NOTE: DON'T POST QUESTIONS IN THIS THREAD.

    In the end, you will need to search for information contained in MSDN.

  • How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    How can I dynamically load swc files using as3? (without relying on the Flash IDE).

    The SWF file can be used in the same way as the CFC, which means that you don't need to "visually show" anything when it is loaded. Your code can use the classes and assets incorporated into the SWF, just as a SWC file. So if someone just to load the SWF file to see what was in it that they see nothing. They could however access programmatically to what anyone on the inside just like you, if they went to that level. But it is not as easy as just racing as SWF to see what is inside.

    I hope that all packaging several separate sovereigns will allow you to load and unload only what you need to keep the RAM usage as low as possible with a minimum load SWF.

    If you are ready, please mark all useful/correct so we can filter without response. You're welcome and good luck!

  • How to add dynamic content?

    Hello

    How can I add dynamic content to my emails in eloqua?

    Thank you

    POOJA

    Hi Pooja,

    You can add dynamic content to be sent by two methods: -.

    1. You can write this code directly-"". ""                                              By this method, you can add dynamic content code offline
    2. Otherwise, you can co to eloqua code. When you expand the e-mail on the far left, you can get an option "Dynamic content" click on it, a black drop-down list will open type name of your content dynamic and this will directly add dynamic content in your code.

    Kind regards

    eDynamic Experts Eloqua

  • How to add dynamic items based on the results of a dynamic query?

    Hi all

    I'm quite new to ofa, here's my problem.

    I have a table 'interventions', each intervention have actions stored in the table "actions".

    I want to show the actions of an intervention in a list, based on the id of the intervention. the response ID value is dynamic, so does not know the number of shares that you want to display in the list.

    Can someone tell me the steps to create a region that has dynamic elements to display names of action?

    Thank you

    Kind regards

    Afaf

    Afaf,.

    Take a look on the link below to see how to create dynamic VO:

    Blog of Anil Oracle Application Framework: create VO when running at the controller or dynamically created VO

    You could add messageStyled text like the code below:

    OAMessageStyledTextBean newMessageBean = (OAMessageStyledTextBean) createWebBean (pageContext, MESSAGE_STYLED_TEXT_BEAN, null,"" ");

    Links to dynamically create elements below:

    Add columns to the table advanced in OA Framework Programatically by Extension

    OPS KNOWLEDGE HELPER

    Let us know if you get any errors when creating.

    See you soon

    AJ

  • How to add dynamic content to a .php model Dreamweaver

    OS: Windows 7

    DW Version: CS5

    PHP: XAMP Local Server

    I hope someone can help.  I created a Dreamweaver template for .php and created 5 pages of child of this model.  Everything is in working order as that is concerned.  Here's my problem:

    I want to add some dynamic data (categories) of a MySQL database to a non editable master section so that it flows to the pages of 5 children.  I can create a connection to the database without problem, but when I go to insert a recordset object in the model, it asks me to put in place the "site", the "document type" and the "test server" what I have done.  I'm sure it's because it's in watching the .dwt file type and saying that she should be a dynamic document such as .php.  I tried to go through these steps, but then it ends just rename my .php .dwt file and then it is no longer a model. I don't know why I can't add dynamic data to a dreamweaver template.  It seems that it should be a no-brainer, but it just isn't working for me.  In my research, I find the following

    http://help.Adobe.com/en_US/Dreamweaver/10.0_Extending/WS5b3ccc516d4fbf351e63e3d117f53d610 8 - 7fdb.html

    but wasn't completely sure how to apply it or if it involved only CS4 since I'm using CS5.  To be honest, it confused me more that it has helped.

    I really hope that there is a simple and logical solution to this issue because I have spent a lot of time to search for/test this.

    Any help/direction is greatly appreciated.  I don't want someone to just solve my problem and I'm willing to dig deep to learn, I just don't know where to go from here.

    Thanks again in advance for your help.

    Rename your yourtemplate.dwt.php model file.

    In other words, simply add .php at the end of your template file leaving the .dwt there.

    Brad Lawryk

    Adobe Professional Community: Dreamweaver

    The Northern British Columbia Adobe user group: Manager

    Thompson Rivers University: Dreamweaver instructor

    My Blog from Adobe: http://blog.lawryk.com

  • addChild (new button()) - how to add a name to this new created button

    Hello

    Lost my old username, I've been Pluda, now exPluda?

    Tring well, use a loop to add buttons to my work, but should refer to their names so I can have diferent x positions for each. How to do this?

    for (var sm:uint = 0; sm < sub_menus.length; sm ++) {}
    hsm.addChild (new bt_sub_menus());
    HSM.bt_sub_menus.x = hsm.x - 10;
    HSM.bt_sub_menus.y = hsm.bt_sub_menus.height + sm * 15;

    }

    This does not work, I just get a button placed where I want.

    Thank you!

    1. go to the faq section of the forum and send a private message to one of the admins to let them know.  they are very conscientious and helped me when my original kglad id has been changed in kglad-HNsomethingorother.

    2.

    for (var sm:uint = 0; sm< sub_menus.length;="" sm="" ++="" )="">

    var btn:bt_sub_menus = new bt_sub_menus()
    hsm.addChild (btn);
    BTN.x = hsm.x - 10;
    BTN.y = hsm.bt_sub_menus.height + sm * 15;

    }

  • How to add the name of a program in the AutoPlay menu? __In win xp, I used 'TweakUiPowertoySetup '; is there a program like that?

    Add in the name of a program in the Autoplay menu.

    Hi shayangh,

    You can use the 'default Programs editor' (third-party tool) to add / change AutoPlay entries.
    http://www.Winhelponline.com/blog/default-Programs-editor-file-association-editor-for-Windows-7-and-Vista/
    Ramesh Srinivasan, Microsoft MVP [Windows Desktop Experience]

  • Tutorial Dreamweaver Cs5.5 The Missing Manual (Pg 998-1018) about how to add dynamic data to your page

    Hallo,

    I made the tutorial: display of information from a database in the manual missing for Dreamweaver CS5.5.

    My problem is with ' edit a Recordset and linking to a detail Page ' (who starts at pg 1002):

    I've done this exercise, more nowe 5 times, but each time with 'Building the product detail Page' 1007 pg, I get a bad result.

    I have only one page (the one with productID = 1 by default) for each link on the indexpage.

    In the adressbar (Live View), I see the right address: for example: http://localhost/cos...hp?productID=16, but for all the productID only finishes for productID are presented.

    There is also a message: notice: use of undefined constant "productID" - assumed "productID" in E:\xampp\htdocs\cosmo_shop\product.php online 34

    But I don't understand what could be wrong in this line.

    Here are the lines of code 33-48: is is on the second line:

    $varProduct_rsDetails = "32";
    If (isset($_GET['productID'])) {}
    $varProduct_rsDetails = $_GET ['productID'];
    }
    @mysql_select_db ($database_connCosmo, $connCosmo);
    $query_rsDetails = sprintf ("SELECT products.productID, products.productName, products.price, products 'description', products.inventory, products.image, vendors.vendorName FROM products, suppliers WHERE products.vendorID = vendors.vendorID AND products.productID = %s", GetSQLValueString ($varProduct_rsDetails, "int") "");
    $rsDetails = mysql_query ($query_rsDetails, $connCosmo) or die (mysql_error ());
    $row_rsDetails = mysql_fetch_assoc ($rsDetails);
    $totalRows_rsDetails = mysql_num_rows ($rsDetails);

    @mysql_select_db ($database_connCosmo, $connCosmo);
    $query_rsCategories = "SELECT * FROM categories ORDER BY categoryName ASC ';
    $rsCategories = mysql_query ($query_rsCategories, $connCosmo) or die (mysql_error ());
    $row_rsCategories = mysql_fetch_assoc ($rsCategories);
    $totalRows_rsCategories = mysql_num_rows ($rsCategories);
    ? >

    Can someone tell me what is happening here?

    Best regards, years Hekerman

    An undefined constant is normally if you have something like

    $var [sometext]

    Where the "etc" is not cited.  Try to replace the single quotes the productID autour double quotes example: $_GET ['productID'].

  • How to add additional event on sample in AS3 event handler

    We can add AS2 is additional event on the same event handler in the code below.

    on (deployment, dragOut) {}

    Statement 1

    }

    Now, I'm workin in AS3. So, how do I add additional event on the AS3 event handler

    Display name of the instance of the object is 'myBtn. "

    Here I have included only outside mouse only, now, I want to add the additional event handler

    myBtn.addEventListener (MouseEvent.MOUSE_OUT, myBtnEvent);

    myBtnEvent(event:MouseEvent):void

    {

    Statement 1

    }

    myBtn.addEventListener (MouseEvent.MOUSE_OUT, myBtnEvent);

    myBtn.addEventListener (MouseEvent.MOUSE_OVER, myBtnEvent);

    myBtn.addEventListener (MouseEvent.MOUSE_DOWN, myBtnEvent);

    etc...

    function myBtnEvent(event:MouseEvent):void

    {

    1 or more statements based on events

    }

  • How to add a link to the html area to launch a dynamic action?

    Hey, guys:

    I need to add a link to a region of html hyper (I wish it could be a button :(), the value of the items in this region is loaded by a process of pl/sql before loading the header. And this link must trigger a dynamic action to update the database. I know how to add a link Super in this region, but how to define this link if I can launch a dynamic action by clicking on this link, could someone give me a hint?

    Thank you very much in advance.

    Sam

    Published by: lxiscas on April 11, 2013 17:04

    When I said updateRec I was just a name. Using the class alias_ncic will produce exactly the same result.
    Learn more about what you're trying to do, I wouldn't do that with DA at all. I would probably do the link send page and launch a process that call your PL/SQL. But if you must do a DA I'll try to explain a technique below.

    When you say

    Then, I pass two values of two hidden variables:

    P216_H_NCIC_APPROVE_TABLE_NAME---> "SOR_ALIAS".
    P216_H_NCIC_APPROVE_KEY_VALUE---> #ALIAS_ID #.

    Your link not pass anything because you never actually call the link, you have a DA of the substitution of the link action.

    So... try something like that. Use it for your link attributes:

    onclick="return false;" class="alias_ncic" title="NCIC Approve" id="#ALIAS_ID#" rel="SOR_ALIAS"
    

    This defines two attributes more to enter the values you need to.

    In yourself DA action on a.alias_ncic add two actions to "set the value.
    1.
    Action: Set
    Set Type: Javascript
    JavaScript expression: this.triggeringElement.getAttribute ("id")
    Assigned items: P216_H_NCIC_APPROVE_KEY_VALUE

    2.
    Action: Set
    Set Type: Javascript
    JavaScript expression: this.triggeringElement.getAttribute ("rel")
    Assigned items: P216_H_NCIC_APPROVE_TABLE_NAME

    Now you have your values defined.
    Make sure that in your PL/SQL Execute Code action you both of these elements in the field "Page to go" so that they values are actually passed.

    That should do it.
    Thank you
    -Jorge

    Published by: jrimblas on April 29, 2013 16:49

  • How can I add a name to the face?

    In Photos 1.5, El Capitan 10.11.5, how can I add a name to a face that is not recognized by the software of pictures (because it is cut by the framework)?

    -Gil

    Oops!  I found this: Ctrl-click on the editable version and pops up a menu... Get Info has a button "Add Faces".

  • I would like to add a name above that too good image that match wii the other images, how can I do this?

    I would like to add a name above that too good image that match wii the other images, how can I do this?F Page 20 copy.jpg

    No, it's a photo,

    It looks like a collage of four photographs with some texts.

    If you do not have the texts as text layers, you must determine the fonts used, then you can create a text with additional text layer.

  • I would like to create an interactive pdf in Indesign - two guest on 1 page in Indesign that when exporting to adobe reader in pdf format, I can simply add new names that populate both copies and then be printable. Any help out there is how to make an ext

    Two invites on 1 page in Indesign that when exporting to adobe reader in pdf format, I can simply add new names that populate both copies and then be printable. Any help out there is how to make an invitation in Indesign, but now how to make 2 copies on a single page that someone else ie the customer can add their own names. So each field name must complete on both guest. Sounds simple, but is not really there to help. I think he called an interactive pdf. Thanks in advance.

    AutoFill is the easiest part, he lies. If both fields have the same name, they will have the same content: type in one and it appears in the other.

  • How can I add meta name = "ad.size" on HTML5 canvas

    Hi all

    How can I add < meta name = "ad.size" content ="width = 300, height = 250" > in HTML5 Canvas code?

    Thank you

    manually add it to the html file.

Maybe you are looking for

  • Cannot access the videos of Confederated Tribes of the grand ronde

    I tried to access a video from a tribal site and couldn't; you have an error message on a plug-in? What that Plug and where can I find?

  • MacBook 2012 w / external monitor - cooler open or closed?

    Hello A very simple question; I'm looking for some advice on my rapidly aging Macbook Pro. I am running 10.11.3 on a 13 inch, mid 2012 Macbook Pro. 2.9 i7 GHz, 16 GB RAM, SSD, Intel HD Graphics 4000 1536 mb. I connected it to a monitor 27 "beautiful

  • Satellite A300 PSAG4E - multimedia keys do not work on Windows XP

    Hello I have a Toshiba Satellite A300, model PSAG4E. I installed all the utilities of the shortcut key that I could find the drivers, but the multimedia keys download page don't wok. Can someone help me?

  • HP: locked out

    I have a laptop touchscreen Hp, model # 15 - 1010wm and I have set the power/administrator password and forgot. Please help me to get back into it.

  • Factory programs

    Hello My laptop was crashing often, so a friend of mine wiped. It is works well now (fast, no crash, ect), but I'm missing the programs installed in the factory. Where could I download these? I only see one of my drives (hard drive shows, but I had a