A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: ActionScript genius required

  1. #1
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749

    ActionScript genius required

    I am loading in a MC and I want to pass it an object full of data. The object is almost passed.

    I did a trace using:
    Code:
    function show_all(temp) {
        for (i in temp) {
            trace(i+" = "+temp[i]+" {}");
            for (j in temp[i]) {
                trace(i+"."+j+" = "+temp[i][j]+" {}");
            }
        }
    }
    The (expletive deleted) is there. But there is no data in it. My trace is:
    Code:
    happy =  {}
    joy =  {}
    When it should have been more like:
    Code:
    happy = [object Object] {}
    happy.happy = Joy joy {}
    joy = Joy {}
    Can anyone help?

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Here is an example, if you run it in Flash and look at the trace, you will see what I mean. The manually set Array seems to be created, but passing an existing array fails.

    SOMEONE?

    ANYONE?

  3. #3

  4. #4

  5. #5
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I think that is the wrong file to download.
    - The right of the People to create Flash movies shall not be infringed. -

  6. #6
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    It shouldn't be. Open the first movie in Flash, and when you test it, it loads in the second one. The trace output window shows you what I mean.

    The variable name is being created successfully, but the variable reference is either corrupt or not passed so it can't be used.

    (BTW, I am not an artist. The red square thing that loads up is, in fact, a button. Pressing the button tries to write the array to the second MC.)

    Look at the actionscript to work out what is going on. Loader is the first movie and loadee is the second.

  7. #7
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    This is getting silly now. See also "major bug? createTextField".

  8. #8
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    sorry,
    I hadn't had time to look at it again, will do tonight.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Ok, got close I think. I changed the button script. I took out the script from the button and put it on the stage just for convenience. What the problem was are the path of the childmovie communicating with the parent movie. This is the change:
    PHP Code:
    myButton.onRelease =function(){
        
    trace("Loadee: "+_root.myArray);
        for (
    i in _root.myArray) {
            
    trace(i+" = "+_root.myArray[i]);        
        }
        
    trace("Loadee: Manual: "+_root.manualArray);

    You have to refer to the parent movie, which has the main timeline, otherwise there is no connection. Was that the problem?
    - The right of the People to create Flash movies shall not be infringed. -

  10. #10
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749

    Not entirely, but thanks for trying.

    Not entirely. Have a look at this trace from Ctrl+Alt+V when running the two files:

    Level #0:
    Variable _level0.$version = "WIN 6,0,21,0"
    Variable _level0.myArray = [object #1, class 'Array'] [
    0:1,
    1:2,
    2:3,
    3:4,
    4:5
    ]
    Variable _level0.i = "0"
    Movie Clip: Target="_level0.loadee"
    Variable _level0.loadee.manualArray = [object #2, class 'Array'] [
    0:1,
    1:2,
    2:3,
    3:4,
    4:5,
    5:6,
    6:7,
    7:8,
    8:9,
    9:10
    ]
    Variable _level0.loadee.myArray = undefined


    However, all three arrays should have been defined by the code

    PHP Code:
            this.myArray = [12345];
            
    loadee.manualArray = [1,2,3,4,5,6,7,8,9,10];
            
    loadee.myArray loader.myArray
    Changing the path to _root has just avoided the issue by linking to loader.myArray instead of loadee.myArray.

    Essentially what this means is that I cannot pass object reference pointers around when using more than one SWF. This means I have to build in rakes of redundant code to make sure I have an exact primitive reference to ALL my data. So I can't plug in object driven SWF.

    Thanks for trying though,

    Gaius

  11. #11
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749

    For comparison

    To illustrate the problem better, I changed the code as follows:
    PHP Code:
    this.myArray = [12345];
    loadee.manualArray = [1,2,3,4,5,6,7,8,9,10];
    loadee.myArray loader.myArray;
    // Create an object in the first MC to accept the array reference
    // then pass it the reference to _root.myArray
    demo_of_how_it_should_be = new Object();
    demo_of_how_it_should_be.myArray this.myArray
    Then I got a trace from Ctrl+Alt+V as follows:

    Level #0:
    Variable _level0.$version = "WIN 6,0,21,0"
    Variable _level0.myArray = [object #1, class 'Array'] [
    0:1,
    1:2,
    2:3,
    3:4,
    4:5
    ]
    Variable _level0.demo_of_how_it_should_be = [object #2, class 'Object'] {
    myArray:[object #1, class 'Array']
    }

    Movie Clip: Target="_level0.loadee"
    Variable _level0.loadee.manualArray = [object #3, class 'Array'] [
    0:1,
    1:2,
    2:3,
    3:4,
    4:5,
    5:6,
    6:7,
    7:8,
    8:9,
    9:10
    ]
    Variable _level0.loadee.myArray = undefined

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