How can I creat buttons in action script? Need a lot of buttons...

Hi guys, I'm trying to represent the pixels on my map with buttons. For this, I'm building a class card and I am trying to create a grid of 30 x 30 buttons. But there seems to be a problem when I try to display the buttons, I have seen in some cases, people were using the f1.controls.Button class, but I can't, all I have is the mx.controls.Button, so I think that's different here.

Try to see if you can help me with this one.

And another quick question, why he shouts with an error when I do this:

private var slot: button [30 [30];

Here is my class, and I was trying to do:

package world

{

import mx.controls.Button;

public class card

{

private accommodation var: Button;

public void Map()

{

var i: int;

var j: int;

for (i = 0; i < 30; i ++)

for (j = 0; j < 30; j ++)

{

slot [i] [j] = new Button();

slot [i] [j] .width = 30;

slot [i] [j] .hieght = 30;

slot [i] [j] .left = 40 + I * 30;

slot [i] [j] .top = 2 + j * 30;

AddChild (slot [i] [j]);

}

}

}

}

The ns1:MapButtonCanvas is the alias for the package that contains the map button object and is defined in the application tag.

Look at the xmlns:ns1 in the tag below.  He points to the package that owns the object MapButtonCanvas. (ns is namespace).

<>

' xmlns:MX ='http://www.adobe.com/2006/mxml ' layout = "vertical".

Width = "100%" height = "100%" backgroundColor = "#eaf1f6."

backgroundGradientAlphas = "1.0,1.0.

xmlns:ns1 = "" com.somaint.View. * ">"

Take a look at the real object of MapButtonCanvas and you can see that the name of the package is identical to the ns1 from above.

package com.somaint.view {}

Import mx.containers.Canvas;

Import mx.controls.Button;

SerializableAttribute public class MapButtonCanvas extends Canvas {}

public void MapButtonCanvas() {}

So the code below is said to look into ns1 (i.e. com.somaint.view) for the MapButtonCanvas object.

Your package names will be different and you will need to change the name in the Application tag and in the MapButtonCanvas object.

Insofar as your buttons for the performance of the functions, you need to add an event dispatcher clicked every button.

Here is another version of the MapButton.  It is contained in a single application without popping the pimple of the card to its own component.

Compare the two and see how they are in fact the same.  I added a name attribute and a listener of click event handler for the button that displays the name at the bottom of the page.  The creationcompletehandler executed after the application is created and built the buttons

<>

xmlns:MX ="http://www.adobe.com/2006/mxml"layout = "vertical"

Width = "100%" height = "100%" backgroundColor = "#eaf1f6."

backgroundGradientAlphas = "1.0,1.0.

creationComplete = "creationCompleteHandler ()" > "

Import mx.controls.Button;

public function creationCompleteHandler (): void {}

var i: int;

var j: int;

for (i = 0; i<30;i++)>

for (j = 0; j<30;j++)>

var btn:Button = new Button();

BTN. Width = 30;

BTN. Height = 30;

btn.setStyle ("left", 40 + i * 30);

btn.setStyle ("top", 2 + j * 30);

btnCanvas.addChild (btn);

}

}

}

private void clickButton(e:Event):void {}

btnClickLbl.text = e.currentTarget.name;

}

]]>

Tags: Flex

