0 Replies Latest reply on May 15, 2008 7:41 AM by crispy_cornflakes

    Object Instantiation Issue

    crispy_cornflakes Level 1
      Greetings all on the forum.

      I have an actionscript/flash related problem that I hope someone can shed some light on.


      I have a list of button instances contained within a movie clip instance.

      Each button instance has a name with the following convention: button_product'n'
      where 'n' is an incremental value starting from 1 and increasing by 1 for each instance.

      e.g 'button_product01' ... 'button_product42' etc.

      I have a list of movie clips (off stage) each named in relation to the button
      names in the following way:

      'product01' ... 'product42' et al.

      Thus, for a button instance called: 'button_product05' there exists a movie clip with a name of: 'product05'

      With reference to the button instances: Each button instance has an onPress() event handler attached to it at runtime.


      When a user clicks on a button instance e.g 'button_product42' an instance of the corresponding movie clip
      is created and allowed to be dragged around the stage and dropped in a specific area.

      In this case the corresponding movie clip is 'product42'. Upon instantiation the movie clip instance name is appended with
      a value corresponding to its depth (1 in this case) thus 'product42' becomes: 'product42_1'.

      Each time a new movie clip is dragged onto the stage in this way the suffix is incremented.


      A typical example could be to have the following instances on stage:


      whose depths are 1, 2 and 3 respectively.


      When the instance is dropped onto the stage it is wrapped in a custom object which allows a number of values associated with the
      instance to be saved such as its name, x and y coords and depth.

      This object is then inserted into an array.

      When the user clicks 'save', the array is written to disk in the form of a shared object.


      The problem occurs when I try and re-instantiate the objects on the stage immedeately after I have saved them.

      For example, a load operation with the following data:

      A.) product05_1
      B.) product05_2
      C.) product05_3

      In the debugger list of current instances I see both A and B being created but when it comes to creating C both A and B dissapear
      from the debugger list and are replaced by C yet on the stage C is not present but both A and B are!.

      My intial reaction here is that there is an issue with respect to depth but each movie clip instance is being created
      with a depth of 1, 2 and 3 respectively.

      Now the fun - If i save the above list of objects and then restart the flash movie and try to load them i get A, B and C
      in both the debugger list of instantiated objects and on the stage ergo no problem!

      I have inspected the shared object data file and the integrity of the saved data is good in all cases.

      It seems the problem is only evident during a load operation immedeately after a save.

      Does anyone have any clue as to what the problem could be here?

      Apologies if this isn't clear - I am happy to clarify any points that I have made here.

      Thanks in advance for any help offered.

      N.B. The company I work for would be interested in employing a contract/freelance developer to fix this problem.