A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Specifying a Path with AS3

  1. #1
    Junior Member
    Join Date
    Sep 2007
    Posts
    10

    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?

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Do you have the AS3 code you are using? That code you have is really really old.

  3. #3
    Junior Member
    Join Date
    Sep 2007
    Posts
    10
    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.

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    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(bgClipbanners); 
    Last edited by MyFriendIsATaco; 09-07-2007 at 05:50 PM.

  5. #5
    Junior Member
    Join Date
    Sep 2007
    Posts
    10
    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();

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Those sound like AS2 errors, not AS3, so make sure you are compiling as AS3.

  7. #7
    Junior Member
    Join Date
    Sep 2007
    Posts
    10
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center