Similar Questions

  • How can I create a single action that hides several items at once?

    I create what I call a "video jukebox", and I would like to find an easier way to switch between videos, according to which the button is clicked. For example, I have 7 videos for viewers to choose.

    On the stage to animate are 7 buttons, each button corresponding to the appropriate video.

    I also added 7 videos of the scene (let's call them Video01.mp4, Video02.mp4, etc.).

    Press each key, I added the following to mousedown:

    SYM.$("Video01"). Hide();

    SYM.$("Video02"). Hide();

    SYM.$("Video03"). Hide();

    SYM.$("Video04"). Hide();

    SYM.$("Video05"). Hide();

    SYM.$("Video06"). Hide();

    SYM.$("Video07"). Hide();

    I have then change ' hide ' for 'show' according to which video I want to play when the viewer clicks the button and assign a mouseup action.

    I'm wondering 2 things:

    1. is there an action that allows you to hide all the videos with a single line of code, instead of repeating it several times (for each video)?

    2. can I assign a code to a transparent symbol I can superimpose each button so I can't open the actions for each of them? In other words, I would simply drag a symbol on the stage and have the code already attached to it, then all I have to do is change one or 2 lines instead of having to rewrite the entire thing every time.

    Thank you

    1 sym.$("video").hide (); allows you to hide all the video elements, then you can selectively show an individual video like sym.$("Vidoe01").show ();

    2 write a function in compositionReady as:

    sym.hideShowVideo = {function (name)}

    SYM.$("video"). Hide();

    SYM. $(Name). Show();

    }

    Call this function for each button in sym.hideShowVideo ("Video01");

    HTH,

    Vivekuma

  • How can I create buttons of switch trigger MC in swf loaded

    Hello

    I am a newbie in ActionScript 3 and I am currently working on a project that has a (zoom) swf that zoom/pan a swf loaded a map (carte_web.swf). Everything was going well until I got more requests.  There are now two cards, same background, one with images and one with only one road. I try to add code to two buttons on a toolbar that is generated by the zoom.swf, to switch between the two cards, without losing its zoom/pan my cards are the two Flash-oriented object programming.  I spent 27 hours, trying to find a way, and I'm definitely at the end of my mind!

    I have a suggestion "to charge both your SWF in a sprite separately.» Then switching between sovereign wealth funds by removing and adding them to their parent sprite. The parent sprite is what you zoom. "I've tried everything!

    Any suggestions?

    If you want to keep the current state of each 'card', you will need to load each of these sovereign wealth funds in different sprites. In this way, you can just addChild and removeChild and save the State without having to reload the SWF file. Another way, you could actually do, would be to just reload in a sprite, and before you unload the SWF file, save all data of zoom/pan in an array or variable or something of that sort and just restore data to the card when it is reloaded. Don't know if I make sense here, but without details of your exact problem, it is difficult to say.

  • How can I create a column 2 "vertical on the left side of my rhythm of House for the installation of the buttons?

    How can I create a column 2 "vertical on the left side of my rhythm of House for the installation of the buttons?

    How can I create a column 2 "vertical on the left side of my rhythm of House for the installation of the buttons?

    With a column CSS floated.

    But ask yourself this important question.  How this column 2 "wide will look on smaller web devices like tablets and mobile phones using the portrait?   2 "on a mobile phone is a big part of the space.

    Nancy O.

  • How can I create a download button on Muse?

    How can I create a download button on Muse. I like people to download a voucher from my Web page.

    What type of file this is what they download?

    If it is a PDF file for example then you use the file---> files for download location and click your button and go to the drop-down list of hyperlinks and you will see that what listed there to link to.

  • How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    How can I create sequential shooting (1 for each 'row') numbers in a script in multiple column?

    Sorry, but for now there no such function to put sequential numbers in the column number drawn.

  • How can I create a 'go-back-to-previous-page-button '.

    How can I create a 'go-back-to-previous-page-button '.

    Select your button or text and hyperlinks tool type in:

    JavaScript:History.Back()

  • How can I change a shared action

    Hello community,

    I build interactions of simple training on mine. In these interactions, I advanced Actions and shared Actions.

    Sometimes I want to change some things in a shared creations (for example I want to incorporate a new variable).

    For me, it would be really great if I could change some questions and then to save the Action shared under the same name.  But I Don t find this possibility. Captivate always ask a new name and then I have to take a new name for the shared action and change all the actions in my slides.to the new Action.

    My question: how to change some questions in my shared Action and save the shared under the same name (old) action?

    Thank you

    Rainer

    As for joint actions, there is still no workflow smooth for editing. Maybe these tips can help:

    If you make sure that the old shared action no longer applied to any event by checking the use of the library, you are able to remove this action. But as you change, start first by creating an 'Advanced' action (no need to name), based on the model that exists for each share of action and that you find under the white button. You complete the settings, you can save it as a tip action. Then delete the old shared action. The created tip action can now be saved as an action shared the same name. It is quite exceptional. Too bad, you will need to set all the parameters again, enter the description of the action and the parameters. There is no way to keep this information, crossing my fingers that the workflow will be, at least in a future version, more user friendly.

  • How can I create a pause in my inspection so that I can change a setting on my DEGREE, and then resume with the rest of the inspection?

    New to Labview and NI Vision in general here.

    How can I create a pause in my inspection so that I can change a setting on my DEGREE, and then resume testing?

    I want my inspection to execute algorithms on the acquisitions of two different images, where the break to change the settings of my DUT.  I thought that the breakpoint was working well when I'm in the configuration interface and I run the State, but it seems that when I run the inspection he jumps on the breakpoint and continues on the next stage of the inspection immediately.

    Are you running Vision Builder AI on Windows or on a remote target? If you have a remote target, which?

    On Windows, you can use a step of user input in the last tab of the Vision Builder AI tool palette.

    It will display a dialog box that is paused the inspection until you click on a button.

  • How can I change the default action of record?

    My laptop with Windows vista has curently explores as the default action (because it does not open in a new window which is my chosen prefrence) and opened as the next option. How can I change the default action to open?

    Hello Nekora,
     
    Thanks for posting on the Community Forums of Microsoft Vista.

    Note: to set Windows Explorer to open in a new window, you must have the disabled Navigation pane.

    To Turn Off the Navigation pane, follow the steps.

    1. click on the toolbar button organize in Windows Explorer.
    2. click on page layout.
    3. Turn Off the Navigation pane - click Navigation pane to turn off highlight the icon.

    Later the value folder always options open the folder in a separate window.

    1. access control panel.
    2. open the Folder Options.
    3. Select the option "open each folder in its own window.
    4. click on apply and Ok.
    5. close the Folder Options and Windows Explorer window when finished.

    Restart the computer and check if it opens in a new window.

    It will be useful.

    Thank you and best regards,

    Srinivas
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How can I create a list of contacts on Outlook Express. I found the answer in help, but cannot locate elements, on what he asked me to click

    Remember - this is a public forum so never post private information such as numbers of mail or telephone!

    Ideas:
    How can I create a group or a list of contacts on Outlook Express.  I found the answer in help, but cannot locate elements, on what he asked me to click

    • You have problems with programs
    • Error messages
    • Recent changes to your computer
    • What you have already tried to solve the problem

    If you're running Vista, you have Windows Mail, not Outlook Express. These instructions for adjustment of these two programs.

    To create a group of contacts:

    You can create a single group name (or alias) to use when sending a message to several contacts at the same time. Just create a group name and add individual contacts to the group. Then just type the name of the group in the box for when you send mail.

    1. in the address book, select the folder in which you want to create a group. Click New in the toolbar, and then click New Group.
    2. the Properties dialog box opens. In the group name box, type the name of the group.
    3. There are several ways to add people to the Group:
    a. to add a person from your address book list, click Select members, and then click a name in the address book list.
    (b) to add a person directly to the group without adding the name to your address book, type the person's name and e-mail address at the bottom of the Properties dialog box and then click Add.
    to add a person to both the Group and your address book, click New Contact and enter the appropriate information.
    (d) to use a directory service, click Select members, and then click search. Select a directory service in the drop-down list at the end of the text box. After finding and selecting an address, it is automatically added to your address book.
    4. Repeat for each addition until your group is defined.

    Note

    a. to view a list of your groups separately from the list of address book in the address book on the view menu, make sure that folders and groups is selected.
     
    b. you can create multiple groups, and contacts can belong to several groups.

    If you want to send to a group without addresses are displayed for each recipient, open the address book and make a new entry. Enter the name of the group in the area of the display, but use your address. (Some Internet service providers require a legitimate address in the line to and recipients will know it's from the Group).

    Click on the button to. Enter the name of the group using your address. Enter the group in the BCC field.

    Bruce Hagen MS - MVP [Mail]

  • How can I create a widget from Adobe Acrobat DC Pro that I use in my Web site instead of using EchoSign/DC, as I am now?

    How can I create a widget from Adobe Acrobat DC Pro that I use in my Web site instead of using EchoSign/DC, as I am now?

    Hello

    As the creation of widgets is an echosign feature and not an Acrobat feature, unfortunately, you wouldn't be able to create widgets with the Acrobat DC pro subscription. This is due to the reason why you get echosign pro subscription when you subscribe to DC, Acrobat pro, which does not support the widget.

    If in the case where you are on Echosign pro subscription, you wouldn't be able to do so because it does not support the creation of widgets. You will have to opt for a global echosign or the company's plan to create widgets.

    Or you can opt for one of the Acrobat business plans to perform this task.

    If you wish, you can connect with the support of Adobe for more information in this regard.

    http://helpx.Adobe.com/x-productkb/global/Service1.html

    Please click on the blue button "Still need help" to connect with one of the frames.

    Concerning

    Sukrit diallo

  • How can I add a game action on an object that contains the first click and read reversed to this object even a second click action?

    How can I add a game action on an object that contains the first click and read reversed to this object even a second click action?

    First create a symbol of the object.

    Then add the code in the event click on this symbol as below:

    Insert the code for the mouse, click here

    var bReverse = (sym.getVariable ("reverseDir")! = undefined)? (sym.getVariable ("reverseDir")): true;

    sym.setVariable ("reverseDir", bReverse)

    {if (bReverse)}

    sym.playReverse ();

    }

    else {}

    SYM. Play();

    }

    HTH,

    Vivekuma

  • How can I create a profile of the camera with camera raw?

    Hello

    How can I create a profile of the camera with camera raw without x-rite or any other third party software?

    I have a color checker, with a different shade of colors gray and different

    I remember on a script or something like that

    I have a lot of google, but without luck

    can I create my camera raw profile using a corrector of color with photoshop acr?

    I don't know, but this should be the script http://Simon.Tindemans.EU/tools/AcrCalibrator , non ?

    but I don't know how to use it

    Is there a tutorial? Perhaps a video to create a profile with camera raw

    Thank you

    Greetings

    Hello, I think you are looking https://www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5Fdngprofileeditor

    Here is a PDF from adobe on this subject: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/cs6/ DNGProfile_EditorDocumentation.pdf

    And an article: http://www.luminous-landscape.com/reviews/accessories/dng-profiles.shtml

  • How can I create a new instance on unix

    Hello
    How can I create a new instance (instance only) on UNIX and how do I mount my database with this new instance.

    udayjampani wrote:
    Hello
    How can I create a new instance (instance only) on UNIX and how do I mount my database with this new instance.

    (1) define the Instance in your own way!
    If you simply create a startup nomount with her, and then - in theory - and pfile file you have a conduct of the proceeding (this method is used for example for restoring a backup rman)

    (2) you can't. The database files are related to a certain instance. What you can do is to recreate an instance with a different name for example, by using the scripts generated by an "alter database backup controlfile to trace;" command

    See you soon
    FJFranken

Maybe you are looking for