The following prompt is displayed for creating a guide line webpage:This problem was discovered during multi-level loading today. the solution is pasted with the Problem description: The Path Structure is: root level: a.swf data (folder) data folder contains B .swf c.swf in B'sCodeWhen C. SWF runs B separately, it is normal. When a0000bis are used, the question "B" cannot begin c.swf. We need to move c.swfto and a.swf. |
Today, this problem was discovered during multi-level loading, and the solution was posted.
Problem description:
The path structure is at the root level: B .swf c.swf IN THE a.swf data (folder) data folder
When C. SWF runs B separately in the code B, it is normal. When a0000bis are used, the question "B" cannot begin c.swf.
You must move c.swfto the same level as a.swf.
Cause:
All loaded SWF files use the directory of the outermost SWF as the root directory.
All SWF files loaded by webpages use the directory where the webpage is located as the root directory.
Solution:
Function compute file directory (){
VaR Directory Index = _ URL. lastindexof ("/");
VaR directory = _ URL. substring (0, Directory Index );
Var file name = _ URL. substring (Directory Index + 1 );
Return [directory, file name];
}
Trace (_ URL)
Trace (computing file directory ())
// ***** Focus. The preceding function separates the directory from the file name. Therefore, the returned value [0] is the directory [1] and the file name. This makes it easier to use.
Use the above function to analyze and obtain the absolute directory of the main loader. At this time, no matter the lower-level carrier or lower-level carrier, call this function again.
Obtain the absolute directory of the lower-level carrier.
In this way, we can get two absolute addresses and use the string analysis method (indexof) to find the same part. remove, and the rest is the required relative path. in this way, this path is appended during the loading. the file with N-level relationships can be normally loaded.
This tutorial is self-developed and only available for learning.
// Add the comparison method. It is relatively simple.
// ========= Calculate your own relative path ========
VaR Directory Index = file directory [0]. indexof (_ root. File directory [0])
VaR Relative Path = file directory [0]. substring (Directory Index + _ root. File directory [0]. Length + 1)
Trace ("Relative Path =" + relative path)
// ===== Trace environment === parsing successful.
Main file directory = file: // F |/create/
Sub-file directory = file: // F |/create/A/Data
Relative Path = Data