A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: text file parameters as variables.

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    3

    text file parameters as variables.

    Hi,
    I currently have a file set up that imports and external text file and displays the parameters in the text file in separate dynamic text fields. No problem there.

    the text file reads:

    param1 = 300&param2 = 450&param3 = 500

    However, what I want to be able to do, is set parameters that rather than defining text strings, define numeric values. I want to be able to use those numeric values to set the x position of an instance of an animated MC on the stage (animated with actionscript). I need to be able to pass the values from the text file to the actionscript.
    I tried using the code below and it doesn't work..,

    Actionscript Code:
    import fl.motion.Animator;
    var bull2001_xml:XML = <Motion>
    <source>
    <Source instanceName="bull2001" symbolName="bull">
    </Source>
    </source>

    <Keyframe index="0" >
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>

    <Keyframe index="49" x={param1}>
    <tweens>
    <SimpleEase ease="0"/>
    </tweens>
    </Keyframe>
    </Motion>;

    var bull2001_animator:Animator = new Animator(bull2001_xml, bull2001);
    bull2001_animator.play();

    Any help with this much appreciated, thanks in advance,

    Mat

  2. #2
    Junior Member
    Join Date
    May 2009
    Posts
    3
    OK, here's the thing.., I'm using this code to import the text file as variables

    Actionscript Code:
    var myTextLoader:URLLoader = new URLLoader();
    myTextLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
    myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

    function onLoaded(e:Event):void {
    trace(e.target.data.p0);
    trace(e.target.data.p1);
    }

    the textfile contents is p0=200&p1=150

    This code returns the values 200 and 150 in the output window...

    So the question is.., how on earth can I use these values in the actionscript above??, using the variables {p0} just returns p0 as undefined.., I realize this is a bit of a newbie question.., but this is driving me crazy and would very much appreciate some help with this,


    Matthew

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