00:00
00:00

As: Load Data (large!)

4,415 Views | 13 Replies
New Topic Respond to this Topic

As: Load Data (large!) 2005-12-13 05:10:34


As: Main

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

Response to As: Load Data (large!) 2005-12-13 05:11:53


loadMovie()

pretty much the sameas mc.loadMovie()
but it loads the content into _level0 instead of a movieclip


loadMovieNum()

similar to loadMovie() but you can load the swf, jpg,png or gif onto any level,
Macromedias description of _levelN is

Flash Player has a stacking order of levels starting with level 0. These levels are like layers of acetate; they are transparent except for the objects on each level.

which i think is very good

any ways when you use loadMovieNum(), you must specify a level into which the SWF file will load.
When a SWF file is loaded into a level, you can use the syntax, _levelN, where N is the level number, to target the SWF file.

if you load a swf into a level which is already occupied by another swf (loading in two swfs) the first swf will be replaced.
also if you load a swf into level0 everything will be replaced with that swf
note: you can load in gifs pngs and jpgs as well as swfs


loadVariables()

ok loadVariables is much the same as the LoadVars() class

example

make a .txt file called vars
with this content in it
var1="cheese"&var2="pie"&var3="cheesePie"
put it in the same directory as the swf and add this to the swf

_root.createEmptyMovieClip("mc", this.getNextHighestDepth());
loadVariables("params.txt", mc);
function pramsLoad() {
if (_root.mc.var1 == undefined) {
trace('loading');
} else {
trace(_root.mc.var1+" "+_root.mc.var2+" "+_root.mc.var3);
clearInterval(interval);
}
}
var interval:Number = setInterval(pramsLoad, 100);

loadVariablesNum()

same as loadVariables() but save to level instead of mc
no example for this because im running out of time =(
but im sure you could work it out

to
unloadMovie()
well it simply unloads a externaly loaded movieclip

example

unloadMovie(mc)

now
unloadMovieNum()
same as unloadMovie()
except it unloads a level instad of a movieclip

example

unloadMovieNum(1);

unloads the movie on level1

loadClip()

load clip is probebly the best in my view
because it has these attibutes


The MovieClipLoader.onLoadStart handler is invoked when loading begins.
The MovieClipLoader.onLoadError handler is invoked if the clip cannot be loaded.
The MovieClipLoader.onLoadProgress handler is invoked as the loading process progresses.
The MovieClipLoader.onLoadComplete handler is invoked when a file completes downloading.

example

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("YourImage.jpg", container);

function onLoadInit(mc:MovieClip) {
trace("onLoadInit: " + mc);
}

that last clip was directly ripped from the macromedia flash help file =p
....its late and i want to go to bed =(...

any way thats mostly it im sure there is somthing i have missed....
but meh its late =(

arround 9000 characters i think

Response to As: Load Data (large!) 2005-12-13 05:23:33


wholly shit, great tutorial shaz


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Response to As: Load Data (large!) 2005-12-13 05:30:11


At 12/13/05 05:23 AM, Flash_kid wrote: wholly shit, great tutorial shaz

thanks =D

i am currently forcing my self to stay up so i can answer any questions that people
have.. :(

Response to As: Load Data (large!) 2005-12-13 05:38:21


i dont think there will be any/many
coz u explained everything in that.


========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

Response to As: Load Data (large!) 2005-12-13 06:15:25


Now this really helped me. Great job :)

Response to As: Load Data (large!) 2005-12-13 09:39:27


Nice tutorial =D


BBS Signature

Response to As: Load Data (large!) 2005-12-13 16:49:27


At 12/13/05 05:38 AM, Flash_kid wrote: i dont think there will be any/many
coz u explained everything in that.

realy awsome =D

Claxor
Nice tutorial =D

thanks =D

-SaintNick-
Posted: 12/13/05 06:15 AM
Now this really helped me. Great job :)

thanks =D

Response to As: Load Data (large!) 2005-12-13 18:51:29


come on people i would like some more comments other than this was cool

Response to As: Load Data (large!) 2008-01-06 15:22:56


thanx

Response to As: Load Data (large!) 2008-01-22 19:17:44


This text is italic.


I used to be relevant.

Response to As: Load Data (large!) 2008-01-22 20:22:59


At 1/6/08 03:22 PM, Powergames wrote: thanx

HEY LETS BUMP A THREAD FROM 2005. High five you fucking idiot.


wtfbbqhax

Response to As: Load Data (large!) 2008-02-10 08:00:32


At 1/22/08 08:22 PM, fwe wrote:
At 1/6/08 03:22 PM, Powergames wrote: thanx
HEY LETS BUMP A THREAD FROM 2005. High five you fucking idiot.

Woah, calm down there :)


BBS Signature

Response to As: Load Data (large!) 2008-02-22 21:07:47


Why is it italic? I don't get it


BBS Signature