Loading variables from txt

Hello everybody,
I have a flash file with two dynamic fields which get data
from a txt file. There is one more dynamic field in flash which i
want to display a certain calculation result between the values of
the two other dynamic fields. The two vars are loaded from the txt
file without any problem, but flash recognizes them as strings and
as a result, the calculation is impossible (NaN). How can i convert
the loaded data from the txt file into numeric ones in order to be
able to do calculations between them?
Thank you

You have a choice:
if your string values is called myVar1
You can convert it to a number type in the following ways:
myVar1=parseInt(myVar1); //for parsing integer values,
ignores after any decimal points - useful particularly for hex
strings etc
myVar1=parseFloat(myVar1); //parses the value into a regular
precision number
myVar1=Number(myVar1);
You can read more about each of the above in the relevant
links on the following page:
http://livedocs.adobe.com/flash/9.0/main/00001166.html

Similar Messages

  • How to load variables from a .txt file

    Hi.
    I usually make a flash aplication in colaboration with a php
    programmer. But i want to test my swfs without having to wait for
    him. So i want to do that through a text file. I know that flash
    can load variables from text files. The problem is i don't know how
    to format the text file ( example.txt).
    Thank you

    Here's a couple of ideas.
    First you probably want to change what you have...and put
    your 'if (pVar==1' etc inside a separate function and call it from
    the onLoad handler after you have assigned the value to pVar...
    because the onLoad will run at some unknown point in time after
    loading has finished (actually in the test environment this might
    work... but that wouldn't be the same as what happens in a
    production setting).
    To create test files for loadvars... simply create a new as2
    file and put this code on the first frame and test movie:

  • Movie refuses to load variables from text file

    Hi,
    I'm sure you can solve my newbie problem in less than 1
    minute...
    I'm pulling my hair out on a template I bought 2 days ago
    from templatemonster.com
    I am using Flash 8 Pro.
    All I want to do is change an existing textfield that is
    Static to Dynamic and load variables from a text file.
    The Action Script I use to do so comes directly from
    Macromedia documentation (see attached)
    It works fine when I create a brand new movie, but doesn't do
    anything when inserted into the template.
    It doesn't even complain about not finding the text file if I
    rename or delete it!
    Here are the FLA and text file:
    Edit : Link to source file removed
    The textfield I would like to change is in the txt2 symbol.
    Here is how I proceed:
    When I open HEADER.FLA, Flash tells me I'm missing a font,
    ok, so I click on Use Default, I'll deal with this later.
    I open up the Movie Explorer, go to Layer 30, go to Frame 75
    and click once on txt2
    I name the instance "myMovie_mc" and save (converts from
    Flash MX to Flash 8)
    I double-click on the Movie Clip, select the word
    "Automobile" on the Stage, change from Static to Dynamic and call
    that instance "myText_txt"
    Still in the Movie Clip, I create a new layer I call
    "actions", and in Frame 1 I copy the attached Action Script:
    This script works when I create a new flash file, but it does
    absolutely nothing in this template.
    I know I'm doing something wrong, but I wonder what?
    Many thanks to any helping soul!
    Ferris.

    try this:
    // Load text as variable and assign it to the
    // dynamic text field
    var features_lv:LoadVars = new LoadVars();
    features_lv.onLoad = onText();
    features_lv.load("safetyFeatures.txt");
    function onText(success:Boolean) {
    if (success) {
    myText_txt.text = features_lv.safetyfeatures;
    } else {
    myText_txt.text = "unable to load text file.";
    or this
    // Load text as variable and assign it to the
    // dynamic text field
    var features_lv:LoadVars = new LoadVars();
    features_lv.onLoad = function(success) {
    if (success) {
    myText_txt.text = features_lv.safetyfeatures;
    } else {
    myText_txt.text = "unable to load text file.";
    features_lv.load("safetyFeatures.txt");

  • Loading Variables from ASP into Flash

    I can find plenty of tutorials detailing how to load
    variables from a defined asp page into Flash, but here's my
    dilemma...
    I have an asp page that is reading a URL with a unique
    identifier in it (www.sampleURL.com?id=123456), and then turns the
    id number from the URL into a variable. On the same page then, sits
    my swf where I need to use LoadVars to pull in that ASP variable
    via Actionscript. If I don't have a static asp page to pull the
    variables in from and I want to pass the variable within the same
    asp page the swf is located on, how do I do it? Many thanks in
    advance...

    "bonzomn65" <[email protected]> wrote in
    message
    news:ej0630$pjh$[email protected]..
    >I can find plenty of tutorials detailing how to load
    variables from a
    >defined
    > asp page into Flash, but here's my dilemma...
    >
    > I have an asp page that is reading a URL with a unique
    identifier in it
    > (www.sampleURL.com?id=123456), and then turns the id
    number from the URL
    > into a
    > variable. On the same page then, sits my swf where I
    need to use LoadVars
    > to
    > pull in that ASP variable via Actionscript. If I don't
    have a static asp
    > page
    > to pull the variables in from and I want to pass the
    variable within the
    > same
    > asp page the swf is located on, how do I do it? Many
    thanks in advance...
    >
    You don't need LoadVars for this at all. You can just pass
    the variable to
    your Flash movie by specifying a query string when you are
    calling the
    movie.
    If you are using the straight object, embed method then it
    would look
    something like this:
    <param name="movie" value="movie.swf?id=11111">
    <embed src="movie.swf?id=11111" ... >
    If you are using the ActiveContent JavaScript for your movie
    then you just
    leave off the .swf... so
    "name", "movie?id=11111"
    Then, in flash you can access the value of id from the _root,
    like
    var idInFlash:Number = _root.id;
    Of course in the above example you would replace 11111 with
    the proper
    syntax for printing a variable's value in ASP.

  • Load variables from XML into Flash

    I was wondering how to load variables from an XML document to
    a Flash file? I am familiar with the code to do it for a text file,
    but was wondering how to do it for XML.
    Many thanks in advance!
    JJ

    Thanks for the recommendation on the site. What I am trying
    to do is load varaibles from an XML file into text boxes in my
    flash movie.
    Here is my loading:
    var my_xml = new XML();
    my_xml.ignoreWhite = true;
    my_xml.onLoad = function(success){
    if (success) {
    gotoAndStop("slide01");
    my_xml.load("narration.xml");
    this is what I have on my frame with the text boxes (the text
    boxes are also have the variable name in the variable area)
    var narration = my_xml.picture01;
    var my_title = my_xml.my_title;
    var my_date = my_xml.my_date;
    should I do my_date.text = my_xml.my_date; instead?
    my xml doc looks like this
    <?xml version="1.0" encoding="iso-8859-1"?>
    <picture01>This is the text for picture
    01</picture01>
    <picture02>This is the text for picture
    02</picture02>
    <my_title>Las Vegas</my_title>
    <my_date>October</my_date>
    Any help on this would be GREATLY appreciated!
    Text
    my_date.text = my_xml.my_date;

  • SQL Loader problem while loading records from txt file to database table.

    I am getting following error while loading records from flat txt file into database table with the help of 'sqlldr' command. I have executed catldr.sql from RDBMS folder but it is still showing same error. I am setting DIRECT = TRUE while issuing sqlldr command. If I try with DIRECT = FALSE then it works fine. Database is Oracle 8i.
    SQL*Loader-951: Error calling once/load initialization
    ORA-24329: invalid character set identifier
    F1 Please.

    Hello,
    Direct path load, can only be used with SQL*Loader and Database have the same version.
    Care to tell the database version and sql*loader version you are using.
    -Sri

  • Loading Variable from a file in BI 7.0 queries

    Hi All,
    When we run BW 3.x queries through RRMX, we get option to load the variables values via import from file means loading the variables values from a file. Do we have this option available in case of 7.0 queries also as 7.0 queries directly run on portal.
    I know via RSRT, i have that option available for 7.0 queries as well.
    Thanks in advance.
    Sumita.

    Hi,
    In 7.0 it is not possible to load directly from a flat file when you run the query in the portal. However, I don't think it was an option in 3.x either. In het analyzer, both 3.x and 7.0 have that option, only the copy paste functionallity is gone in 7.0, you have to use a flatfile now. Also, in 7.0 portal you can add indivual values for a variable sperated by a ; sign. So you can use excel to create a ; seperated csv file and copy and paste from that.
    Kind regards,
    Alex

  • Loading Variables from a php file

    Im trying to get the stats from a shoutcast radio stations
    into flash so i can manipulate them into a nicer looking site.
    Anyway, ive identified the line on which the stats are
    updated (its in a php file, line 48):
    <stong>Current
    Song:</strong></b><p><marquee>
    Morel&#x27;s Grooving Again - That Melody [Morel&#x27;s
    Groove Mix]</font></p>
    and i was wondering the following things:
    is it possible to have flash load only this line of text from
    the php file,
    how do i get flash to recognise "<stong>Curren Song" as
    the variable
    how to get flash to recognise the colon sign as meaning that
    that is waht the variable is equal to,
    and how, once flash recognises the parameter, to remove the
    formatting code from the text.
    Or is there an easier way of getting this variable into
    flash, like using some kind of self-updating html file...
    help would be much appreciated.
    thanks

    u can convert the array in to a string in FLEX and in PHP u can use the "split" command...
    here s sample program see if it helps u
    http://flexarraytransfer.blogspot.com/
    similary u can transfer VARIABLES also,in the place of the string just put ur variable on the PHP use t variable without spliting t

  • Loading Variable from HTML

    I am trying to load a variable into a flash file from the
    html page which it is displayed on. What i am trying to do is load
    a photo album category from a GET variable
    (photo_album.htm?cat=test) into the loadXMLgroup Actionscript event
    for a program which I am using. I essentially want to be able to go
    to photo_album.htm?cat=test and end up with the event
    loadXMLgroup("test").
    Please Help.

    SWFObject will help you do this easily
    Check out the getQueryParamValue example on this page:
    http://blog.deconcept.com/swfobject/

  • Loading variable from a file in 7.0 Queries

    Hi All,
    When we run BW 3.x queries through RRMX, we get option to load the variables values via import from file means loading the variables values from a file. Do we have this option available in case of 7.0 queries also as 7.0 queries directly run on portal.
    I know via RSRT, i have that option available for 7.0 queries as well.
    Thanks in advance.
    Sumita.

    Hi,
       Please check out this link. They are requesting to use patch level 14 to the SAP front end.
    Re: Clipboard option in BI7
    Hope this helps for you.
    Thanks,
    Arun.

  • Loading variables from JAVA PROGRAM

    Hello, i have a java program how have on a variables that i want to put on a DataBase Oracle9i.
    Help me

    Hey, if you're the one that posted this: http://forum.java.sun.com/thread.jsp?forum=32&thread=495288 then you still owe me some..
    You want environment vars to remain changed after your programme finished? Do you want them to remain changed in a new session (logout/login) ? Do you want them changed in both Systems equally (the mechanisms are equal but the syntax is different in DOS and Unix shells) ?
    As I do not get tired to repeat: provide some information and the possibility of being helped is raised exponentially => explain what you try to do and people will try to help you.
    -T-

  • Has anyone loaded variables from paypal using ipn?

    Im so flustered. I'm using flash 8 pro btw.

    I had a problem while loading the AOL disc just after getting my Mac Pro. AOL would show the spinning beach ball and not seem to finish the installation. AOL would not run.
    About a week later I noticed the AOL Radio application was loaded and started it. I had to sign in with my AOL screenname and password. Radio worked. A bit later I noticed that the AOL icon was now showing that it was running. I clicked on the icon and AOL opened and ran normally. I signed on and all was normal.
    AOL sure did not work when I first tried. I was using Apple's MAIL to get AOL e-mail.

  • Loading Variables in a Class Function

    I am having problems loading variables from an external text
    file inside of a class function. The text file has been created
    properly, and the code that I use in the class is as follows:
    _root.createEmptyMovieClip("texRules", -100);
    loadVariables("texRules.txt", _root.texRules);
    m_Rules = _root.texRules.rules;
    I create an empty movie clip on the root frame named
    texRules, load the variables into that movie clip with the next
    line and then set my member string value equal to the text file
    variable named rules. When I run the program, I get an undefined
    for my m_Rules.
    Here is my texRules.txt:
    rules=THESE ARE THE TEXAS HOLD'EM RULES.
    Any ideas as to what I am doing incorrectly?

    I've opted to use the LoadVars instead of creating an empty
    movie clip and loading the variables there. Here is my new code.
    public function setRules():Void
    var rulesLoader:LoadVars = new LoadVars();
    rulesLoader.onLoad = function (success:Boolean):Void
    if (success)
    trace(rulesLoader.rules);
    this.m_Rules = rulesLoader.rules;
    else
    trace( "Unable to load external file.");
    rulesLoader.load("texRules.txt");
    Here is where I define my properties of my class:
    class TexHoldem extends Game
    //Class member properties
    //Private Properties
    private var m_Rules:String;
    private var m_Target:MovieClip;
    Here is my constructor:
    public function TexHoldem(target)
    this.m_Target = target;
    super("Texas No Limit Hold'Em", 0, 1);
    setRules();
    The setRules function works fine, the only problem now is
    that I can't save the variables once the onLoad function goes out
    of scope. I've thought of modifying it so that it returns a type,
    but that seems difficult. The two easiest solutions I see is to
    create an empty text field that holds the string or find a way to
    get the rulesLoader.rules outside of the onLoad scope. Any
    suggestions now? Sorry to change the problem on you.

  • Actionscript to load captions from array to dynamic text when thumb is clicked

    i have this code below that i made using a tutorial....it loads vars from txt file splits it then puts it into an array....once in an array it the brings the pics in from the array to create thumbnails and a larger image. my problem is i have captions to go with it and when i try to load the captions nothing happens or can be seen to be happening.
    i dont know where i am going wrong as i have no output or compiled errors
    var locVar = new Array();
    locVar = imgLoc.split(",");
    trace ( locVar );
    var tmbVar = new Array();
    tmbVar = tmbLoc.split(",");
    trace ( tmbVar );
    var capVar = new Array();
    capVar = imgCap.split(",");
    trace ( capVar );
    var NPICS:Number = locVar.length;     // number of pictures to load
    var PICX:Number = 32.8;               // x loc of big picture
    var PICY:Number = 24.9;               // y loc
    var THUMBHOLDERX:Number = 50;        // x location of thumbnail holder movieclip
    var THUMBHOLDERY:Number = 457;      // y location
    var THUMBW:Number = 100;             // width of each thumbnail
    var THUMBH:Number = 75;             // height
    var MARGIN:Number = 10;             // margin between thumbnails
    var TOTALBYTES:Number = 212000;     // approx sum of bytes in all jpgs (x 2)
    var MAXPIXELS:Number = 12;          // max number of pixels to move slider per frame
    // mask definition; mask is assumed to cover some part of the thumbnail slider (here the numbers
    // were chosen so that there are margins between the mask and the right and left edges of the movie
    // (which is 420 x 290), and enough space above and below the thumbs to show them when they 'grow'
    // on mouseover
    var MASKX:Number = 0;                    // start x location of mask
    var MASKW:Number = 600;                    // mask width
    var MASKY:Number = 447.9;                    // start y location of mask
    var MASKH:Number = 92;                    // mask height
    var totalloaded:Number = 0;         // running tally of bytes loaded from all pics
    // index into pictures array, used for loading
    var ipic:Number;
    // set up loader, an instance of MovieClipLoader
    var loader:MovieClipLoader = new MovieClipLoader();
    // use the main timeline to listen to and respond to loader's broadcast events
    loader.addListener(this);
    // function to move thumbnail slider ("this" = thumbs_mc)
    function sliderControl() {
       var w:Number = this._width/2;
       var hw:Number = mask_mc._width/2;
       var npixels:Number;
       // only do when mouse over slider mask
       if (_ymouse > mask_mc._y && _ymouse < mask_mc._y + mask_mc._height) {
          // mouse over left half of slider:
          if (_xmouse > mask_mc._x && _xmouse < mask_mc._x + hw) {
             npixels = (hw - _xmouse) / hw * MAXPIXELS;
             this._x += npixels;
             if (this._x >= 0) this._x = this._x - w;
          // mouse over right half of slider:
          } else if (_xmouse > mask_mc._x + hw && _xmouse < mask_mc._x + mask_mc._width) {
             npixels = (_xmouse - hw) / hw * MAXPIXELS;
             this._x -= npixels;
             if (this._x <= -w) this._x = this._x + w;
    // thumbnail click (onrelease) handler
    function openPic() {
       pic_mc.loadMovie(locVar[this.i]);
    function brightON(){
         this._alpha = 300;
    function brightOFF(){
         this._alpha = 30;
    function captionTXT(){
         _root.cap_txt = capVar;
    // assign event handlers (called when all jpgs are loaded)
    function setupHandlers() {
       pct_txt.removeTextField();          // don't need loading indicator any more
       thumbs_mc.onEnterFrame = sliderControl;
       for (var i:Number = 0; i < NPICS*2; i++) {
          thumbs_mc["mc"+i].onRollOver = brightON;
          thumbs_mc["mc"+i].onRollOut = brightOFF;
          thumbs_mc["mc"+i].onMouseDown = captionTXT;
          thumbs_mc["mc"+i].onRelease = openPic;
    // listener function for broadcast 'done' message (for each pic)
    // onLoadInit gets executed when the movieclip has been loaded into _mc AND
    //   its width and height data are available.
    //   (_mc = the movieclip being loaded into)
    // this routine sets the size and position of each thumbnail clip as its jpg
    //   is loaded and starts the next one loading.  When all have been loaded,
    //   a random picture is loaded into pic_mc and setupHandlers is called to
    //   assign handlers to each thumbnail movieclip
    function onLoadInit(_mc:MovieClip) {
       // this gets done when the jpg is completely loaded:
       _mc._width = THUMBW;
       _mc._height = THUMBH;
       _mc._alpha = 30;          // for image clarity
       // give the movieclip a property to remind it who it is
       // (used by openPic to know which big picture to open)
       _mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
       // add picture size to totalloaded variable
       totalloaded += loader.getProgress(_mc).bytesTotal;
       // now load the next one (if there are more) or set up handlers if done
       ipic++;
       if (ipic == NPICS * 2) {
          // start with a random photo displayed when all thumbs loaded
          pic_mc.loadMovie(locVar[Math.floor(Math.random()*NPICS)]);
          setupHandlers();
       } else if (ipic >= NPICS) {
          // load jpg into duplicate thumbnail (will already be cached)
          loader.loadClip(tmbVar[ipic-NPICS],  thumbs_mc["mc"+ipic]);
       } else {
          // load jpg into thumbnail
          loader.loadClip(tmbVar[ipic],  thumbs_mc["mc"+ipic]);
    // listener function to handle broadcast progress messages
    // make pct_txt show cumulative loading progress
    function onLoadProgress(_mc:MovieClip, loaded:Number) {
       var loadedsofar:Number = totalloaded + loaded;    
       pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) + "%";
    function init() {
       // create holder for pictures
       createEmptyMovieClip("pic_mc", 1);
       pic_mc._x = PICX;
       pic_mc._y = PICY;
       // create (and draw) holder for thumbnails
       createEmptyMovieClip("thumbs_mc", 2);
       thumbs_mc.beginFill(0, 100);     // black
       thumbs_mc.moveTo(0, 0);
          thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
       thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
       thumbs_mc.lineTo(0, THUMBH);
       thumbs_mc.endFill();
       // drawing the thumb holder at 0, 0 and then moving it makes its reg point = upper left
       thumbs_mc._x = THUMBHOLDERX;
       thumbs_mc._y = THUMBHOLDERY;
       // create, draw and enable mask over thumbs (could use different variables to define mask
       // if desired)
       createEmptyMovieClip("mask_mc", 3);
       mask_mc.beginFill(0x0000cc, 100);
       mask_mc.moveTo(0, 0);
       mask_mc.lineTo(MASKW, 0);
       mask_mc.lineTo(MASKW, MASKH);
       mask_mc.lineTo(0, MASKH);
       mask_mc.endFill();
       mask_mc._x = MASKX;
       mask_mc._y = MASKY;
       thumbs_mc.setMask(mask_mc);
       // create loading textfield indicator
       createTextField("pct_txt", 4, 200, 100, 40, 100);
       var tf:TextFormat = new TextFormat();
       tf.align = "center";
       tf.size = 12;
       tf.font = "Verdana";
       tf.color = 0xFFFF00;
       pct_txt.setNewTextFormat(tf);
       // create loading textfield indicator
       createTextField("cap_txt", 0, 400, 200, 40, 100);
       var cf:TextFormat = new TextFormat();
       cf.align = "center";
       cf.size = 12;
       cf.font = "Verdana";
       cf.color = 0xFFFF00;
       cap_txt.setNewTextFormat(cf);
       // make empty movieclips in thumbs_mc for each pic to go into
       // make double the number so the slider can move continuously and show content
       for (var i:Number = 0; i < NPICS * 2; i++) {
          var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
          mc._x = i*(MARGIN + THUMBW);
          mc._y = 0;
       // set the pointer to the first jpg in the array picnames
       ipic = 0;
       // start loading jpgs (ipic is initialized to 0)
       loader.loadClip(locVar[ipic], thumbs_mc["mc"+ipic]);
    init();
    stop();

    ok here is my code so far.....i've set a movieclip where i want the captions and set the dyn text box above the clip....i've given the movieclip a background n faded so images can still be seen behind.
    im just having a problem with the loop.....each one i tried resulted in the caption staying the same no matter what thumbnail is clicked.
    are there any suggestions as to how this can be done......(please bare in mind im a newbie to actionscript)
    var locVar = new Array();
    locVar = imgLoc.split(",");
    var tmbVar = new Array();
    tmbVar = tmbLoc.split(",");
    var capVar = new Array();
    capVar = imgCap.split(",");
    var NPICS:Number = locVar.length;     // number of pictures to load
    var PICX:Number = 32.8;               // x loc of big picture
    var PICY:Number = 24.9;               // y loc
    var THUMBHOLDERX:Number = 50;        // x location of thumbnail holder movieclip
    var THUMBHOLDERY:Number = 457;      // y location
    var THUMBW:Number = 100;             // width of each thumbnail
    var THUMBH:Number = 75;             // height
    var MARGIN:Number = 10;             // margin between thumbnails
    var TOTALBYTES:Number = 212000;     // approx sum of bytes in all jpgs (x 2)
    var MAXPIXELS:Number = 12;                    // max number of pixels to move slider per frame
    var CAPSW:Number = 525;                    
    var CAPSH:Number = 28;     
    var CAPSX:Number = 38;            //caption text x position
    var CAPSY:Number = 391;            //caption text y position
    // mask definition; mask is assumed to cover some part of the thumbnail slider (here the numbers
    // were chosen so that there are margins between the mask and the right and left edges of the movie
    // (which is 420 x 290), and enough space above and below the thumbs to show them when they 'grow'
    // on mouseover
    var MASKX:Number = 0;                    // start x location of mask
    var MASKW:Number = 600;                    // mask width
    var MASKY:Number = 447.9;                    // start y location of mask
    var MASKH:Number = 92;                    // mask height
    var totalloaded:Number = 0;         // running tally of bytes loaded from all pics
    // index into pictures array, used for loading
    var ipic:Number;
    // set up loader, an instance of MovieClipLoader
    var loader:MovieClipLoader = new MovieClipLoader();
    // use the main timeline to listen to and respond to loader's broadcast events
    loader.addListener(this);
    // function to move thumbnail slider ("this" = thumbs_mc)
    function sliderControl() {
       var w:Number = this._width/2;
       var hw:Number = mask_mc._width/2;
       var npixels:Number;
       // only do when mouse over slider mask
       if (_ymouse > mask_mc._y && _ymouse < mask_mc._y + mask_mc._height) {
          // mouse over left half of slider:
          if (_xmouse > mask_mc._x && _xmouse < mask_mc._x + hw) {
             npixels = (hw - _xmouse) / hw * MAXPIXELS;
             this._x += npixels;
             if (this._x >= 0) this._x = this._x - w;
          // mouse over right half of slider:
          } else if (_xmouse > mask_mc._x + hw && _xmouse < mask_mc._x + mask_mc._width) {
             npixels = (_xmouse - hw) / hw * MAXPIXELS;
             this._x -= npixels;
             if (this._x <= -w) this._x = this._x + w;
    // thumbnail click (onrelease) handler
    function openPic() {
            pic_mc.loadMovie(locVar[this.i]);
    function brightON(){
         this._alpha = 300;
    function brightOFF(){
         this._alpha = 30;
    function captionTXT(){
         cap_txt.text = capVar[this.i];
    // assign event handlers (called when all jpgs are loaded)
    function setupHandlers() {
       pct_txt.removeTextField();          // don't need loading indicator any more
       thumbs_mc.onEnterFrame = sliderControl;
       for (var i:Number = 0; i < NPICS*2; i++) {
          thumbs_mc["mc"+i].onRollOver = brightON;
          thumbs_mc["mc"+i].onRollOut = brightOFF;
          thumbs_mc["mc"+i].onMouseDown = captionTXT;
          thumbs_mc["mc"+i].onRelease = openPic;
    // listener function for broadcast 'done' message (for each pic)
    // onLoadInit gets executed when the movieclip has been loaded into _mc AND
    //   its width and height data are available.
    //   (_mc = the movieclip being loaded into)
    // this routine sets the size and position of each thumbnail clip as its jpg
    //   is loaded and starts the next one loading.  When all have been loaded,
    //   a random picture is loaded into pic_mc and setupHandlers is called to
    //   assign handlers to each thumbnail movieclip
    function onLoadInit(_mc:MovieClip) {
       // this gets done when the jpg is completely loaded:
       _mc._width = THUMBW;
       _mc._height = THUMBH;
       _mc._alpha = 30;          // for image clarity
       // give the movieclip a property to remind it who it is
       // (used by openPic to know which big picture to open)
       _mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
       // add picture size to totalloaded variable
       totalloaded += loader.getProgress(_mc).bytesTotal;
       // now load the next one (if there are more) or set up handlers if done
       ipic++;
       if (ipic == NPICS * 2) {
          // start with a random photo displayed when all thumbs loaded
           var calc:Number = Math.floor(Math.random()*NPICS);
          pic_mc.loadMovie(locVar[0]);
           cap_txt.text = capVar[0];
          setupHandlers();
       } else if (ipic >= NPICS) {
          // load jpg into duplicate thumbnail (will already be cached)
          loader.loadClip(tmbVar[ipic-NPICS],  thumbs_mc["mc"+ipic]);
       } else {
          // load jpg into thumbnail
          loader.loadClip(tmbVar[ipic],  thumbs_mc["mc"+ipic]);
    // listener function to handle broadcast progress messages
    // make pct_txt show cumulative loading progress
    function onLoadProgress(_mc:MovieClip, loaded:Number) {
       var loadedsofar:Number = totalloaded + loaded;     
       pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) + "%";
    function init() {
       // create holder for pictures
       createEmptyMovieClip("pic_mc", 1);
       pic_mc._x = PICX;
       pic_mc._y = PICY;
       // create (and draw) holder for thumbnails
       createEmptyMovieClip("thumbs_mc", 2);
       thumbs_mc.beginFill(0, 100);     // black
       thumbs_mc.moveTo(0, 0);
       thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
       thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
       thumbs_mc.lineTo(0, THUMBH);
       thumbs_mc.endFill();
       // drawing the thumb holder at 0, 0 and then moving it makes its reg point = upper left
       thumbs_mc._x = THUMBHOLDERX;
       thumbs_mc._y = THUMBHOLDERY;
       // create, draw and enable mask over thumbs (could use different variables to define mask
       // if desired)
       createEmptyMovieClip("mask_mc", 3);
       mask_mc.beginFill(0x0000cc, 100);
       mask_mc.moveTo(0, 0);
       mask_mc.lineTo(MASKW, 0);
       mask_mc.lineTo(MASKW, MASKH);
       mask_mc.lineTo(0, MASKH);
       mask_mc.endFill();
       mask_mc._x = MASKX;
       mask_mc._y = MASKY;
       thumbs_mc.setMask(mask_mc);
       // create loading textfield indicator
       createTextField("pct_txt", 4, 200, 100, 40, 100);
       var tf:TextFormat = new TextFormat();
       tf.align = "center";
       tf.size = 12;
       tf.font = "Verdana";
       tf.color = 0xFFFF00;
       pct_txt.setNewTextFormat(tf);
       createEmptyMovieClip("caps_mc", 5);
       caps_mc.beginFill(0x000000, 50);
       caps_mc.moveTo(0, 0);
       caps_mc.lineTo(CAPSW, 0);
       caps_mc.lineTo(CAPSW, CAPSH);
       caps_mc.lineTo(0, CAPSH);
       caps_mc.endFill();
       caps_mc._x = CAPSX;
       caps_mc._y = CAPSY;
       // create loading textfield indicator
       createTextField("cap_txt", 6, 38, 380, 525, 25);
       var cf:TextFormat = new TextFormat();
       cf.align = "center";
       cf.size = 16;
       cf.font = "Arial Black";
       cf.color = 0xFFFFFF;
       cap_txt.setNewTextFormat(cf);
       cap_txt._x = CAPSX;
       cap_txt._y = CAPSY;
       // make empty movieclips in thumbs_mc for each pic to go into
       // make double the number so the slider can move continuously and show content
       for (var i:Number = 0; i < NPICS * 2; i++) {
          var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i, i+1);
          mc._x = i*(MARGIN + THUMBW);
          mc._y = 0;
       // set the pointer to the first jpg in the array locVar
       ipic = 0;
       // start loading jpgs (ipic is initialized to 0)
       loader.loadClip(locVar[ipic], thumbs_mc["mc"+ipic]);
       cap_txt.text = capVar[2];
    init();
    stop();

  • Load variables, remembering variables

    I am trying to load variables from a text file, and have them
    available from then onwards in the movie, globally so to speak.
    While I can read the variable values in a loader function
    which executes when the text file is loaded, I don't seem to be
    able to keep those variables available afterwards.
    How do I that? Isn't AS3 wonderful? :(
    John

    I think you are missing the fact that things don't happen in
    a sequence you write the code. The very core of events model is to
    allow dealing with things happening asynchronous and at
    unpredictable times while proceeding with the code.
    In your example I suspect you envision that when Flash hits
    the line "function urlLoader_complete(evt:Event) {" it waits until
    text is loaded. This is not correct. The fact (and the beauty) of
    it is that Flash goes right pass this line to the line
    "trace("After: " + sspColourBG);" Naturally, sspColorBG variable is
    not defined by that point.
    urlLoader_complete is executed ONLY after index.as3.txt is
    loaded which happens some time after.
    I suggest to time your code to grasp the sequence of events.
    In the example below you will observe that trace 2 comes after
    trace 4:
    trace("1: " + getTimer());
    var sspColourBG;
    function urlLoader_complete(evt:Event) {
    trace("2: " + getTimer());
    trace("During: " + urlLoader.data.extColourBG); // returns
    correct value
    trace("3: " + getTimer());
    trace("After: " + sspColourBG); // returns undefined
    trace("4: " + getTimer());

Maybe you are looking for

  • How to search content in repository through portal

    i want to search the content present in my content repository with input as a string ,which will be searched in content and displayed through portal. or can i navigate bea content search into portal

  • Rare e-mail notifications when purchasing from iTunes Store?

    Hello. I use various Macs machines (Mini, Pros, and virtual machines (VMs)) and latest versions (Mac OS X 10.5.8, 10.7.5, 10.8.5, and 10.9.4) with their iTunes (various latest versions, but don't remember which ones). I noticed when getting free stuf

  • Material Staging for Production

    Hi, When WM is implemented, is it really necessary to use Production supply area and Control Cycle? or only Interim storage area 100 is sufficient? We are not using any KANBAN features,, Regards Shrinivas

  • LG G3 - When will I get my Lollipop?

    SO, LG G2 Has been upgraded to Android Lollipop 5.0 before my LG G3. In the first place, this is unacceptable for being the current flagship model that LG Supports, in addition all the other major carriers now support OTA (over the air) Upgrade for L

  • How to report that my ipod was stolen

    my ipod was stolen but has a password on it can anybody help me track it with mobile me on it