A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Variables and External sources

  1. #1

    Variables and External sources

    I have an mp3player that loads an external mp3 file and plays. It works just fine if the url/location is hardcoded in the swf file.
    however, i need to be able to have the url passed to the flash externally so that a number of users may utilize this single swf build.

    example:
    current location need to be filename.mp3 or http://www.domain.com/123/filename.mp3
    however, i need this location to be edited per use of the swf.
    in php i know i could call it such as:
    $myLocation = "123";
    http://www.domain.com/$myLocation/filename.mp3
    or

    $myLocation = "http://www.domain.com/123/filename.mp3";

    (the "123" is what changes for each page use)


    how do i do this within actionscripting?

    Here is the code i have that is working just fine...
    until i need to use a full url that changes for each page the swf is use on.

    onClipEvent (load) {
    if (playing!=true) {
    playing=true;
    soundIsLoaded=1
    myMusic=new Sound();
    myMusic.loadSound("myMusic.mp3",true)
    }

    }


    Limitations:
    1. because of the server set up, i am always required to call items using full absolute urls/paths.
    2. php, cfm, xml etc are not available for use with this.
    -- the goal is to be able to give an webmaster a copy of the swf and the code to embed it on their html page... and that's it.

    Thank you! And I apologize in advance if this has been answered or its so simple one would feel the need to roll ones eyes. I'm stuck.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    In the HTML code that embeds the movie, there is an object tag and an embed tag.

    Both of these tags contain references to the .swf file you are using, like so:

    <param name="movie" value="bellcurve.swf" />
    ...
    <embed src="bellcurve.swf" ... etc.>


    In both cases, you can load up variables after the swf, like so:

    <param name="movie" value="bellcurve.swf?myVar=xxx&myVar2=yyy" />
    ...
    <embed src="bellcurve.swf?myVar=xxx&myVar2=yyy" ... etc.>

    And then when the movie runs, these variables will be available for your use in actionscript (attached to _root).

    I would suggest that you pass the desired URL to the movie this way.

    - Jim

  3. #3
    thank you thank you...
    i was just trying to figure out how to go that route.

    Lets say i use....

    <param name="movie" value="bellcurve.swf?myVar=http://domain.com/123/myMusic.mp3">


    where or how do i call myVar within the code below?
    I tried:
    myMusic.loadSound(myVar, true)

    what am i missing?

    onClipEvent (load) {
    if (playing!=true) {
    playing=true;
    soundIsLoaded=1
    myMusic=new Sound();
    myMusic.loadSound("myMusic.mp3",true)
    }

    }

  4. #4
    you can also add variables by doing this:

    <param name="flashvars" value="myVar=varValue">

    and then in the flash all you have to do to call the variables is us
    _root.myVar

    etc. etc.

    thanks!!


    (this is working for me...not sure if this is just my servers, or anyone using flash 6 or above)

  5. #5
    Junior Member
    Join Date
    Mar 2001
    Posts
    4

    still having (some) trouble....

    I'm just getting started 'dow n& dirty' with some code i plugged in:

    :
    var xml:XML;

    var urlLoader:URLLoader=new URLLoader();
    urlLoader.addEventListener( Event.COMPLETE, onXMLLoad );
    urlLoader.load(new URLRequest("images.xml"));
    function onXMLLoad(e:Event):void {

    xml = new XML(urlLoader.data);
    xml.ignorewhitespace = true;
    dancGIF.load( new URLRequest( xml..image[0].@url ));}


    I have a 'video??' placeholder called (not 'instance?) dancGIF on the stage;what mistakes have I made please?

    yes, also the error is: access of undefined property danceGIF.

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    dvafa, why did you post on this unrelated 2004 thread in the wrong Forum?

    gparis

  7. #7
    Junior Member
    Join Date
    Mar 2001
    Posts
    4
    I've been away from heav-y computer reading for some time.. I would like -like, to play it simple & easier since (I also have an eye stigmatism) rambling through 6-12 pages of this huge database takes a good deal..
    I figured the title is similar. hopefully someone could help me on my Actionscript journey by answering this question(above).I just am not ;really ' going to notice its from 2004. Someone please help. Dave

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    I suggest you post in the Actionscript 3.0 Forum, then.

    gparis

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