dcsimg
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: [CS4][AS2]Game Tile Editor, Input Text Problem

  1. #1
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236

    [CS4][AS2]Game Tile Editor, Input Text Problem

    Hi,

    I am in the process of building a tile game; I had just assembled a tile editor that uses arrays of map properties and strings.

    What my problem is that I want to be able to import an array into the editor and edit it from there instead of redoing my maps all the time.

    Here is the code I tried.
    Code:
    on (release) {
    	_root.mapString = mapInput;
    }
    The idea was to have a button open up a MC with an inputText and I would be able to paste my previous code into it and have it load. Every time I place the code the code into the inputText which the var is set correctly "_root.mapString" it gives me all of the zeros representing the blank code, then I paste in the other code and it does nothing.

    The "mapInput" represents the inputText field that is used to put the new code in.

    So here was my next conclusion which ironically I came up with after studying prototypes a little bit.

    Code:
    on (release) {
    var mapString = _root.mapString;
    var mapInput = mapString.replace(mapString, mapInput);
    trace(mapString);
    }
    This partially worked. It displayed my new mapInput code into the Output, but it did not change any of the tiles on my editor and then I closed the MC and opened it back up to give all of the zeros all over again.

  2. #2
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    And this code is put where? Have you traced out _root.mapString, before AND after you used var mapString? It sounds like a scope error but you're explanation is unclear to me. If you want to paste an fla or elaborate the probably I can probably help you further.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #3
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    Here is an .fla of it.

    www.cliffordhowes.com/material/PKM_Mapper.fla

    go to the movieClip "inputBox".

    I want to paste an already generated map array back into the editor basically instead of remaking the maps all over again.

  4. #4
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    If I understand you correctly, you're having an issue going from the input box to something the code understands as map data. Upon pressing the save button on the import mc, you need to do the opposite of how you populated the text box. You need to collect, parse, and convert the text in the input box back into an array before you save back to the root. Let me know if I missed the mark a bit.
    Last edited by ImprisonedPride; 04-26-2009 at 11:43 PM.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  5. #5
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    That seems about correct.

    I want to import map data back into the editor.

    It is driving me crazy how come it will not go into the input and save. I have done this so many times before and I am not sure if it is the way the string is or what.

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    You cant directly get string from textfield object. Give your textfield an Instance Name and then use its text property:

    var myStr = myTextField.text;

  7. #7
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    You cant directly get string from textfield object. Give your textfield an Instance Name and then use its text property:

    var myStr = myTextField.text;
    I tried that several times and I just did it again to be sure; have you taken a look at my .fla file?

  8. #8
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    I'll be home in 90 minutes or so... I"ll try to look at it again then but I'm in class right now. One thing I didn't agree was the usage of the String keyword in the line that I think was
    Code:
    var mapString = String;
    Maybe it's ok, but I haven't seen it before. Typically, most people do
    Code:
    var mapString:String = "";
    //or
    var mapString:String = null;
    // then apply a string to it.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  9. #9
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    The first code works fine; I would not know how the second one would work because the mapString is associated with an array. That is how come I have the input text target that variable to make the changes for the my tiles.

  10. #10
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Quote Originally Posted by Evaman View Post
    I tried that several times and I just did it again to be sure; have you taken a look at my .fla file?
    Sorry, dont have CS4 so cant open it.

  11. #11
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    Quote Originally Posted by tonypa View Post
    Sorry, dont have CS4 so cant open it.
    www.cliffordhowes.com/material/PKM_MapperCS3.fla

  12. #12
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    You have wrong path to the text field:
    _root.mapString = _root.inputBox.mapInput.text;
    should be:
    _root.mapString = _root.map.inputBox.mapInput.text;

    Once you have set the mapString, you can pass it into map building function. Currently i dont see it being used anywhere as the map itself is built from map1 array and if you try to output the code you are resetting mapString and rebuilding it based on map1 array.

  13. #13
    Ich lerne jede Tag etwas Neues Evaman's Avatar
    Join Date
    Nov 2006
    Location
    Die Welt
    Posts
    236
    Quote Originally Posted by tonypa View Post
    You have wrong path to the text field:
    _root.mapString = _root.inputBox.mapInput.text;
    should be:
    _root.mapString = _root.map.inputBox.mapInput.text;

    Once you have set the mapString, you can pass it into map building function. Currently i dont see it being used anywhere as the map itself is built from map1 array and if you try to output the code you are resetting mapString and rebuilding it based on map1 array.
    The mapString is associated with map1 by interpreting the array code and to be compiled when I want to export the array so I can copy and paste the array into the game.

    I see my mistake on my part but that is from just a few hours of experimenting and becoming careless.

    Whenever I lay out tiles in the editor, the mapInput.text will pick up the array's changes under the variable of _root.mapString. When I have it under map1, it just shows nothing but comas and when I make changes it remains the same.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center