Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




GetBytesLoaded() And GetBytesTotal() Return Nothing When Loading Content From Another Domain



I have created a movie that loads various media using loadMovie() and then in many cases performs actions on the newly loaded MCs once the loading is complete. I'm relying on getBytesLoaded and getBytesTotal to know when to run these actions.This works just fine when the content is on the same server as the movie, but I also need to load content from another domain and this is where it falls apart. The media is actually loading just fine into the target MCs, but the functions that should be running when loading is complete never do. The problem is that getBytesLoaded() and getBytesTotal() both return nothing when the content is loaded from another domain.I'm stuck with loadMovie and the getBytesLoaded/getBytesTotal check as this movie must be published for Flash Player 6, but I have actually tried using loadClip() and onLoadInit() and I get the same problem - onLoadInit() never runs.Another weird thing is that testing by previewing in flash doesn't show this problem - the content loads fine and getBytesLoaded and getBytesTotal both return values as expected. It's only when I publish the movie and view in a browser that I have this problem.Where am I going wrong?Thanks!



Adobe > ActionScript 1 and 2
Posted on: 03/08/2007 05:06:55 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

GetBytesTotal() And GetBytesLoaded() Not Working When Loading Jpg File Into MC...hlp
Using MX, anyone see a problem with getBytesLoaded() and getBytesTotla() not being returned correctly using this code? Does not work for me. movBirdContainer is just an empty mc with 1 empty frame.


Code:
movBirdContainer.createEmptyMovieClip("movBird", 1);
movBirdContainer.movBird.loadMovie("./image.jpg");

onEnterFrame = function()
{
// Preloader code
var nLoaded = Math.round(movBirdContainer.movBird.getBytesLoaded() / 1024);
var nTotal = Math.round(movBirdContainer.movBird.getBytesTotal() / 1024);
trace("total bytes loaded is: " + nLoaded);
trace("total bytes is: " + nTotal);
trace("percent loaded is: " + Math.round((nLoaded / nTotal) * 100));
}

Help - GetBytesTotal() And GetBytesLoaded()
hi,

i wonder if anybody can help me,
i have a movie clip called "imgholder" which is on the stage of a movie called main.swf.

I am using "imgholder" to load external .swf files.
This is fine, however when i try to use flash5's new object style code,
e.g. imgholder.loadmovie("test.swf")
Or
loaded = imgholder.getBytesLoaded();
it doesn't work.

At the moment i am using:
loadMovie ("test.swf", "imgholder");
and
test = getProperty("imgholder", _framesloaded);
to achieve the above.

I have also tried using _root.imgholder.getBytesLoaded();
to no avail. should i be using levels?

Thanks in advance,Ben.

Xml Obj With GetBytesLoaded And GetBytesTotal
is it possible to use getBytesLoaded and getBytesTotal methods on an xml object?

Mac GetBytesLoaded() And GetBytesTotal()
in my flash app i have the block:


Code:
if(_root.main_mc.loader_mc.getBytesLoaded() == _root.main_mc.loader_mc.getBytesTotal())
{
...
}
works fine on a pc. i don't think mac supports getBytesLoaded() and getBytesTotal(); i've had some buggy problems in the past with it on a mac. is this true? any way around it?

thanks

Getbytesloaded/getbytestotal ?
I have a few problems with getbytesloaded/getbytestotal.

offline, when I try to trace their value from an object (on stage) in witch I loaded a JPG they both give me the same value. (usually 18 and then around 44 thousands...)

then online I can't trace their value but flash seems to react as if they are both equal. which makes it impossible to make a loader, because
getbytesloaded/getbytestotal always returns 1.

anyway here's how I'm trying to do this.
on 1st frame I got:

content.loadMovie("files/" + _root.selected +".jpg");


then on the 3rd frame:

bl = content.getBytesLoaded();
bt = content.getBytesTotal();

if (bt != bl) {
bar._xscale = bt/bl;
gotoAndPlay(2);
} else {
content._visible = true;
play()
}



thanks..

How To Use GetBytesLoaded And GetBytesTotal
Hey, can anyone help me get this section of code to work? What I am trying to do should be pretty self explanitory . . .


Code:
function swf(clip){
loadMovie("box.swf",clip)
bytesLoad = getBytesLoaded();
totalBytes = getBytesTotal();
if (bytesLoad = totalBytes) {
fadout = setInterval(fade,30,this);
}
trace("function swf is working");
}

GetBytesLoaded() == .getBytesTotal
Hi Forum,

I want to have two preload scenes, pre_load1 scene checks
if (_root.getBytesLoaded() == _root.getBytesTotal())

{
_root.gotoAndPlay("Main", 1);// skip pre_load2 scene and play Main scene
}


If not go to pre_load2 scene and download.

Reason is for repeat visitors so they dont have to view preload again. cheers P

GetBytesLoaded() / GetBytesTotal()
Hello there... I have a small problem with getBytesLoaded() / getBytesTotal() for use with a preloader. I know how to make a preloaded, but ive decided to make a preloader on a specific level that will be loaded into the embedded swf.

