|
-
Specifying a Path with AS3
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?
-
Bearded (M|G)od
Do you have the AS3 code you are using? That code you have is really really old.
-
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.
-
Bearded (M|G)od
well, the equivalent as3 code to what you have there is as follows:
PHP Code:
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);
Last edited by MyFriendIsATaco; 09-07-2007 at 05:50 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();
-
Bearded (M|G)od
Those sound like AS2 errors, not AS3, so make sure you are compiling as AS3.
-
I don't know then. It is on AS3 and I am getting the same errors when I try and export the file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|