0

I have a file I am saving out in php that is just a txt file that has an array in it like this:

array (
  0 => 
  array (
    'key' => 0,
    'cropBounds' => 
    array (
      'x' => 73,
      'y' => 111,
      'bottom' => 269,
      'width' => 176,
      'height' => 158,
      'top' => 111,
      'topLeft' => 
      array (
        'cropBounds' => 73,
        'x' => 111,
      ),
      'bottomRight' => 
      array (
        'cropBounds' => 249,
        'x' => 269,
      ),
      'size' => 
      array (
        'cropBounds' => 176,
        'x' => 158,
      ),
      'left' => 73,
      'right' => 249,
    ),
  ),
)

Then I am trying to bring it back into flash as an array. I have tried things like "as array" but that doesn't work. Can someone point me in the right direction for converting this "string" from a txt file into an array in flash?

1
  • This appears to be more like a Dictionary or Object rather than an Array in Flash. It might be easier to parse the array from PHP to Flash as an XML string. Commented Feb 8, 2011 at 5:37

1 Answer 1

3

You're making this a bigger task then it needs to be. There is not a "simple" way to do what you are asking. Basically you would need to parse the string and build the arrays in AS3 yourself. Probably more complicated then you want to tackle.

An alternative solution is to use a separate data-interchange format that both PHP and AS3 can use. The two best examples are XML or JSON. Both AS3 and PHP have native XML support, PHP has native JSON support too, and this library makes it easy in AS3. I would highly recommend going either of these two routes.

In PHP, you could easily convert the array from your text file to JSON which AS3 could read and use. I'd recommend this. A simple PHP script could even do it dynamically for you.

Good luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.