so the preloader is accessed by _level200

this works fine. I can use getBytesLoaded() / getBytesTotal() to find out how much is loaded.

example:

Code:
myLoader.myKBs.text = _level0.getBytesLoaded() add "kb/" add _level0.getBytesTotal() add "kb";

//OR use it to get to level the loader is inside

myLoader.myKBs.text = this.getBytesLoaded() add "kb/" add this.getBytesTotal() add "kb";
but the second i try any level BUT "_level0" or "this" then I just get undefined!!! Any ideas? Btw, I KNOW the other levels are there because they are showing up in the embedded file.

thanks guys/gals

GetBytesTotal & GetBytesLoaded?
Hi

I want to load a picture from outside my site and get the size info of that file.
But when I use getBytesTotal & getBytesLoaded it's only return 0 byte.


Code:
...
newImg_mc.loadMovie("http://www.helpexamples.com/flash/images/image1.jpg");
...
trace(newImg_mc.getBytesTotal());
trace(newImg_mc.getBytesLoaded());
...
I want to know the filesize of a file outside my site.
And to be able to see the downloaded bytes.

please someone!
/Stenberg

GetBytesLoaded() & GetBytesTotal()
Say I have 2 files (file a, file b) and I want to use file a to load file b (in a blank movie clip symbol). The problem is that file b has a preloader that uses _root.getBytesLoaded() & _root.getBytesTotal() in it.

These values, however, return the size of 'file a', what should I put in place of _.root (which is in 'file b') so that it returns the size of 'file b' even if I load it from somewhere else?

Thanks

GetBytesloaded && GetBytesTotal Undefined
I'm loading an external swf on a button release. Since the external swf was small I initially didn't have a preload check. The first time the button is clicked the swf doesn't load, but the on the second click the swf would load and play.

I tried using basic tests with _framesloaded and even tried a comparison with (getBytesloaded & getBytesTotal). If all cases , _framesloaded and getBytesloaded & getBytesTotal return "undefined" and the swf loaded only have the second click.

Any ideas.

Lisa

GetBytesLoaded()/getBytesTotal() = Headache
Got a flash piece at http://www.lake.k12.fl.us/makearipple.asp that pops it in a new window.

Problem is, preloader shows up on some machines, not others.

Real frustrating. Because it will show up, say, on a p4 2+ GHZ machine as well as a 128 MB Ram AMD older machine, but won't show up on similar machines running same software, browser and players.

I'd rather use getBytesLoaded vs ifFrameLoaded -- site is a bunch'a mcs that play when buttons are activated, etc. getBytesLoaded is more accurate than ifFrameLoaded in this case.

Also, want preloader to load dynamically, which, as I said above, it does in most cases. It's the times that it chugs along before jumping strait in to the main movie that's got me all frustrated.

Any suggestions are appreciated.

I've tried multiple variations.

Here's preloader code:


----------------------------------

stop();
myInterval = setInterval(preloader, 10);
if (getBytesLoaded() == getBytesTotal()) {
nextScene();
}
function preloader() {
if (getBytesLoaded()>=getBytesTotal()) {
play();
clearInterval(myInterval);
}
myTextField.text=(Math.round(getBytesLoaded()/getBytesTotal())*100)+"% loaded";
progressBar._xscale=(getBytesLoaded()/getBytesTotal())*100;
mask._xscale=(getBytesLoaded()/getBytesTotal())*100;
mask._yscale=(getBytesLoaded()/getBytesTotal())*100;
ripple._xscale=(getBytesLoaded()/getBytesTotal())*250;
ripple._yscale=(getBytesLoaded()/getBytesTotal())*250;
ripple._alpha=(getBytesLoaded()/getBytesTotal())*50;
ripText._alpha=(getBytesLoaded()/getBytesTotal())*100;
}


----------------------------------

Thanks,

Andy

GetBytesLoaded & GetBytesTotal Messed?
OMG.... nevermind, I missed one little capitalization in the script...

_level1 GetBytesLoaded/getBytesTotal.. Help
Does anybody know how can I make my preloader.. if I want to load music from _leverl1 ?

setProperty("_parent.load_bar", _xscale, ((_level1.getBytesLoaded()/_level1.getBytesTotal())*100));
//this script doesn't work for me

Thanks..

GetBytesLoaded Returns GetBytesTotal...
Okay what I am trying to do should be pretty simple... I've done it quite a few times before but I'm getting nowhere this time. Here's my setup.

I have a main swf that simply is used to load other swfs as links are clicked. Now two different swfs are always loaded at the same time. One is a banner that contains the menu which is never unloaded. And the other is the content swf that is changed as the links are clicked.

Here's the setup: It's not as optimized as it could be because I've been messing it up continuously trying to find the problem.


Code:
//SNIPPET: this is in the banner.
if (loading) {
loading = _root.checkLoading();
if (!loading) {
turnOn();
}
}

