all groups > flash actionscript > october 2005 >
You're in the

flash actionscript

group:

I'm sorta new to actionscript and have several problems....



I'm sorta new to actionscript and have several problems.... Key Chung
10/31/2005 11:16:29 PM
flash actionscript: I'm slogging my way through Lynda's Flash MX 2004: Beyond The Basics: Hands-On
Training Manual and have run across a few moments where the tutorials (and the
actionscript I've used to complete them,) do not act like they're supposed to.
I don't know if it's my fault, the book's or a bug in Flash. (seeing as how
lynda.com offers no support on this, i thought I'd try my luck here.)

The first problem is (chapter 6, exercise 9) when I try to set an inline swf
file within a txt file that's being loaded into a dynamic text field when you
click the OUR STAFF menu button using the loadVars. If I delete the code in the
txt file (img src="swfs/staff-01.swf" width="75" height="75" align="left"
hspace="10" vspace-"5") that call for the swfs, the text renders perfectly in
the dynamic text field. When I put it back in, not even the text renders.

The second problem (chapter 11, exercise 4) has to do with progressively
downloading an FLV file. According to the tutorial, when I click the video menu
button, the button's function should be initializeVideo, which in turn has the
videoActivate function inside of it. That fails to load, as do some of the
other variables (like the history text, and the aforementioned staff text and
swfs) that are supposed to load in the video's place (using videoDeactivate
function.) When I swap the initializeVideo function for the videoActivate
function (to try to debug the script,) the videoActivate works better (video
still doesn't load, but the movie clip that contains the video object +
interface, and the OUR HISTORY text reloads properly,) which makes me think
there's something wrong with my initializeVideo function, or there's something
wrong with the way Flash is rendering the test movie.

Here is the actionscript code for the 1st keyframe of the main timeline:


var scrollDirection:String;
this.videoContainer._visible = false;

//-----<load CSS>-----\\
var cssStyles:TextField.StyleSheet = new TextField.StyleSheet ();
cssStyles.load ("styles/styles.css");
cssStyles.onLoad = function (success) {
if (success) {
loadedInfo.styleSheet = cssStyles;
_level0.myLV.load("vars/ourHistory.txt");
} else {
loadedInfo.text = "There has been an error loading the requested
information. Please contact the Webmaster and report your error.";
}
}
//-----</load CSS>-----\\



//-----<scroll buttons>-----\\
this.scrollDown.onPress = function () {
scrollDirection = "down";
scrollText();
}
this.scrollDown.onRelease = function () {
delete _root.onEnterFrame;
}
this.scrollDown.onReleaseOutside = function () {
delete _root.onEnterFrame;
}
this.scrollUp.onPress = function () {
scrollDirection = "up";
scrollText();
}
this.scrollUp.onRelease = function () {
delete _root.onEnterFrame;
}
this.scrollUp.onReleaseOutside = function () {
delete _root.onEnterFrame;
}
function scrollText () {
_root.onEnterFrame = function () {
if (scrollDirection == "up") {
loadedInfo.scroll -= 1;
} else if (scrollDirection == "down") {
loadedInfo.scroll += 1;
}
}
}
//-----</scroll buttons>-----\\

// set the alignment of the sub-menu options to autoSize right
this.ourHistoryMC.ourHistory.autoSize = "right";
this.ourStaffMC.ourStaff.autoSize = "right";
this.ourVideoMC.ourVideo.autoSize = "right";

// create TextFormat Objects that define the states of the sub-menu options
var btnDisable:TextFormat = new TextFormat("Bitstream Vera Sans Bold Oblique",
12);
var btnEnable:TextFormat = new TextFormat("Bitstream Vera Sans Oblique", 11);

// disable the sub-menu option that corresponds to the currently-loaded section
this.ourHistoryMC.ourHistory.setTextFormat(btnDisable);
this.ourHistoryMC.enabled = false;

// re-enable the sub-menu options
function reEnableOptions () {
this.ourHistoryMC.enabled = true;
this.ourHistoryMC.ourHistory.setTextFormat (btnEnable);
this.ourStaffMC.enabled = true;
this.ourStaffMC.ourStaff.setTextFormat (btnEnable);
this.ourVideoMC.enabled = true;
this.ourVideoMC.ourVideo.setTextFormat (btnEnable);
}

