UIScrollBar on 2 separate dynamic text fields, scrollbar disappears after sendAndLoad

Hi flashers,

 I'm having a problem with an application which has 2 dynamic text fields. I have UIScrollBar in the library and I successfully utilise the scrollbar by attaching it to the different text field depending on which buttons on screen are clicked. I load files into these text fields no problems. The scrollbar appears on each of the textfields. In the debugger I see the scrollbar. I use the _visible = true or false to display the appropriate text field. I reassociate the scrollbar to the specific text field at the appropriate time, adjust it's position and size and make it visible. So far so good.

It seems once I click submit to allow the program to call a CGIbin program using sendAndLoad the scrollbars no longer display but the textfields still display content and are scrollable but the scrollbar is not there.

At this point in the program, in the debugger, the scrollbar disappears, and all trace statements in the program to display whether it is visible or invisible now come up as undefined where they happily displayed true or false in the same function code earlier. Obviously because for some reason the scrollbar just drops out of the programs assets for some reason.

Any idea why this might happen?

It isn't easy to display all this working code as 1. it is thousands of lines of code and 2. I probably can't really give out the entire work project source code and 3. I bet if I strip it down to small specific code it will probably work. 4. It calls a CGIbin program inhouse and not available external to my workplace.

Summary:
So anyway the code works up until it runs sendAndLoad and then UIScrollBar disappears from the program assets within debugger and yet I never attempt to remove it and don't even know how to.

Cheers,
Max



madmax61Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
DarthModConnect With a Mentor Commented:
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0
 
muxxterCommented:
Maybe you're doing something like:

myScroll = false;
 ... instead of
myScroll._visible = false;

I'd like to see the code in the onLoad function of the loadVars if possible. Or even describe more of what you're doing after the sendAndLoad (before and after it comes back to call the onLoad function)

Thanks
MuXx
0
 
madmax61Author Commented:
Hi MuXx,

Thankyou for the reply.

I isolated the code doing the relevant bits and sure enough it appears to work just fine. The scroll bar happily stays put, whereas in my full application the scrollbar property disappears (I see it disappear in the debugger) for no apparent reason. I'm wondering if I have come across some bug as there is no reason (that I can think of) as to why it would disappear seeing as I do not attempt to remove it.

I may have to give the textarea a try as it has built in support for scrollbars.


Ok I have the code below, but as I suggest it works fine, note I have edited out the cgibin program path.

Cheers,
Max



#include "scrollBars.as"
#include "helpButtons.as"
var lVars:LoadVars = new LoadVars();

var lReceiver:LoadVars = new LoadVars();

//
// Create the scrollbar for use in all the help screens.
//
_root.createClassObject(mx.controls.UIScrollBar, "scrollBar", depth++);
//
//
// Create text field.
//
var myStyle:TextField.StyleSheet = new TextField.StyleSheet();
_root.myStyle.load("sample2.css");
_root.help_Content_txt.styleSheet = myStyle;
_root.help_Content_txt.multiline = true;
_root.help_Content_txt.wordWrap = true;
_root.help_Content_txt.html = true;
//
var mainHelp:XML = new XML();
_root.mainHelp.ignoreWhite = true;
_root.mainHelp.onLoad = function() {
      _root.help_Content_txt.htmlText = _root.mainHelp;
};

..........................
helpButtons.as
..........................


_root.help_btn.onRelease = function() {
      trace("help button pressed");
//
      _root.mainHelp.load("input1.html");
      //
      // Set up appropriate help field with scrollbar
      //
      setScrollHelp();
      _root.legal_txt._visible = false;
      _root.help_Content_txt._visible = true;
      //
};

_root.input_btn.onRelease = function() {
      trace("input button pressed");
//
      _root.legal_txt._visible = true;
      _root.help_Content_txt._visible = false;
      //
      // Create the dynamic text field.
      //
      // Is it necessary to load sample2.css again? Done in helpbuttons. Sort this out.
      //
      var myStyle2:TextField.StyleSheet = new TextField.StyleSheet();
      myStyle2.load("sample2.css");
      _root.legal_txt.styleSheet = myStyle2;
      _root.legal_txt.multiline = true;
      _root.legal_txt.wordWrap = true;
      _root.legal_txt.html = true;
      //
      var legal:XML = new XML();
      legal.ignoreWhite = true;
      // change to legal.html below when ready
      legal.load("legal.html");
      legal.onLoad = function() {
            _root.legal_txt.htmlText = legal;
      };
      //
      // Set up appropriate help field with scrollbar
      //
      setScrollLegal();
};
//
//
//
_root.submit_btn.onRelease = function() {
      trace("submit button pressed");
      makeFormVars();
};
//*********************************************************************************
//
//
//
//      S T A R T     O F     CODE TO TALK TO UNIX SERVER THRU CGI
//
//
//
//**********************************************************************************
var makeFormVars = function () {
      lVars.lat = Number(23000);
      lVars.lon = Number(124000);
      trace("lVars.lat = "+lVars.lat+"lVars.lon = "+lVars.lon);
      trace("pre cgi call");
      //
      _root.legal_txt._visible = false;
      _root.help_Content_txt._visible = false;
      _root.scrollBar._visible = false;
      //
      lVars.sendAndLoad("http://******edited out******/myprogram", lReceiver, "POST");
};
.........................
scrollbars.as
.........................

function setScrollHelp():Void {
      //
      // Set the scrollbar to be used with the help_Content_txt dynamic textfield
      // which is larger than the help dynamic textfield
      // this reuses the UIScrollbar but alters the size
      //
      // Set the target text field for the scroll bar.
      _root.scrollBar.setScrollTarget(_root.help_Content_txt);
      // Size it to match the text field.
      _root.scrollBar.setSize(16, _root.help_Content_txt._height);
      // Move it next to the text field.
      _root.scrollBar.move(_root.help_Content_txt._x+_root.help_Content_txt._width+25, _root.help_Content_txt._y);
      //      
      // Now make the large help dynamic textfield visible
      //
      _root.help_Content_txt._visible = true;
      //
      // Make the scrollbar visible
      //
      trace("============in setScrollHelp=====");
      trace("_root.scrollBar._visible = "+_root.scrollBar._visible);
      _root.scrollBar._visible = true;
      trace("_root.scrollBar._visible = "+_root.scrollBar._visible);
}
function setScrollLegal():Void {
      //
      // Set the scrollbar to be used with the legal_txt dynamic textfield
      // which is smaller than the help dynamic textfield
      // this reuses the UIScrollbar but alters the size
      //
      // Set the target text field for the scroll bar.
      _root.scrollBar.setScrollTarget(_root.legal_txt);
      // Size it to match the text field.
      _root.scrollBar.setSize(16, _root.legal_txt._height);
      //
      // Move the scrollbar to right of the text field.
      //
      _root.scrollBar.move(_root.legal_txt._x+_root.legal_txt._width+25, _root.legal_txt._y);
      //      
      // Now make the small legal dynamic textfield visible
      //
      _root.legal_txt._visible = true;
      //
      // Make the scrollbar visible
      //
      _root.scrollBar._visible = true;
}
0
 
madmax61Author Commented:
Well I have worked out my problem, and it was only because I went on a hunch. I've been wanting to clean up my code in the area of setting depths for the various movieclips.

I have been using a variable called depth and incrementing it. i.e. depth++ I knew it would eventually get me into trouble :(

I added a getNextHighestDepth() and it has resolved itself (I think), so I will work through the program and change all occurrences of depth++ and see how I go.

And the reason the code above worked when I isolated it, because there weren't depth conflicts I guess.

Cheers,
Max
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.