//SNIPPET:this is in the main swf
function checkLoading() {
var rbool:Boolean = true;
var loaded:Number = content.getBytesLoaded();
var total:Number = content.getBytesTotal();
lbar.lbar._xscale = loaded/total*100;
lbar.perc = loaded;
if (total == loaded && total > 1) {
rbool = false;

}
return rbool;
}

//SNIPPET: Last here's the setup for content which is also in the banner
if (_root.chg == "2d") {
loadMovie("2dViewer.swf", _root.content);
} else if (_root.chg == "3d") {
loadMovie("3dViewer.swf", _root.content);
} else if (_root.chg == "web") {
loadMovie("webViewer.swf", _root.content);
} else if (_root.chg == "contact") {
loadMovie("contact.swf", _root.content);
} else if (_root.chg == "about") {
loadMovie("about.swf", _root.content);
} else if (_root.chg == "home") {
loadMovie("main.swf", _root.content);
}
Okay now here's my problem. content.getBytesLoaded() returns the same as content.getBytesTotal(). And no it's not 0... it's a large amount of bytes that I am assuming is the actual Total. And it's not loaded yet either, one of the swfs is about 2.5 megs and says it is loaded but it's not even close...

Am I doing something stupid? Probably... if you can help me that would be awesome! In the mean time... I'll scratch my brain some more...

_level1 GetBytesLoaded/getBytesTotal.. Help
Does anybody know how can I make my preloader.. if I want to load music from _leverl1 ?

setProperty("_parent.load_bar", _xscale, ((_level1.getBytesLoaded()/_level1.getBytesTotal())*100));
//this script doesn't work for me

Thanks..

GetBytesLoaded And GetBytesTotal Isnt Getting
Hi! Im going crazy! It seems no matter how I try to get the bytes loaded and total, its not getting them. Im loading a picture into a holder.  The swf loads into the holder fine, but the preloader isnt working because the bytes loaded and total are always 0.  Here's the code Im referring to...

