Solved

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

Posted on 2006-06-08
5
251 Views
Last Modified: 2012-06-21
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



0
Comment
Question by:madmax61
  • 2
5 Comments
 
LVL 7

Expert Comment

by:muxxter
ID: 16871657
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
 

Author Comment

by:madmax61
ID: 16890570
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
 

Author Comment

by:madmax61
ID: 16892045
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
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17642136
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now