//-----<our history option>-----\\
this.ourHistoryMC.onRollOver = function () {
this.ourHistory.setTextFormat (btnDisable);
}
this.ourHistoryMC.onRollOut = function () {
this.ourHistory.setTextFormat (btnEnable);
}
this.ourHistoryMC.onRelease = function () {
reEnableOptions();
this.ourHistory.setTextFormat (btnDisable);
this.enabled = false;
_level0.myLV.load("vars/ourHistory.txt");
videoDeactivate();
}
//-----</our history option>-----\\

//-----<our staff option>-----\\
this.ourStaffMC.onRollOver = function () {
this.ourStaff.setTextFormat (btnDisable);
}
this.ourStaffMC.onRollOut = function () {
this.ourStaff.setTextFormat (btnEnable);
}
this.ourStaffMC.onRelease = function () {
reEnableOptions();
this.ourStaff.setTextFormat (btnDisable);
this.enabled = false;
_level0.myLV.load("vars/ourStaff.txt");
videoDeactivate();
}
//-----</our staff option>-----\\

//-----<our video option>-----\\
this.ourVideoMC.onRollOver = function () {
this.ourVideo.setTextFormat (btnDisable);
}
this.ourVideoMC.onRollOut = function () {
this.ourVideo.setTextFormat (btnEnable);
}
this.ourVideoMC.onRelease = function () {
reEnableOptions();
this.ourVideo.setTextFormat (btnDisable);
this.enabled = false;
initializeVideo();
}
//-----</our video option>-----\\

//----------<video activate>----------\\

function videoActivate() {
scrollDown._visible = false;
scrollUp._visible = false;
loadedInfo.text = "";
videoContainer._visible = true;
myNetStream.play("la_eyeworks_video.flv");
}

//----------</video activate>----------\\

//----------<video deactivate>----------\\

function videoDeactivate() {
loadedInfo.scroll = 0;
scrollDown._visible = true;
scrollUp._visible = true;
videoContainer._visible = false;
}

//----------</video deactivate>----------\\

//----------<video>----------\\

var myNetConn:NetConnection;
var myNetStream:NetStream;
var videoLV:LoadVars;

function initializeVideo() {
myNetConn = new NetConnection();
myNetConn.connect(null);
myNetStream = new NetStream(myNetConn);
videoContainer.myVideo.attachVideo(myNetStream);
myNetStream.setBufferTime(5);

videoLV = newLoadVars();
videoLV.onLoad = function (success) {
if (success) {
videoActivate();
}
}
videoLV.load("vars/video_info.txt");
}

//----------</video>----------\\
Re: I'm sorta new to actionscript and have several problems.... Key Chung
10/31/2005 11:22:27 PM
Re: I'm sorta new to actionscript and have several problems.... SimpleScripter
10/31/2005 11:34:29 PM
Regarding your first problem: What is the exact string you're passing to the
text field? Does it look something like this?

This is my favorite image: <img src="swfs/staff-01.swf" width="75" height="75"
align="left" hspace="10" vspace-"5"> Sometimes the snow comes down in june.
Etc...

Have you created your text field using the gui or dynamically using
createTextField? In anycase make sure you have the text field set to render
html via the text field properties gui or as (myTF.html = true). And then when
you set the text of the field make sure you use
myTF.htmlText = myTextString

Try using basic html tags (<b></b>, <p></p>) with your text to rule out
anything quirky.

-David
Re: I'm sorta new to actionscript and have several problems.... Key Chung
10/31/2005 11:44:18 PM
Re: I'm sorta new to actionscript and have several problems.... SimpleScripter
10/31/2005 11:47:35 PM
Maybe this will help:
http://www.actionscript.org/forums/archive/index.php3/t-35073.html

Have you checked what attributes of the img tag are supported by the text field class?

Re: I'm sorta new to actionscript and have several problems.... Key Chung
11/1/2005 12:21:52 AM
I figured out my second problem. It was a stupid typo! I'm gonna look to solve
this other problem with the text now.

I tried to hand code the render as HTML behavior to my text field and it still
doesn't work. I'm gonna check into the rendering bug mentioned in the link
above, but I'm just getting more frustrated. Oh well.
AddThis Social Bookmark Button