function load_pic(myLoad, myNum:Number)
{
    //this loads the picture into backpics
    _root.mc_backpics["img" + myNum].loadMovie(myLoad);
    
    //this is what I cant get working.  myLoad isnt referencing the file I think
    
     total = myLoad.getBytesTotal();
     loaded = myLoad.getBytesLoaded();
     percent = int(loaded/total*100);
     

and here's how I call it...
var myPage = 1;
load_pic("backpics/pic" + [myPage] + ".swf", myPage);

Thanks!
Rich


MovieClip.getBytesLoaded() And GetBytesTotal() == 0?
For some reason when I load a movie clip these functions always seem to return 0 to me. Does this mean that it loads the movie with the LoadMovie method from the cache memory which makes that value 0? Even then I'd think it would still display that number.

I load it like this in a frame:

LSL=loadingScreen.getBytesLoaded();

LSL shows 0 as a value when I do Debug - List Variables when testing it. It's the same for LST=loadingScreen.getBytesTotal();


Btw I load the MovieClip like this and in the next frame I update those LSL and LST variables:

_root.createEmptyMovieClip("loadingScreen",2);
_root.loadingScreen.loadMovie("LoadingScreen1.swf");


Of course those both values being 0 will always end up in this if statement to fail:

if(LSL<LST){
gotoAndPlay(1);
}

Suggestions to let these methods return the correct values are appreciated a lot.

Flash MX LoadVariables GetBytesLoaded GetBytesTotal
i know how to use getBytesLoaded getBytesTotal on an external loading .swf or .jpg but is posible to use it on a .txt that you loading in useing loadVariables ?

GetBytesLoaded Showing As GetBytesTotal About 50% Of The Time. Help.
I am loading a sound file and have a loop that continually checks getBytesLoaded and compares it to getBytesTotal.

unfortunately the getBytesLoaded is returning getBytesTotal about 50% of the time and then it doesn't download the file at all.

I have stripped it down to the bare bones just checking getBytes Loaded and can't figure out why this is happening.

I am loading the sound off of a button click and if I click the button 5 or 6 times it usually kicks in and starts showing getBytesLoaded but that is not really acceptable. The funny thing is sometimes it goes on the first click. Can anyone give me any hints.

My guess is it has something to do with the large file size and my slow internet connection but then many other people will have a similarly slow conntection.

Problem With GetBytesLoaded And GetBytesTotal With A SendAndLoad
I can't get it work. It's loading fine, but I can't find a way of retrieving the informations. I would like to do a preloader, so I need the getBytesLoaded and getBytesTotal

here is the code I have done :

Code:
stop();
var sendData:XML = new XML();
var replyXML:XML = new XML();

checkProgress = function() {
var lvBytesLoaded:Number = replyXML.getBytesLoaded();
var lvBytesTotal:Number = replyXML.getBytesTotal();
trace("Loaded "+Math.floor(lvBytesLoaded/lvBytesTotal)*100);
};
replyXML.onLoad = function(success:Boolean) {
clearInterval(intervalID);
if (success) {
trace(replyXML.getBytesLoaded()+" Bytes sent.");
} else {
trace("error");
}
};
sendData.sendAndLoad("http://127.0.0.1/RandomThoughtsHandler.ashx", replyXML);
var intervalID:Number = setInterval(checkProgress, 100, replyXML);

XML Object: GetBytesLoaded() And GetBytesTotal Returns Same
i am trying to build a preloader for loading XML documents, but getBytesLoaded() and getBytesTotal returns the same number as the document is loading.

has anyone heard of a problem with this?

Sound.duration Continues To Increase After GetBytesLoaded()==getBytesTotal()?
Try this:

ActionScript Code:
var s = new Sound();
s.loadSound('sound.mp3',true);
onEnterFrame = function(){
    var a = s.duration+" : "+s.getBytesLoaded()+" / "+s.getBytesTotal();
}

Have sound.mp3 or whatever in the same dir as the fla. Test movie, and simulate download. Notice that the Sound.duration continues to steadily increase even after getBytesLoaded()==getBytesTotal()! Example:
45166 : 201558 / 201584
45322 : 201584 / 201584 // done loading bytes
45558 : 201584 / 201584 // duration increasing??
45793 : 201584 / 201584 // still increasing?! and continues for a long time

I was trying to extrapolate the duration of the mp3, since Sound.duration only returns milliseconds of audio downloaded when loadSound stream is set to true(like above). I got so close, but fear I'm stuck. The discrepancy created by this is as long as 10 seconds, which is not acceptable. I am probably going to have to settle for a nasty alternative, like creating id3 tags(ug) or manually enter all the timestamps into XML. If any gurus have any last ideas, I'm all ears.

GetBytesTotal Doesnt Return Any Value?
Hi

I am loading an image into a holder clip (holder2) off stage and then loading it into a display clip (holder) when fully loaded

here is the code

Code:
function imageLoader(image2load) {
//load image into holder clip
holder2.loadMovie(image2load);
//show loader mc
_root.loader.gotoAndStop("on");
_root.loader.indicator.onEnterFrame = function() {
bytesLoaded = holder2.getBytesLoaded()/1024;
//this is not returning any value
bytesTot = holder2.getBytesTotal()/1024;
//if I specify the bytesTotal it works
//bytesTot = 340;
if (bytesTot>5) {
percent = int((bytesLoaded/bytesTot)*100);
_root.loader.indicator.percent.text = percent+"%";
}
if (bytesLoaded>=bytesTot && bytesTot>1) {
//place image into display clip
holder.loadMovie(image2load);
//hide loader
_root.loader.play()
delete this.onEnterFrame;
}
};
}
imageLoader("images/home.jpg")

The getBytesTotal request does not return any value, the code works cos if I hard code the value the loading works???

Any ideas? is there a setting on the server that needs to be set to allow this to work??

GetBytesTotal() Vs. Content-Length Header
I have run into a problem with getBytesTotal() function of LoadVars object (probably the same function in XML object will exhibits the same behaviour).
I have a php-generated page (variables) that I load into flash. All works OK except for getBytesTotal(). I believe it is because originally I did not pass Content-Length header with the page, so getBytesTotal returned undefined. Until here it has been all as I have expected and by the book (manual .-).
So I added the header, I buffer output and use ob_get_length() function in PHP (there are also other ways how to get the length of dynamically generated page). It seems it returns correct header, but then all loading to flash fails - LoadVars load() returns false. I have failed in finding any clue why so. When I just get rid off Content-Length header it works again all ok, but naturaly the problem with getBytesTotal() is back.

Does anyone experienced something simillar either with LoadVars or XML?

Thanks in advance...

GetBytesTotal On Loading Jpg ?
Hi people!!!

i am working on a photo gallery where a movieclips replace themselves with a jpg found on a server. an mc named 'pic001' uses contains a movie clip named 'picture'. i use a loadMovie command to replace 'picture' with a file named 'pic001.jpg'. this works fine.

trick is, some of the photos are large and i would like to have a simple loader sho up until the jpg is entirely loaded. i first managed this by creating a library of swf files (each with their own loader) that work fine, but i wanted to take advantage of the killer new feature, so i don't have to go through the extra step of compiling a .swf file for each image...

when i use the command 'picture.getBytesLoaded()' it only returns the ORIGINAL value for the picture MC (which contains nothing other than a rectangle use to determine placement). is there a way to determine the size of the actual .jpg as it is being loaded?

thanks in advance for any help you may be able to provide...

theoceanfrog

Loading External SWF - Incorrect GetBytesTotal?
Loading external SWF - incorrect getBytesTotal??
Hi, I've posted this question a couple times now, but no one has responded to my posts. I'm really desperate for help, so if any one had ideas please let me know!

I am loading external SWF into empty movie clips. I want to create a preloader that stops the movie until the SWF have loaded for all buttons

I want to do like this site http://minhlong.com

Thanks for your help!!

GetBytesTotal() From An Externally Loading Picture
Hello,

I'm using this code to load a .jpg into a movieclip with the instance name picholder

Code:
_root.picholder.loadMovie("pic.jpg");
How do I get getBytesTotal() or getBytesLoaded() to work with this picture? I've tried to get the total and loaded this way:

Code:
_root.picholder.getBytesLoaded()
But it doesn't seem to work

GetBytesTotal For File Without Loading-4 Podcast
Hello kirupa...

So i am building a dynamic podcast creator with flash (and mySQL, amfPHP) for a client who is not a tech person at all.

The podcast will update itself through the CMS we are building for him.

For an iTunes podcast however, i need to include the length of each podcast item in bytes.

Is there a way i can get the file size of the mp3 without fully loading it into a Sound object?

Anybody know? I dont think My client will be able to get and fill in the length in bytes for each entry, so i need a way to do this behind the scenes.

I would like to think that there is a way to do this other than storing the "bytes total" in the database when the client uploads the mp3 through the flash CMS.


ANy help would be hugely appreciated.

Loading External SWF - Incorrect GetBytesTotal?
Loading external SWF - incorrect getBytesTotal??
Hi, I've posted this question a couple times now, but no one has responded to my posts. I'm really desperate for help, so if any one had ideas please let me know!

I am loading external SWF into empty movie clips. I want to create a preloader that stops the movie until the SWF have loaded for all buttons

I want to do like this site http://minhlong.com

Thanks for your help!!

Loading An External .swf And Using GetBytesLoaded
I'm loading an external clip into a blank mc like:

Code:
loadMovie("pic1.swf", pic1holder);
now i want to use getBytesLoaded on this external clip.

Code:
bytesLoaded = pic1holder.getBytesLoaded();
but this doesn't seem to work... any ideas?

GetBytesLoaded When Loading An Image?
Hey,
i am trying to get number of bytes loaded when loading an image. Is there way to retrieve information like that?
Here is what i am trying to do:

myMc.loadMovie("picture.jpg");
// i need to see how much of an image is loaded

Please let me know if you have any ideas. Thanks

GetBytesLoaded When Loading Swf From Another Server
Hi!
I have a pretty annoying problem. I have a main-flash on one
server and I'm loading another swf into that file from another server.
It has to be done this way for bandwidth purposes.

This works just fine. I have a "System.security.allowDomain("*");" in
the file and a "crossdomain.xml" on the server as well just to be safe.

The problem is that "getBytesLoaded()" & "getBytesTotal()" returns
undefined until it's 100% loaded. The file is pretty large and I really
would like to have a neat percent-loader.

Does anyone have a solution or a workaround to this problem?
Thanks.

Loading External Jpges - Incorrect GetBytesTotal?
Hi, I've posted this question a couple times now, but no one has responded to my posts. I'm really desperate for help, so if any one had ideas please let me know!

I am loading external jpegs into empty movie clips. I want to create a preloader that stops the movie until the jpegs have loaded.

I am using the code below, however the movie just seems to play anyway, even though the images have not actually loaded. It seems as if its not calculating the correct bytesTotal.

Is there something I am missing?

(I am using Flash MX 2004, but I want to export for Flash 6 Player).

Thanks for your help!!


Code:
stop();
loadMovie("photos/galleries/gal1_01a.jpg", "a");
loadMovie("photos/galleries/gal1_01b.jpg", "b");
loadMovie("photos/galleries/gal1_01c.jpg", "c");

myInterval = setInterval(preloader, 100);

bytesA = a.getBytesTotal();
bytesB = b.getBytesTotal();
bytesC = c.getBytesTotal();
totalBytes = (bytesA + bytesB + bytesC);

loadedA = a.getBytesLoaded();
loadedB = b.getBytesLoaded();
loadedC = c.getBytesLoaded();
loadedBytes = (loadedA + loadedB + loadedC);

function preloader() {
if (loadedBytes>=totalBytes && totalBytes>0) {
play();
clearInterval(myInterval);
} else {
stop();
}
}

GetBytesLoaded When Loading Image ONLINE
Is it true that a

myMovieClip.loadMovie("myImage.jpg")

...wont return

myMovieClip.getBytesLoaded() (!NAN)

...until

myMovieClip.getBytesLoaded() == myMovieClip.getBytesTotal()

?

I dont get ANY DATA from

myMovieClip.getBytesLoaded()

...until the image is loaded completely.


I used a script @

http://www.flashguru.co.uk/000044.php

..but i wont help either !

This always works OFFLINE but NEVER ONLINE !


Thanks so much for any hints on this topic !!!

cEdRik!

Loading External Swfs And Getting Getbytesloaded()
Since components load in the first frame,

I want to create an swf (ie construct)

In the first frame of construct i want to load pgloader.swf in an mc called 'load' (my loading program)

and on load, i want it to load program.swf into another mc called 'program'

now, i want my loading program in 'load' to be able to get information like.. getBytesLoaded and getBytesTotal from _level0.program ?? How do you do this, im used to loading load programs into the swf i want to load and thenjsut doing _root.getBytesTotal...


Im just not sure how todo this, i know that using _level0.program.getBytesTotal doesn't work, (i tried it)

[F8] Loading SWF - Getbytesloaded, Drivin' Me Nuts...
Please let me beg forgiveness if this is answered somewhere, but i've been looking at numerous threads and testing multiple examples from flashkit and can't seem to figure this one out.

Basically I'm loading a SWF file but it won't report the bytes loaded or increase the percentage bar until the file is fully loaded. The Plan.SWF that is loading (see attachments) is a file taken from AutoCAD, imported to Illustrator and saved from CS3 to a SWF file. I've tried putting that swf file into Flash but get a "not enough stack space" error so i'm resigned to using the SWF as it comes from Illustrator.

Here's a copy of the code in the first frame of LoadPlan.fla that was basically copied from another Flashkit example (or maybe it was Flash Help). Sorry, i've tried too many things to remember...

var barWidth:Number = 200;
var barHeight:Number = 6;

this.createEmptyMovieClip("pBar_mc",9999);
var bar:MovieClip = pBar_mc.createEmptyMovieClip("bar_mc", 10);
bar.beginFill(0xFF0000,100);
bar.moveTo(0,0);
bar.lineTo(barWidth,0);
bar.lineTo(barWidth,barHeight);
bar.lineTo(0,barHeight);
bar.lineTo(0,0);
bar.endFill();
bar._xscale = 0;

var stroke:MovieClip = pBar_mc.createEmptyMovieClip("stroke_mc", 20);
stroke.lineStyle(0,0x000000);
stroke.moveTo(0,0);
stroke.lineTo(barWidth,0);
stroke.lineTo(barWidth,barHeight);
stroke.lineTo(0,barHeight);
stroke.lineTo(0,0);

pBar_mc.createTextField("label_txt",30,0,barHeight ,100,21);
pBar_mc.label_txt.autoSize = "left";
pBar_mc.label_txt.selectable = false;

pBar_mc._x = (Stage.width-pBar_mc._width)/2;
pBar_mc._y = (Stage.height-pBar_mc._height)/2;
this.createEmptyMovieClip("my_plan",100);
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);

