;

PDA

Click to See Complete Forum and Search --> : Specifying a Path with AS3


syv
09-07-2007, 02:12 PM
This is probably a simple matter, but I am having an issue with the path when I reference files. For some reason when I try to call an swf with flash it starts looking at the root folder when it is posted on the server.

Let me see if this makes sense. Here is my hierarchy.

Root
>pages
>>homepage
--mainfile.swf
>>>images
---subfile0.swf
---subfile1.swf

I want mainfile.swf to look in images to reference the two subfiles. For some reason it starts the search for the images folder in the Root. Here is the code that is used for mainfile.swf to try and reference the subfiles:

banners = new Array("images/subfile0.swf", "images/subfile1.swf");
function randomBanners() {
randomNumber = random (banners.length);
loadMovie (banners[randomNumber], "_root.bgClip");
}
randomBanners();

How do I get it to search from the folder that contains mainfile.swf?

MyFriendIsATaco
09-07-2007, 02:41 PM
Do you have the AS3 code you are using? That code you have is really really old.

syv
09-07-2007, 05:14 PM
I have been out of the flash game for a while. Most of the code I use I get from tutorials or help sites. This is what I am using to generate random swf files. I don't know any other way to do it.

MyFriendIsATaco
09-07-2007, 06:48 PM
well, the equivalent as3 code to what you have there is as follows:import flash.display.DisplayObject;
import flash.display.Loader;
import flash.net.URLRequest;

var banners:Array = new Array("images/subfile0.swf", "images/subfile1.swf");

function randomBanner($target:DisplayObject, $banners:Array):void
{
var selection:String = $banners[Math.round(Math.random()*($banners.length-1))];

var loader:Loader = new Loader();
loader.load(new URLRequest(selection));

$target.addChild(loader);
}

randomBanner(bgClip, banners);

syv
09-07-2007, 07:20 PM
This code is not working for me. Here are the errors I am getting:

A type identifier is expected after the ':'. | function randomBanner($banners:Array):void

The class or interface 'Loader' could not be loaded. | var loader:Loader = new Loader();

MyFriendIsATaco
09-07-2007, 09:07 PM
Those sound like AS2 errors, not AS3, so make sure you are compiling as AS3.

syv
09-10-2007, 12:41 PM
I don't know then. It is on AS3 and I am getting the same errors when I try and export the file.