Skip to main content
Srihari_Ch
Known Participant
July 7, 2009
Question

Does flash[in ActionScript 3.0] supports relative URL?

  • July 7, 2009
  • 1 reply
  • 1659 views

Hi all,

      I am new to the Flash platform. My work is on Java. But, I need the help of a flash file(.swf) in my Java application to work with. So, I came to here to listen my doubts like this in this forum.

     Can we pass relative-url using ActionScript 3.0 with Flash?

I have worked with absolute-url till now[WHICH IS IN BOLD] within localhost server only. And my sample piece of code looks like below:

... ...

...bla ...bla

var request:URLRequest = new URLRequest("http://localhost:8082/getviews");

var urlLoader:URLLoader = new URLLoader();

urlLoader.dataFormat = URLLoaderDataFormat.TEXT;

urlLoader.addEventListener(Event.COMPLETE,completeHandler1);

urlLoader.load(request);

function completeHandler1(event:Event):void {  

     trace(“ Inside COMPLETE handler.”);

     var loader:URLLoader = URLLoader(event.target);

     var listData:String=loader.data;

     trace("listData: "+listData);

     var viewswithusertype:Array=listData.split("$");

     /* These are the fields saved in the database server.

      * Further,I am trying to pass these fields using URLVariables

      * class available in AS-3.0 into

      */

     usertype=viewswithusertype[0];

     var views:String=viewswithusertype[1];

     var users:Array = views.split(".");

     trace("list is:"+users.length);

     for (var t=0; t<users.length; t++) {

       trace("in for loop");

       var itemname:String=users;

       var itemslist:Array=itemname.split(",");

       trace("itemslist:  "+itemslist);

       comboBox_mc.addItem({label:itemslist[1],data:itemslist[0]});

    }//for

}//CompleteHandler1()

...bla ...bla

Can anyone post me with an example or a url regarding this problem.

I request you to please spend 2 minutes of your valuable time in replying to this post so that I can solve this issue.

Thanks in advance,....

Srihari.Ch

This topic has been closed for replies.

1 reply

July 7, 2009

You should consider on the following points:

  1. By default Flash AS3.0 sets the location of the Page [Usually HTML/ASP/JSP/CFM/PHP] as its current directory. No matter where your .swf file is.
  2. You can refer to any local path just like in Java using
    • "../" for parent directory,
    • "<direct file name>" to refer to  file with name <file name> in the same directory of the page where flash is embeded,
    • "<directory>/<file name>" to refer file with file name <file name> in <directory> folder kept at the same level as that of the page.
  3. There are a few restrictions in using parent directories please go through Flash Security on Adobe's site.

For your reference here is the example:

var request:URLRequest = new URLRequest("Temp/getviews.JSP");

This code will try to link to the "getviews.JSP" file in the "Temp" directory which should be present on the root folder where this flash file is embeded.

Let's say you have this flash file embeded inside file "flashcontent.JSP", then "flashcontent.JSP" should be placed in the parent directory of "Temp" directory.

Srihari_Ch
Known Participant
July 10, 2009

Hi Swapnil V.J,

Thanks for your reply.

        But, I feel sorry for not replying to your post these days, I was far from work these days.

Does the 3 points which you mention/explained in previous post belongs to Flash-AS-3.0 or others[viz., JSP, PHP, etc.,] ?

Please, Can you give/post me a sample code of AS-3.0 which works with relative-url's...

I will be waiting for your reply....

Anyone, if you hav solution for working with relative-paths of url in flash, help me by spanding 2 min.s of your valuable time in sending reply with a solution to this post.

Thanks in advance...

Srihari.Ch

July 13, 2009

It is for all the languages mentioned by you. [inclusive of AS3.0]

Also read my post carefully I have already given an example which explains the referencing.

Let me know if you are not clear with it.