image_mcl.loadClip("Plan.swf",my_plan);
pBar_mc.onEnterFrame = function() {
var pctLoaded:Number = Math.floor(my_plan.getBytesLoaded()/my_plan.getBytesTotal()*100);
if (!isNaN(pctLoaded)) {
pBar_mc.bar_mc._xscale = pctLoaded;
pBar_mc.label_txt.text = pctLoaded+"% loaded";
trace (pBar_mc.label_txt.text);
if (pctLoaded>=100) {
pBar_mc.onEnterFrame = undefined;
}
}
};

Thanks for any help!!!

GetBytesLoaded Loading Image Into Dynamic MovieClip
Hi,

I'm creating a movieClip dynamically and loading an image into it. This works fine, although I'd like to monitor the loading of the image but whenever I try "getBytesLoaded" or "getBytesTotal" it returns the value "0". This is an excerpt of my code:


code:
this.main_mc.createEmptyMovieClip("imgClip",5);
this.main_mc["imgClip"].loadMovie("pic.jpg");
this.main_mc["imgClip"].onEnterFrame = function() {
trace(this.getBytesLoaded());
}


If anyone has any ideas about this, I would really appreciate any help.

Thanks!

GetBytesLoaded Problem When Loading Sound Object
Hello everyone,

When I load an external .mp3 into Flash, I try to get a value for getBytesLoaded() within an onEnterFrame event handler so I can use that to figure out the progress of the .mp3 as it downloads. However, I only get a value that is the total file size (even though I call that separately with getBytesTotal()). Is there a bug with the Sound object when attempting to get these parameters?

