Using Actionscript to generate a grid

Hello all.
I am working on a Flash project and have a problem that has
turned out to be a real head scratcher for me. I need to create a
Flash form that will generate a floorplan grid based upon width and
length values entered by the user. I have successfully completed
part of the task and I am able to generate a grid based upon the
width and length entered by the user.
Here is my problem: When the Width and Length "units" are
entered as feet, I need to generate a grid that displays 1 grid
square for every 5 feet of length or width entered, (the scale is 1
square grid = 5 ft so if you entered a 50 ft building length or
width the "length or width" side of the grid would be 10 grid units
in length). Then, if the user re-enters new values for the width
and height and clicks "draw floorplan"
again
the grid needs to regenerate
again
at the proper size. Currently my sample generates 1 grid for
every foot of length or width entered and will not regenerate
properly.
Below is a link to a sample of where I am so far as well as
the Actionscript I am using to control the sample file.
Can anyone provide some pointers on how to generate the grid
with one grid representing 5ft and how to regenerate the grid once
new values are input and the "draw floorplan" button is clicked
again? (Also, ultimately I need to then send the form data as
email.)
Any help is very much appreciated!
Bitjammer
Link to sample:
http://216.197.127.249/grid/grid_sample_1.html
(Try entering 10 width and 10 length then click draw floor
plan)
Here is my actionscript code so far:
my_button.addEventListener("onPress",gridf);
my_button.onPress=function(){if(Number(widthTF.text)>1&&Number(heightTF.text)>1){gridF(Num ber(widthTF.text),Number(heightTF.text))
function gridF(h,w){
initX = 0;
initY = 0;
counter = 0;
for (var i = 1; i<=h; i++) {
for (var j = 1; j<=w; j++) {
counter++;
grid_container.attachMovie("cellMC", "cell"+counter,
counter);
grid_container["cell"+counter]._x = initX;
grid_container["cell"+counter]._y = initY;
initX += 15;
initY += 15;
initX = 0;
(For clarification: the width input variable is widthTF and
height input varible is heightTF.)

Thanks for taking time to answer my post, kglad.
Yes. I believe I understand. I could create another button
and call it "Reset Grid" and call this function, however what I am
hoping for is to have the grid redraw simply by the user entering
new values for the width and height and then clicking "draw
floorplan" again.
Currently the first line of code is:
my_button.addEventListener("onPress",gridf); Should not the grid
redraw each time and then parse the new values in the width and
height fields? I am sure I am just dense but my grid is not
clearing each time the "draw " button is clicked.
You can see this happen on the sample link below. After
entering say 20 width and 20 height values and clicking "draw"
button, the grid is created perfectly. Then if, say new values of
10 width and 10 height are entered and "draw" button is clicked,
the grid does not redraw correctly using these new values.
Sample link:
http://216.197.127.249/grid/grid_sample_1.html
Could the problem be that the gridf function should happen as
the first function in the script before the new values are parsed
again? Should a: grid_container.removeMovieClip(); execute before
anything else is executed each time the "draw" button is clicked?

Similar Messages

  • Creating a dynamic grid using actionscript

    Hello all:
    I am working on a Flash project which requires that the user
    input 2 values. These two values will be used as height and width
    to generate a dynamic grid. I am new to actionscript and am
    struggling with how to create the 2 input fields and pass the
    values to actionscript by an event such as the user pressing
    return. The code below will create the grid correctly based upon
    the hardcoded variable values hightlighted, but I need the user to
    enter the values and press return to generate the grid.
    Can anyone suggest the actionscript required to capture the 2
    values, send them to actionscript with an event such as pressing
    return and then have AS generate the grid width and height based
    upon the user input. The i (10) and j (10) values in line 4 and 5
    are the values that I need to have the user input to generate the
    grid.
    Any help will be most appreciated!
    initX = 0;
    initY = 0;
    counter = 0;
    for (var i = 1; i<=10; i++) {
    for (var j = 1; j<=10; j++) {
    counter++;
    grid_container.attachMovie("cellMC", "cell"+counter,
    counter);
    grid_container["cell"+counter]._x = initX;
    grid_container["cell"+counter]._y = initY;
    grid_container["cell"+counter].onRelease = function() {
    cellName.text = this._name;
    initX += 30;
    initY += 30;
    initX = 0;

    Thanks for the quick reponse kglad. I will give it a
    go.

  • Example of using ActionScript to create Grid, GridRow, and Grid Item?

    Does anyone know where I can find a complete example of using
    ActionScript to create Grid, GridRow, and Grid Item?
    I got an error when trying to add a child to the GridRow.
    Flex 2 said this method (addChild) is not available to
    GridRow.

    This thread should help:
    http://www.actionscript.org/forums/showthread.php3?t=167806
    matt horn
    flex docs

  • RendererProviders in AdvancedDataGrid using Actionscript

    hi..
    am working with AdvancedDataGrid...
    am generating these grids at runtime...
    <mx:AdvancedDataGrid id="myADG"
    width="100%" height="100%"
    variableRowHeight="true">
    <mx:dataProvider>
    <mx:HierarchicalData source="{dpHierarchy}"/>
    </mx:dataProvider>
    <mx:columns>
    <mx:AdvancedDataGridColumn dataField="name"
    headerText="Name"/>
    <mx:AdvancedDataGridColumn dataField="total"
    headerText="Total"/>
    </mx:columns>
    <mx:rendererProviders>
    <mx:AdvancedDataGridRendererProvider
    dataField="detail"
    renderer="ChartRenderer"
    columnIndex="0"
    columnSpan="0"/>
    </mx:rendererProviders>
    </mx:AdvancedDataGrid>
    now in this code i used rendererProviders.
    using MXML we can write like this...
    bcse am generating this grid at runtime.. i need to code
    everything using ActionScript.
    any idea how to implement renderProviders... using
    actionscript??
    can any one help me how to write the above code.. just only
    the rendererProviders part using actionscript???
    Thanks
    Pratap

    This should help -
    // create a new RendererProvider
    var rp:AdvancedDataGridRendererProvider = new
    AdvancedDataGridRendererProvider();
    rp.dataField = "detail";
    rp.renderer = new ClassFactory(ChartRenderer);
    rp.columnIndex = 0;
    rp.columnSpan = 0;
    // assign the RendererProvider to the rendererProviders array
    adg.rendererProviders = [rp];
    - Sameer
    http://techrays.wordpress.com/

  • DataGrid Control using ActionScript

    Hi,
    Is it possible to generate the rows of a datagrid dynamically
    using actionscript?
    I want to put information of multiple XML's on one line of my
    datagrid.
    Mark

    Ok, I found out my problem, the thing is i wanted to combine
    info in a datagrid, from 2 xml's, but since it's not directly
    possible to access a row of the grid, I created a labelfunction for
    the datagridcolumns which i wanted to populate with a different
    value.
    Source is included below, hope it will help someone.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="1120" height="300" initialize="doInit();">
    <mx:XML id="dataContacts"
    source="/data/Contactperson.xml"/>
    <mx:XML id="dataCommunication"
    source="/data/Communication.xml"/>
    <mx:Script>
    <![CDATA[
    private function doInit():void {
    trace(dataContacts.Contactperson.Firstname);
    protected function getPhonenoById(row:Object,
    column:DataGridColumn):String {
    for each(var node:XML in row.Communicationid) {
    var value:String = new String;
    if (dataCommunication.Communications.Communication.@id ==
    node.toString) {
    value = dataCommunication.Communication.(@id ==
    node.toString()).(@type == "Phone");
    if (value != "") // if the string is empty
    // return to the returning parameter.
    break;
    // returning the value to the cell
    return value;
    ]]>
    </mx:Script>
    <mx:DataGrid x="10" y="10" width="493" id="dg"
    dataProvider="{dataContacts.Contactperson}">
    <mx:columns>
    <mx:DataGridColumn id="dcFirstname" dataField="Firstname"
    headerText="Voornaam"/>
    <mx:DataGridColumn id="dcLastname" dataField="Lastname"
    headerText="Achternaam"/>
    <mx:DataGridColumn id="dcPhone"
    dataField="Communicationid" labelFunction="getPhonenoById"
    headerText="Telefoonnummer"/>
    </mx:columns>
    </mx:DataGrid>
    </mx:Canvas>

  • Using ActionScript to control where a break happens in TLF linked text boxes

    Let's say you want to display a directory of people including name and department person works in. This information is in an xml file and ActionScript is used to read the information in and display the text in TLF text boxes that are linked. Is there a way to use ActionScript to control orphans/widows? Meaning, let's say that the first TLF text box fills up and at the very bottom of that text box another person's name appears. Then at the top of the linked text box the department name that person works in appears. Is there a way to use ActionScript to control it so that the persons name doesn't get separated from the department name? Thanks for any help!!

    Thanks for taking time to answer my post, kglad.
    Yes. I believe I understand. I could create another button
    and call it "Reset Grid" and call this function, however what I am
    hoping for is to have the grid redraw simply by the user entering
    new values for the width and height and then clicking "draw
    floorplan" again.
    Currently the first line of code is:
    my_button.addEventListener("onPress",gridf); Should not the grid
    redraw each time and then parse the new values in the width and
    height fields? I am sure I am just dense but my grid is not
    clearing each time the "draw " button is clicked.
    You can see this happen on the sample link below. After
    entering say 20 width and 20 height values and clicking "draw"
    button, the grid is created perfectly. Then if, say new values of
    10 width and 10 height are entered and "draw" button is clicked,
    the grid does not redraw correctly using these new values.
    Sample link:
    http://216.197.127.249/grid/grid_sample_1.html
    Could the problem be that the gridf function should happen as
    the first function in the script before the new values are parsed
    again? Should a: grid_container.removeMovieClip(); execute before
    anything else is executed each time the "draw" button is clicked?

  • Using SQVI to generate report of open and released delivery schedule lines

    All,
    I'm using SQVI  to generate an excel spreadsheet for some buyers to show open released schedule lines because they are a 1 line item per scheduling agreement company.
    I used the logical database MEPOLDB instead of a table joint and pulled fields from EKKO(vendor, SA #,&purchasing group), EKPO(Material Number), EKEH(schedule line type), and EKET(delivery date, scheduled qty,previous qty).
    Does this sound like I'll get the results I want on paper as long as I use the right selection criteria, because the report I'm getting isn't quite what I expect? I am unable to identify which lines are authorized to ship vs. trade-off zone, planning, etc. in the report thus far.

    Hi Mark,
                 I have faced same requirement. I am not sure about transporting to TST and PROD. I done by this way.
    After generating SQVI program in DEV , I assigned that program  to a transaction and tested in DEV. Later i have regenarated SQVI in Production. then I assigned the generated Program to same transaction in DEV. And transported the Tcode assignment of program to Production..
    About authorization , if its not sensitive report, BASIS can restrict at transaction level.
    Regards,
    Ravi.

  • I want to use the Function Generator VI to send command signals through the NI 7344 motion controller. This will be a closed loop servo valve system. I want to be able to change from say a square wave to a sine wave on the fly. Idea's?

    I am going to run tests that require an actuator to move using various types of arbitrary waveforms such as sine or square. The NI 7344 is hooked to the UMI that is going through a driver for a servo valve. The loop is analog and it is closed. I have played with some of the examples but can't get it to work. I have used the function generator VI to generate a signal but I think I am using the wrong input VI to the motion control board. When I use what I have it moves the servo and then stops. It doesn't continually generate the signal.
    I would love to use the controls on the function generator vi to control frequency and amplitude ect. Any help or pointer would be helpful. Thank you in advance.

    Hello,
    I'm not clear on exactly how you want to use the generated data but I'm assuming they will be used as your target points.
    There's a built-in example for motion called 'One-Axis Contour Move.vi'. This example demonstrates how to provide your target points as 1-D array. All you need to do is to replace the input array with the output of the function generator. In order to have it run continuously, use a while loop. You can further program your application so that it'll change the waveform on the fly by monitoring the user interface but this might be little little tricky as you will need to reset the move and load the new generated points while keeping track of your current position.
    I hope this helps. Let me know if you have further questions regarding this
    application.
    Best regards,
    Yusuf C.
    Applications Engineering
    National Instruments

  • Using mathscript to generate multiple digital outputs for switch control

    Hello 
    I am new to this NI LV and a have kind of a basic question. I would like to use Mathscript to generate an array of bolean numbers which will be used to control the Digital I/O lines. I am using NI 6251 USB device and the Mathscript code runs well. But I have a problem using this array to control the Digital output. So I created a simple test programme where I set the DAQ assitant to generate 4 digital outputs(P0.0 ~ P0.3) and it gives error that  ".. number of channels in the data does not match the number of channels in the task..." (see attachment) . How can I solve this problem thank you.
    Attachments:
    K-9.jpg ‏36 KB

    looks like you did not initialize all 4 of the elements in the bool array....

  • Using JarSettings to generate EJB client jar, but supported classes missed

    Appreciated for any comments in advance.
    I am using @jarSetting to generate EJB client jar file from workshop 9.2. The remote method of EJB has one input parameter that is defined as an interface. The interface is included in client jar, but the implementation of this interface is not.
    Please advise how I can add the implementation of this interface to client jar?
    Best Regards,
    James

    Hi James,
    I believe the algorithm for creating the client jar is to simply inspect the EJB interfaces using reflection and to include all user defined classes and exceptions that are referenced by the interfaces. In your case, it sounds like a class is not being included because it is not directly referenced by one of the EJB interfaces.
    I think the client jar creation algorithm can be described as "best effort" and unfortunately, it does not always end up including all classes needed by the client. I would recommend you add the additional classes manually using the jar tool.
    - Matt

  • Using PHP to generate images in alternate colors

    I have a PNG image of a black silhouette graphic with
    softened edges against a transparent background.
    Can I use PHP to generate this image in alternate colors
    (allowing the black graphic to be displayed in a color other than
    black)?

    AngryCloud posted in macromedia.dreamweaver:
    > I have a PNG image of a black silhouette graphic with
    softened
    > edges against a transparent background.
    >
    > Can I use PHP to generate this image in alternate colors
    > (allowing the black graphic to be displayed in a color
    other than
    > black)?
    I have no experience with this, but I was just poking around
    in the GD
    references and found a comment on imagefill() that might
    help:
    http://us.php.net/manual/en/function.imagefill.php
    Comment:
    http://us.php.net/manual/en/function.imagefill.php#81873
    Or you may need to work with some of the other alpha
    functions.
    Mark A. Boyd
    Keep-On-Learnin' :)

  • How to  Use page parameter for 2 grids

    Hi All,
    I have 2 grids for 2 different DB's in a report.In this page view have business dim, user able to choose the
    business.So i'm using 2 prompts for 2 grids in business dim at page view.but user wants only once he gave the
    input.How to pass one grid page parameters to another grid?
    Plzzzz give any suggestions on this................
    Thanks

    Instead of using prompts and the page, you can put the selectable dimension onto the POV of both grids and set it to current user pov on both grids.
    This way it will work, but the drawback is that you cannot make user select multiple members for that dimension, which is possible with prompts.
    hope this helps
    Bulent

  • Do you need to use Actionscript 3 code in Flash player 9 and above?

    Can anyone tell me if I need to use Actionscript 3 code instead of Actionscript 2 code in the following situation:
    I am running a swf file which is contained in a browser window (all files are contained on a CD and I have a 'trust' file set up to let them play properly).  Up until now, I have been using the following Actionscript 2 code to close the browser window (the Actionscript 2 code is on an 'Exit' button within the swf):
    on (release) {
    getURL("javascript:window.close()");
    This Actionscript 2 code has always worked and still works in Flash player 8 and lower.  However, it does nothing when played using Flash player 9.  Can anyone tell me if Flash player 9 won't recognize Actionscript 2 code?  Is it essential to use ONLY Actionscript 3 code if you are using Flash player 9?
    I am having the same problem when I try to launch another html page containing a swf (popped up from the swf contained in the main html window).  I have the following code on the button to launch the popup html window.  It always worked, but suddenly no longer works with Flash player 9.  Here is the code I am using:
    on (release) {
                getURL("javascript:launchWin2('webpage2.html');");
    I have all the necessary background code to launch 'webpage2.html'.  It works everywhere except in Flash player 9.  Can anyone tell me if it is essential to use Actionscript 3 code ONLY on these buttons in Flash player 9?  I am pretty new to Actionscript 3, so any help with syntax would be appreciated. 
    Please note that I don't want to use the projector.
    Thanks!

    You can use both AS2 and AS3 based applications in both Flash 9 and 10.
    As for the issues you describe - perhaps Flash General Forum is a better bet:
    http://forums.adobe.com/community/flash/flash_general

  • DYNAMIC CREATION OF LINE SERIES USING ACTIONSCRIPT

    There's something wierd about flex or im doing something
    wrong?
    - when i create a line series manually using mxml and specify
    a id for the series, it works.
    - similarly when i try to dynamically create a line series
    using actionscript & define an "id" property, flex does not
    understand! what am i doing wrong?
    code for reference:
    private function addSeries(series:Array,
    yField:String,id:String) // addseries(series,"date","1000")
    var ls:LineSeries= new LineSeries();
    var stroke:Stroke = new Stroke()
    ls.yField = yField;
    ls.xField="ts"
    ls.dataProvider=dp
    ls.id=id // tried defining it dynamically, but flex does not
    find
    this.mychart.series.push(ls)
    THIS IS THE ERROR I GET : "TypeError: Error #1010: A term is
    undefined and has no properties."

    I see... I played around with the line chart ...
    Hopefully this helps... if not forgive me...
    I know why you are trying to use the id property which i
    agree doesn't work.
    since the series is an array in your lineChart use the index
    to set the visible property false/true.
    lineChart.series[0].visible = true/false;
    <mx:Lineseries id="a1" visible="true"
    dataProvider="{whatever}" />
    <mx:Lineseries id="a2" visible="false"
    dataProvider="{whatever}"/>
    create a function called init();
    public function init():void
    var lineS1:LineSeries = new LineSeries();
    lineS1.visible = true/false;
    lineChart.series.push(lineS1);
    var lineS2:LineSeries = new LineSeries();
    lineS2.visible = true/false;
    lineChart.series.push(lineS2);
    ... and the key is to call this init function on initialize
    event...NOT on createComplete event
    <mx:LineChart.... initialize="init()" .... />
    and to show both lines... call this function...
    public function showLines():void
    lineChart.series[0].visible = true;
    lineChart.series[1].visible = true;
    Hope this helps....

  • How to load other obejects in flash file after intro using ActionScript 3.0

    How to load other obejects in flash file after intro using ActionScript 3.0 or any other method all in same fla file. see blow intro screen shot ,this one playing repeatedly without loading other fla pages .only way to load other pages is click on Skip intro .see second screeshot below .i need that site to load after intro .
    see codes already in
    stop();
    skipintro_b.addEventListener(MouseEvent.CLICK, skipintro_b_clicked);
    function skipintro_b_clicked(e:MouseEvent):void{
    gotoAndStop("whoweare");
    There is another script there
    /* Simple Timer
    Displays a countdown timer in the Output panel until 30 seconds elapse.
    This code is a good place to start for creating timers for your own purposes.
    Instructions:
    1. To change the number of seconds in the timer, change the value 30 in the first line below to the number of seconds you want.
    var fl_TimerInstance:Timer = new Timer(1000, 30);
    fl_TimerInstance.addEventListener(TimerEvent.TIMER, fl_TimerHandler);
    fl_TimerInstance.start();
    var fl_SecondsElapsed:Number = 1;
    function fl_TimerHandler(event:TimerEvent):void
              trace("Seconds elapsed: " + fl_SecondsElapsed);
              fl_SecondsElapsed++;
    i have no knowledge about these thing ,any help really appreciated .

    Ned Murphy Thank you very Much .It is working .Great advice

Maybe you are looking for