A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Getting the path for a parent swf?

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    2

    Getting the path for a parent swf?

    Hi!
    Im a very novice flashdeveloper and i have a feeling that there should be a simple solution to my problem.

    I have created a component (swc) that reads some Xml and stores away some values. Just trying the component out works very good and the XML is read correctly.

    The problem is that the XML-file read have the same name as the .swf that the component is loaded from. This wouldnt be a problem either if i stoped here and was using root.loaderInfo.loaderURL. And i realy need to get that name to know what XML to load and where its placed.

    The problem is that the .swf also is loaded inside another main-swf. The structurce look something like this

    mainSwf
    #####|- Child1.swf
    #############|-Component (reading Child1.xml)
    #####|- Child2.swf
    #############|-Component (reading Child2.xml)
    #####|- ...

    When using root.loaderInfo.loaderURL now i get the url to the mainSwf instead and cant find any way to get the name or path of Child1.swf

    Child1.swf and Child1.xml will be in subfolder to the mainSwf folder, the folder will have the same name (Child1)

    Soo my question is, is there any way of getting the Child1 path from the component? I should also say that the name Child1 can be anything since the folder and filestructure is generated from another application.

    Thx in advance
    /Erik

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    Using root , will always return the base movie. Never use root. Why is the loader in the base movie ?

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    2
    This projekt is a courseplayer with x number of pages, soo for every page the Courseplayer (mainSwf) will load a coursepage (child1 for example). What coursepage to load is defined in a XML-file. When that is loaded there will be a number of components inside the coursepage that will use their values from the XMLComponent (component)
    If i only could get the filename/path from the child1 to the XMLComponent the rest would be easy.

  4. #4
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    The problem is the way in which the data is being managed. Typically, every child shouldnt need its own xml file , one xml file , loaded upfront in the mainSWF , and parsed within the mainSWF into nice pretty little data object , and then passed in as an initialization arguement to the child.

    The next best idea would be just to hardcore the location of each child swf's xml file , in the mainSWF, in array , and again pass it in to the child swf.

    Or , if you wanted to take it one step further, create a seperate xml file, with just the local paths to the child xml files , load this file in mainSWF , and pass those paths in as areguements to your children.

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