intro
hello, as denvish requested a more indepth loading data tutorial
in this tut we will cover
load()
movieclip.loadMovie()
loadMovie()
loadMovieNum()
loadVariables()
loadVariablesNum()
unloadMovie()
unloadMovieNum()
loadClip()
unloadClip()
and i think thats most of it >:|
load()
there is lots of different load commands like these
TextFeild.StyleSheet.load()
LoadVars.load()
XML.load()
there they are the most common uses there are some others like
mx.control.loader.load()
but i have never used it - its to do with the UI Component "Loader"
but any way
TextFeild.StyleSheet.load()
used for loading in StyleSheets *duh* (.css files)
what are css files?
googles answer to that is
Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML
(i knew what a css sheet was but i wanted to make sure i was 100% right. which i was)
so what flash isnt a markup language?
yeah your right but!
flash has html text As: Html Text
and html stands for hyper text markup language
see any way on topic how to use css styling sheets
(there could be WHOLE As: Topic on this so this will be a crash course)
make a textfile and call it "styles.css"
and put this in it
html {
font-family: _sans;
}
title {
font-weight: bold;
text-decoration: underline;
text-align: center;
font-size: 10;
}
.code {
margin-left: 15;
font-family: _typewriter;
}
h1 {
font-weight: bold;
}
a {
text-decoration: underline;
color: #0000FF;
}
to add your own tags to it add add 'something' like this to the bottom of it
tagName {
stuff you want the tag to do like
text-decoration: underline;
color: #0000FF;
font-weight: bold;
text-align: center;
font-size: 10;
}
there would be more but meh
now make a html file called "css.html"
this is tthe data we will be loading in
now put this in the css.html file
<html>
<head>
<title>TITLE</title>
</head>
<body>
<h1>Using CSS with HTML Text</h1>
<p>
blah blah
more text!?!
ok im over it
</p>
<p></p>
<p class="code">
var cssStyles:TextField.StyleSheet = new TextField.StyleSheet();
</p>
<p></p>
<p>
blah vlah blah this is some text <a href="http://www.google.com">
a web site that looks like a link in flash plain html you can only semi do this</a>.
<p>
<body>
</html>
now put both those files in the same directory as you swf
and in that swf have a code like this
var cssStyles:TextField.StyleSheet = new TextField.StyleSheet();
cssStyles.parseCSS("html{font-family: _typewriter;}");
cssStyles.setStyle("title", {fontWeight:"bold", textDecoration:"underline", textAlign:"center", fontSize:10});
cssStyles.setStyle(".code", {marginLeft:15, fontFamily:"_typewriter"});
cssStyles.setStyle("h1", {fontWeight:"bold"});
cssStyles.setStyle("a", {textDecoration:"underline", color:"#0000FF"});
this.createTextField("tOutput", this.getNextHighestDepth(), 0, 0, 550, 400);
tOutput.border = true;
tOutput.html = true;
tOutput.multiline = true;
tOutput.wordWrap = true;
tOutput.condenseWhite = true;
tOutput.styleSheet = cssStyles;
var lvHTML:LoadVars = new LoadVars();
lvHTML.onData = function(sData:String):Void {
tOutput.htmlText = sData;
};
lvHTML.load("css.html");
now have a look at it =D
simple =P
ok now lets have a look at
LoadVars.load()
its coverd here As: Load External Data/Cross Domain
eerh.. i was going to add somthing about that but then i though 'its pretty well explained in that tut so yeah'
to
XML.load()
usage to load XML data
XML = Extendable Markup laguage
here is a good XML tutorial Kipura: Intro to XMl
XML is it own language so there could be 10 - 20 topics about it but XML.load is simple enough
put that in a swf
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
trace(my_xml);
};
my_xml.load("my_xml.xml");
now make a .xml file called my_xml in the same directory as the swf and add this to it
<bleh>
blah blah blah
</bleh>
<turnip>
<icecream />poopascoopa
</turnip>
when loading xml you can check to see how much has loaded (like a pre loader kinda)
example
function checkXMLProgress(xmlObj:XML) {
var nLoaded:Number = xmlObj.getBytesLoaded();
var nTotal:Number = xmlObj.getBytesTotal();
var nPercent:Number = 0;
if (nTotal>0) {
nPercent = nLoaded/nTotal*100;
}
progress.text = nPercent+" % ";
if (nPercent == 100) {
clearInterval(nInt);
}
}
var nInt:Number = setInterval(checkXMLProgress, 100, xmlVal);
simple =D (its all simple)
now to
movieclip.loadMovie()
description
Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8. If you load an animated GIF, only the first frame is displayed.
example
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc.loadMovie("otherMovie.swf");
loads otherMovie.swf into mc =D simple you can use the same method as the XML.load to measure how much is loaded into the flash player.
dont post anything this is going over two pages =D