Here is my code (which is on the 4th frame as the playhead goes here after preloading the entire main clip):


Code:
stop();

music_file = "audio_test.mp3";

onEnterFrame = function(){
loadedBytes = site_audio.getBytesLoaded();
totalBytes = site_audio.getBytesTotal();
percentDone.text = int((loadedBytes/totalBytes) * 100);

site_audio.onLoad = function(success:Boolean){
if(success){
trace("success!");
delete onEnterFrame;
gotoAndStop(5);
} else {
trace("Audio did not successfully download!");
}
}
}

site_audio = new Sound(this);
site_audio.loadSound(music_file,false);
Any feedback or direction is appreciated. Forgot to add that I have my publish settings at FP 7 and AS 2.0 with all classes exporting to the third frame for the main movie preloader. Not sure if that info matters but I didn't want to leave it out.

Thanks in advance for any feedback!

GetBytesLoaded() Or Math.round(getBytesLoaded())
hi have a problem with my preloader it is in scene1 and when it loads it goes to scene2 it works fine on my computer but when i upload it to the web it doesn't work right the preloader bar shows up allready loaded can any body help me, here is the script i'am using:


ActionScript Code:
total_bytes=_root.getBytesTotal();
loaded_bytes=_root.getBytesLoaded();
remaining_bytes= total_bytes - loaded_bytes;
percent_done=int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded("main",11){
    gotoAndPlay("main",1);
}

External Content Loader With Multiple Content Types (trouble Loading Graphics)
Hey all!

I am yet another new project. Our flash designer here isn't a big AS guy, and asked me to write a reusable class so that he can load a variety of content types using minimal amount of code on his part. It's also going to be the main component piece in a larger external content player once I'm done with the class itself, so I am making the loading functions into public methods of the loader object than can be called from a button, etc.

I have the code for the text and html parts working (although I can't get stage.width and stage.height to work in the class or from the frame).

The problem I have is that I can't get the graphics content to load (the swf/pic content). Could you please check my code and tell me what I'm missing? I'm sure it's something simple, like it always is.

thanks a million!

-Fish


-----------------------------


ActionScript Code:
package
{
   
    /**
    * External Multimedia Loader Class
    * @author $(DefaultUser)
    * Add new MultiLoader object and insert media type (all lowercase) and object path to control initial loaded object
    * To load a new object, call the MultiLoader.load* methods (loadText, loadPic, loadSwf, or loadHtml as appropriate), passing the path to the external file.
    */
   
    import flash.display.*;
    import flash.events.*;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
   
    public class MultiLoader extends MovieClip
    {
        private var media:String;
        private var path:String;
        public var textObj:TextField = new TextField;
        public var picObj:MovieClip = new MovieClip;
        public var swfObj:MovieClip = new MovieClip;
        public var htmlObj:TextField = new TextField;
        private var objLoader:Loader = new Loader();
        private var objType:String;
        private var textLoader:URLLoader = new URLLoader();
       
       
       
        public function MultiLoader(mediaType:String,objPath:String)
        {
            media = mediaType;
            path = objPath;
           
            if (media == "text" || media == "TEXT" || media == "Text")
            {
                loadText(objPath);
            }
            else if (media == "pic" || media == "PIC" || media == "Pic")
            {
                loadPic(objPath);
            }
            else if (media == "swf" || media == "SWF" || media == "Swf")
            {
                loadSwf(objPath);
            }
            else if (media == "html" || media == "HTML" || media == "Html")
            {
                loadHtml(objPath);
            }
            else
            {
                trace("ERROR: Media type not supported. Media type must be 'text', 'pic', 'swf', or 'html'.");
            }
        }
       
        public function loadText(txtPath):void
        {
            objType = "text";
           
            if (this.numChildren > 0)
            {
                this.removeAllChildren();
            }
           
            this.addChild(textObj);
            this.textLoader.load(new URLRequest(txtPath));
            this.textObj.wordWrap = true;
            this.textObj.multiline = true;
            this.textLoader.addEventListener(Event.COMPLETE, addTextContent);
            //this.textObj.width = this.width;
            //this.textObj.height = this.height;
        }
       
        public function loadPic(picPath):void
        {
            trace("loadPic started");
           
            objType = "pic";
           
            if (this.numChildren > 0)
            {
                this.removeAllChildren();
            }
           
            this.addChild(picObj);
            this.objLoader.addEventListener(Event.COMPLETE, addObjLoader);
            this.objLoader.load(new URLRequest(picPath));
           
            trace("loadPic completed");
        }
       
        public function loadSwf(swfPath):void
        {
            trace("loadSwf started");
            objType = "swf";
           
            if (this.numChildren > 0)
            {
                this.removeAllChildren();
            }
           
            this.addChild(swfObj);
            this.objLoader.addEventListener(Event.COMPLETE, addObjLoader);
            this.objLoader.load(new URLRequest(swfPath));
           
            trace("loadSwf completed");
        }
       
        public function loadHtml(htmlPath):void
        {
            objType = "html";
           
            if (this.numChildren > 0)
            {
                this.removeAllChildren();
            }
           
            this.addChild(htmlObj);
            this.textLoader.load(new URLRequest(htmlPath));
            this.htmlObj.wordWrap = true;
            this.htmlObj.multiline = true;
            this.textLoader.addEventListener(Event.COMPLETE, addTextContent);
        }
       
        private function removeAllChildren():void
        {
            if (objType == "pic")
            {
                this.picObj.removeChild(objLoader);
            }
            else if (objType== "swf")
            {
                this.swfObj.removeChild(objLoader);
            }
            else
            {
                trace("objType != 'pic' or 'swf.' objType = '" + objType + "'.");
            }
           
            while ( this.numChildren > 0 )
            {
                this.removeChildAt(0);
            }
        }
       
        private function addObjLoader(event:Event):void
        {
            trace("addObjLoader started");
           
            if (objType == "pic")
            {
                trace("trying to load pic");
                this.picObj.addChild(this.objLoader);
                this.picObj.objLoader.removeEventListener(Event.COMPLETE, addObjLoader);
            }
            else if (objType== "swf")
            {
                trace("trying to load swf");
                this.swfObj.addChild(this.objLoader);
                this.swfObj.objLoader.removeEventListener(Event.COMPLETE, addObjLoader);
            }
            else
            {
                trace("ERROR: Cannot add object loader. The 'objType' variable does not contain correct media type. The function 'addObjLoader' should only be called when objType is 'pic' or 'swf'. In this case, objType is '" + objType + "' .");
            }
           
            trace("addObjLoader completed");
        }
       
        private function addTextContent(event:Event):void
        {
            if (objType == "text")
            {
                this.textObj.text = event.target.data as String;
                this.textLoader.removeEventListener(Event.COMPLETE, addTextContent);
            }
            else if (objType == "html")
            {
                this.htmlObj.htmlText = event.target.data as String;
                this.textLoader.removeEventListener(Event.COMPLETE, addTextContent);
            }
            else
            {
                trace("ERROR: Cannot add text content. The 'objType' variable does not contain correct media type. The function 'addTextContent' should only be called when objType is 'text' or 'html'. In this case, objType is '" + objType + "' .");
            }
        }

    }
   
}

Loading XML From Other Domain
I think my problem is quite simple but i hope there is a solution:
I want a SWF to load an XML file that is on another server

just for this example: swf is on www.mydomain2.com/myswf.swf

and my XML code is like this:

ActionScript Code:
function xmlLoaded(success){

    if (success){
        _root.myText_txt.text = myXml.firstChild.nodeName;
    } else {
        _root.myText_txt.text = 'error parsing xml';
    }
}

myXml = new XML();
myXml.ignoreWhite = true;
myXml._parent = this;
myXml.onLoad = xmlLoaded;

myXml.load('http://www.mydomain.com/myXML.xml');

the problem is, as soon as the XML is not on the same domain as my SWF it can't load the XML.

Am i doing something wrong? Is this a security issue?

I hope someone has a solution.

Loading SWF From A Different Domain
Hi all,
I am have trouble loading SWF from a different domain.

Files:
index.html (localhost)
index.swf ((localhost)
external.swf (different domain)

Index.html holds index.swf, index.swf has a movie clip that loads external.swf using loadMovie(). When i double click on index.html, everything works just fine, external.swf does load inside the movie clip. But when i run index.html on the webserver (http://localhost/index.html) the movie clip does not load external.swf. I think it has something to do with the swfs being on different domains.

Please tell me how to fix this problem

Thanks

Loading JPG From Another Domain
I'm trying to load a jpg from another domain than the flash is run from (http://localhost for example), the images are loading, but the Event.COMPLETE and Event.INIT arent dispatching.. and i really need to handle them.. How do i do that?

Here's the scipt example:


ActionScript Code:
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("http://www.modernlifeisrubbish.co.uk/images/illustrations/google-as-a-giant-robot.jpg");

ldr.load(urlReq);
addChild(ldr);

ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
function imgLoaded(event:Event):void
    {   
    var contt:Bitmap = event.target.content;
    contt.scaleY = .5;   
    contt.scaleX = .5;
    }

Loading SWF From Another Domain
I have a SWF file that needs to be hosted at images.domain.com and the site resides at domain.com. I have several SWF files that work completely fine. Then I have one (unfortunately) crucial file that uses a animated movie clip to create a rollover roll out link as described in http://www.kirupa.com/developer/mx2004/button_effect.htm to link to the other pages. That movie clip link which is generated in the ActionScript does not work in IE or FF for PC. HELP. Do a need a crossdomain file?

Loading Xml From Another Domain
I have a flash file that uses actionscript to read a remote XML file. Thanks to kirupa.com for the tutorial that allowed me to accomplish this. Everything is working pefectly except one little issue.

When the movie loops it requests the XML file again. How can I have it request the XML file only the first time and just re-utilize the data?

Thanks in advance.

Loading Sound From Another Domain - Possible?
Ok, I'm loading up an XML list of sounds, and some of them are on other domains.

First,
I strip the URLs down to their base URLs and then add them to a quoted, comma separated list ('domainone.com','domaintwo.com','...'). The list is saved as a variable "domainList"

After I have this text list list created, I do this:
System.security.allowDomains(domainList).

Then I proceed to try loading the sound (my_sound.loadSound('url_of_sound/sound',true), and as I thought, I can't.

Is there any way to load sounds from another domain???

I thought the allowDomain method let the app have access to the domains listed. How exactly does this work?

Loading XML From Diff Domain
Hey all,

Is there any way to load xml from diff domain from where the flash file is loaded?

I know by default, flash doesn't allow this for security reason. I wonder if tehre's a way around it?

Thanks!

Problem Loading SWF From Another Domain
I have a SWF file that needs to be hosted at images.domain.com and the site resides at domain.com. I have several SWF files that work completely fine. Then I have one (unfortunately) crucial file that uses a animated movie clip to create a rollover roll out link as described in http://www.kirupa.com/developer/mx20...ton_effect.htm to link to the other pages. That movie clip link which is generated in the ActionScript does not work in IE or FF for PC. HELP. Do a need a crossdomain file?

Copyright © 2005-08 www.BigResource.com, All rights reserved