MovieClipLoader - bytesLoaded problem
I am trying to create a preloader to load multiple swf files
from an XML file. I was able to add the bytesTotal of the files
together to get a cumulative bytesTotal and now I need to do the
same for the bytesLoaded... the problem is that the files load in
parallel so getting the bytesLoaded in the onLoadProgress state
gives me a bytesLoaded number that is WAY larger than my
bytesTotal.
Any idea how I can get the bytesLoaded for each movie and add
them into a cumulative bytesLoaded variable? Code is attached.
Thanks!
- Aaron
-------------------- Code
---------------------------------------
It's getting there! Thanks for the example... now... why is
totalLoaded exceeding totalBytes by a large amount? Shouldn't
totalLoaded equal totalBytes when it is finished?
Also, it seems that the totalLoaded amounts are broken out
individually for each file... how can I add these amounts up into
one totalLoaded for all the files that I'm loading?
Similar Messages
-
FullScreen problem with MovieClipLoader
Hi and thanks very very much for reading.
My problem is: When I load a .swf via MovieClipLoader in ActionScript 2 -- Stage["fullScreen"] no longer works. I am stuck in "normal" for the Stage.
If I run the loaded SWF without the preloader, then everything works fine and I can get to fullscreen mode. So it seems the problem has to do with the preloader.
I am using loadMovieNum("FSTest.swf",0) to bring the loaded clip to Root level. Thought that would solve my problem but it doesn't.
Here is some test code that demonstrates my problem. You can see it run at: http://www.tommygameco.com/TestLoader.html
TESTLOADER.FLA: (preloader)
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var FS_mc:MovieClip = container.createEmptyMovieClip("FSClip", container.getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
var interval:Object = new Object();
listener.onLoadInit = function() {
// make loaded movie _root
loadMovieNum("FSTest.swf",0);
mcLoader.addListener(listener);
mcLoader.loadClip("FSTest.swf", FS_mc);
stop();
FSTEST.FLA: (Loaded Movie)
fsbutton.onRelease = function() {
Stage["displayState"]="fullScreen";
stageState.text = Stage["displayState"];
Thanks again!! Any Clues are greatly appreciated!!!
TomHi,
Problem was in the publish settings --- My loaded clip was set for "allow full screen" under publish options (file Menu, HTML Tab). However the Pre-loader was not!! Fixing that fixes the problem.
Best Regards,
Tom -
Problem Loading Gif's using MovieClipLoader
Hi forum,
I am using the MovieClipLoader to load images into a web
site. some are jpg's some are gif's. Now the problem is that jpg's
load properly and appear on the stage but gif's don't load...(well
at least they don't appear on the stage)
I know MovieClipLoader doesn't load animated gif's (as
mensioned in the help file) but I have created those gifs in flash
and non are animated, they are all just one frame image.
So can anyone tell me what am I doing wrong.
Here is the code:
P.S. I'm exporting for player 7 and I need to keep it that
way.
if I decomment the last line of code the jpg image loads and
appears on the stage.
Many thanks in advance.has981,
> I know MovieClipLoader doesn't load animated gif's (as
> mensioned in the help file) but I have created those
gifs in
> flash and non are animated, they are all just one frame
image.
Actually, MovieClipLoader does load animated GIFs -- they
just don't
animate once loaded.
> if I decomment the last line of code the jpg image loads
> and appears on the stage.
> Many thanks in advance.
You code looks absolutely fine to me. I tested it right here
with a GIF
and a JPG. You're doing this in Flash 8, right? Prior to 8,
Flash only
loaded non-progressive JPGs and SWFs (and earlier, only
SWFs).
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design." -
Hello guys
Iam using the MovieClipLoader object to load multiple jpg
images by getting their names from a xml file but agfter a minute
or two images are disappearing.In other words I can still get a
hand cursor by rolling over them but I cant see them,please guys
help me with this problem.here is my code:
for (i=0;i<10;i++)
{_root.attachMovie("Movie","Movie"+i,i);
_root["Movie"+i].createEmptyMovieClip("Clp"+i,10*i);
var mcloader:MovieClipLoader=new MovieClipLoader();
mcloader.loadClip("Folder/"+xml_var+".jpg" , _root["Movie"+i]
["Clp"+i]);you're repeatedly destroying mcloader with each loop
iteration (until the last).
to remedy, remove your mcloader instantiation statement from
the for-loop and insert just prior to your for-loop. -
Problem with CheckBox and MovieClipLoader
I am using the MovieClipLoader and it was working great,
until I load one of my sections which has a CheckBox in it. Once I
load that section, the MovieClipLoader is not working correctly
anymore. Anyone have experience with this? What can I do?wow, that fixed my issue! I can't believe that is all I
needed.
Thank you so much KGlad! I don't know what I would do without
your help! -
Problems with MediaPlayer.bytesLoaded updating for ImageElement
Hello!
I use Sprint 10 (0.95). MediaPlayer.bytesLoaded property is not updating in the case using ImageElement as source media for MediaPlayer.
Correct load progress bar to make impossible. Actual values are 0/bytesTotal or bytesTotal/bytesTotal only for _mediaPlayer.bytesLoaded /_mediaPlayer.bytesTotal.
Code sample:
_mediaPlayer = new MediaPlayer();
_mediaPlayer.bytesLoadedUpdateInterval = 1;
_mediaPlayer.addEventListener(LoadEvent.BYTES_LOADED_CHANGE, onLoadProgress);
_mediaPlayer.media = _mediaElement; (_mediaElement is ImageElement)
private function onLoadProgress(event : LoadEvent) : void
loaderIndicatorProgressBar.scaleX = _mediaPlayer.bytesLoaded / _mediaPlayer.bytesTotal;
Is this bug?
Thanks in advance!Yes, this looks like a bug. Apparently we don't listen for "progress" events on an image or SWF until it's fully loaded. (I believe the fix is to mosify LoaderLoadTrait.loadStateChangeStart to add the progress listener when newState is LOADING, not when newState is READY.)
Can you file a bug and reference this thread? Thanks!
https://bugs.adobe.com/jira/browse/FM -
I looked up MovieClipLoader tutorials and finally came up with the code:
var myMCL:MovieClipLoader = new MovieClipLoader();
var loadListener:Object = new Object();
myMCL.addListener(loadListener);
loadListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void
var perc:Number = (bytesLoaded / bytesTotal) * 100;
prcnt.text = perc + " %";
loadListener.onLoadInit = function(target_mc:MovieClip)
trace( target_mc + " finished loading so display on screen now. " );
prcnt.text = "init";
loadListener.onLoadError = function(target_mc:MovieClip, errorCode:String, httpStatus:Number)
trace( "error loading image : errorCode : " + errorCode );
loadListener.onLoadStart = function(target_mc:MovieClip)
trace( target_mc + " start loading. maybe you want to do something here? " );
prcnt.text = "onstart";
myMCL.loadClip("filename.swf", mcholder); //mcholder is the movie clip holder placed on stage manually
The problem here is that the file does not move beyond printing this:
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
_level0.mcholder start loading. maybe you want to do something here?
Why is this happening? The code is directly from the tutorial. I have included all event functions, in case they are something like abstract functions, I don't know if this is required or not. I know I must be being a pain, but no one seems to be answering my question. I can't figure out what is wrong with the code, seems simple enough to me. I am sure I am missing some basic point. Any help will be greatly appreciated...it could be that the code in that frame is repeatedly executing. ie, that frame is part of a frame loop.
to remedy, add a stop() to your code. -
Preloader problems - disappears at 60%
Hi,
I have two Preloader problems for a project I'm working on right now.
1. The Main Site preloader disappears when 60% is loaded...with a blank screen lag until moving to the main screen
2. My external .swf Preloader is still on screen after an external .swf has loaded. I can hear the external .swf playing while watching my loader bar at about 20-40%.
I'm going to show the code I have for each...hopefully someone can help. Thanks!
Main Site Preloader:
var yChange = 109.2;
var yStart = 330.2;
myInterval = setInterval(preload,100);
function preload() {
var current = _root.getBytesLoaded();
var total = _root.getBytesTotal();
var pctLoaded = Math.round(current/total*100);
mask_mc._y = yStart - yChange/100*pctLoaded;
if (current >= total) {
clearInterval(myInterval);
gotoAndStop("Main",1);
External SWF Preloader:
var mcLoader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
mcLoader.addListener(myListener);
myListener.onLoadProgress = function(target_mc,bytesLoaded,bytesTotal) {
extLoader_mc._visible = true;
var pctLoaded = Math.round(bytesLoaded/bytesTotal*100);
extLoader_mc.extLoaderBar_mc._xscale = pctLoaded;
if (bytesLoaded >= bytesTotal) {
extLoader_mc._visible = false;change soundHandler in the fla to:
// this code below is on the main timeline?
var soundHandler:AdobeCaptivate.rdSoundHandler = new AdobeCaptivate.rdSoundHandler(this);
and change rdSoundHandler:
import AdobeCaptivate.rdSound;
import flash.display.MovieClip; // if this is as3
class AdobeCaptivate.rdSoundHandler extends Object
var m_sounds:Object;
var m_movieSound:rdSound;
var mainMC:MovieClip;
function rdSoundHandler(mc:MovieClip)
m_sounds = new Object();
m_movieSound = null;
mainMC=mc;
function attachSound(key:Number, id:String):rdSound
var sound:rdSound;
if(m_sounds[key] == undefined || m_sounds[key] == null)
{ //attach new sound to the handler
var newSound:rdSound = new rdSound(mainMC);
// and now you have to find rdSound() class and post that
newSound.attachSound(id);
sound = m_sounds[key] = newSound;
else
sound = m_sounds[key];
sound.stopSound();
return sound;
function detachSound(key:Number)
{ //remove the sound object from the handler
if(m_sounds[key] != undefined && m_sounds[key] != null)
var sound:rdSound = m_sounds[key];
sound.stopSound();
m_sounds[key] = undefined;
function playAllSounds(bPause:Boolean)
if(bPause == true)
{ //pause all sounds
if(m_movieSound != null)
m_movieSound.pause();
for(var key in m_sounds)
m_sounds[key].pause();
else
{ //resume all sounds
if(m_movieSound != null)
m_movieSound.play();
for(var key in m_sounds)
m_sounds[key].play(); -
Problem with the FOR statement.....again!
Hi everyone,
Well I'm still trying to do a car slideshow using external
files and can't seem to see the end. The current movie is here:
http://www.virtuallglab.com/projects.html
I also attach the code. My problem is I had originally set up
an animation with 2 pictures sliding in with some text, and then
wait 4 seconds before sliding out, and then next pictures and text
would slide in and so on, using a setInterval.
The problem is the FOR loop seems to skip the setInterval and
the function "wait", so it just loops quickly and jumps to last
picture, so on the example above, it just slides the last picture
(i=9) and that's it!
Can you not include another function within a FOR statement.
Or is there a way to tell the FOR loop to wait until all motion is
finished?
Any help greatly appreciated
import mx.transitions.*;
import mx.transitions.easing.*;
for (i=0; i<10 ; i++) {
var picLeft = "pics/"+i+".jpg";
var picRight = "pics/"+i+"b.jpg";
var txtToLoad = "text/"+i+".txt";
this.createEmptyMovieClip("leftHolder",1);
leftHolder.loadMovie(picLeft,i,leftHolder.getNextHighestDepth());
leftHolder._x = -200;
leftHolder._y = 15;
var leftTween:Tween = new Tween(leftHolder, "_x",
Strong.easeOut, leftHolder._x, 10, 2, true);
this.createEmptyMovieClip("centerHolder",2);
centerHolder.loadMovie(picRight,i+"b",centerHolder.getNextHighestDepth());
centerHolder._x = 180;
centerHolder._y = 250;
var centerTween:Tween = new Tween(centerHolder, "_y",
Strong.easeOut, centerHolder._y, 15, 2, true);
text._x = 600;
myData = new LoadVars();
myData.onLoad = function(){
text.carText.text = this.content;
myData.load(txtToLoad);
var textTween:Tween = new Tween(text, "_x", Strong.easeOut,
text._x, 420, 2, true);
myInterval = setInterval(wait, 4000);
function wait() {
var leftTweenFinished:Tween = new Tween(leftHolder, "_x",
Strong.easeOut, leftHolder._x, -200, 1, true);
var centerTween:Tween = new Tween(centerHolder, "_y",
Strong.easeOut, centerHolder._y, 250, 1, true);
var textTween2:Tween = new Tween(text, "_x", Strong.easeOut,
text._x, 600, 1, true);
clearInterval(myInterval);
***************************************************************************************** ***There is no way to tell a for loop to wait. That is not what
they do.
The entire for loop will execute (if possible, and it doesn't
enter some kind of continuous infinite loop) completely before each
time the frame is rendered.
If you want to spread things out over time you need to use
the setInterval -- but not inside a for loop! If you do that you
immediately set however many intervals as your loop has. In this
case you will also assign the ids for those intervals to the same
variable, effectively overwriting the value so you will never be
able to clear most of those intervals.
So you need to rethink you whole structure. Set up some kind
of counter and limit like this:
var slidesToShow:Number=10;
var curSlide:Number=0;
Then have your setInterval increment the curSlide each time
it is called and check to see if it has shown all of them. That is
where your "loop" comes in.
As for the other part of your question -- yes you actually
have two different issues going on -- again you cannot make a for
loop wait for anything. So no there is no way to pause it while you
wait for your tween to end. But you can be notified when a tween
ends.
Check out the documentation about the tween class in the help
files. There you will find the onMotionFinished event. So you can
set up one of those to start whatever needs to be started when the
tween has finished.
You should also use the MovieClipLoader class to load your
images, because you have no idea how long it will take to load
them. Using that class you get a nice event (onLoadInit) that tells
you when the asset is ready to be used.
Finally I'm thinking you might want to use setTimeout instead
of setInterval. It only goes once, while setInterval repeats
forever. So I would think your algorithm would be something like
this.
1. load external asset
2. when ready animate in and set onMotionFinished handler
3. when motion is finished start loading next asset and
setTimeout for 4 seconds.
4. when 4 seconds is up or the clip is loaded (which ever
takes longer) go to 2 and repeat.
If this is going to be run locally on a hard drive or CD you
won't have any problem with the length of time it takes to load the
external assets, but if it is over the web it will take time. -
Problem with preloader not passing over nextFrame();
The preloader I created doesn't transistion to the next frame, it just hangs on the preloader frame at 0%. Here is my code:
stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
function updatePreloader (evtObj:ProgressEvent):void{
var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
preloader_bar.width = (percent/100) * 600;
preloader_txt.text = "Loading " + percent + " %";
if (percent == 100) {
nextFrame();
this.removeEventListener(ProgressEvent.PROGRESS, updatePreloader);
The problem is when the swf is called online it stops on the 1st frame and shows the preloader at 0% and does nothing. I can right-click on the non-functional embedded flash swf and select play and it runs fine; but this doesnt make any sense for my users to be doing the same... However, when the file is recalled after the first attempt it works fine. Any ideas what could be going on?Thanks, I think it’s working! I can't recreate the problem...
Code:
stop();
if (this.framesLoaded == this.totalFrames){
nextFrame();
else{
loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
function updatePreloader (evtObj:ProgressEvent):void{
var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
preloader_bar.width = (percent/100) * 600;
preloader_txt.text = "Loading " + percent + " %";
if (percent == 100) {
nextFrame();
this.removeEventListener(ProgressEvent.PROGRESS, updatePreloader); -
Problem in Loading Multiple image in Single Sprite/MovieClip
Hi All,
I am having a killing problem in loading multiple images in single movie clip/sprite using a separate class.
Here is the ImageLoader.as class
package com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(imgHolder:MovieClip, imgObj:Object):void {
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
imgMc = imgHolder;
imgObject = imgObj;
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadProgress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadFailed);
imgloader.load(new URLRequest(imgObj.FilePath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
//imgLoader=new ImageLoader;
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(target.list_mc.imgholder_mc,imgObj);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++;
In this case, the ImageLoader.as works only on the last movie clip from the for loop. For example, if i am trying to load three image in three movie clips namely img_mc1,img_mc2 and img_mc3 using the for loop and ImageLoader.as, I am getting the image loaded in the third movie clip only img_mc.
See at the same time, If i uncomment onething in the for loop that is
//imgLoader=new ImageLoader;
its working like a charm. But I know creating class objects in a for loop is not a good idea and also its causes some other problems in my application.
So, help to get rid out of this problem.
Thanks
-Varunpackage com.project.utils{
import com.project.*;
import com.project.utils.*;
import flash.events.EventDispatcher;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.Loader;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Bitmap;
public class ImageLoader extends EventDispatcher {
public var imgloader:Loader;
public var imgMc:MovieClip;
public var imgObject:Object;
public var loaded:Number;
public function ImageLoader():void {
// better add you movieclip to the stage if you want to view anything added to it.
imgMc = new MovieClip();
imgObject = new Object();
imgloader = new Loader();
public function loadImage(filepath:String):void {
imgloader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImgLoad);
imgloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImgLoadPr ogress);
imgloader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,onImageLoadF ailed);
imgloader.load(new URLRequest(filepath));
private function onImgLoad(Evt:Event):void {
var image:Bitmap = Bitmap(Evt.target.content);
try {
imgMc.removeChildAt(0);
} catch (error:Error) {
imgMc.addChild(image);
try {
if (imgObject.URL != undefined) {
imgMc.buttonMode = true;
imgMc.removeEventListener(MouseEvent.CLICK, onImageClicked);
imgMc.addEventListener(MouseEvent.CLICK, onImageClicked);
} catch (err:Error) {
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD"));
private function onImageClicked(evt:MouseEvent):void {
trace("Image Attrs:"+imgObject.URL +" Target "+imgObject.Target);
private function onImgLoadProgress(Evt:ProgressEvent):void {
if (Evt.bytesLoaded>0) {
loaded = Math.floor((Evt.bytesLoaded*100)/Evt.bytesTotal);
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_PROC",loaded));
private function onImageLoadFailed(Evt:IOErrorEvent):void {
trace("Image Loading Failed");
dispatchEvent(new CustomEvent("CustomEvent.ON_IMGE_LOAD_FAIL"));
Here I am loading some images using the above class in a for loop, like
for (var i=0; i < 3; i++) {
var imgLoader:ImageLoader=new ImageLoader();
imgLoader.addEventListener("CustomEvent.ON_IMGE_LOAD",onImageLoad);
var target:MovieClip=videolist_mc["list" + mcCount + "_mc"];
target.list_mc.visible=false;
var imgObj:Object=new Object;
imgObj.FilePath=list[i].Thumbnail;
imgObj.Url=list[i].Url;
imgObj.Target=list[i].Target;
target.list_mc.urlObj=new Object ;
target.list_mc.urlObj=imgObj;
imgLoader.loadImage(pass the image file's path/name);
target.list_mc.lable_txt.htmlText="<b>" + list[i].Label + "</b>";
target.list_mc.imgholder_mc.buttonMode=true;
target.list_mc.imgholder_mc.addEventListener(MouseEvent.CLICK,onItemPressed);
mcCount++; -
Problem with volume handle and external SWF
Hello I'm having 2 problems.
The first is that when loading an external swf in my main SWF I get this in the output window:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at audio_fla::list_1/frame1()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at audio_fla::MainTimeline()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at audio_fla::MainTimeline/frame1()
But it still works. Its an mp3 player.
The other problem is that the loaded SWF has a volume controller. When I test the external SWF by itself it works fine. When I load it on my main SWF when I start to drag the handle on my volume slider and MOUSE_UP outside the handle it still keep dragging the handle.
The code of my main SWF is:
import caurina.transitions.*;
var _currentCategory:String = "";
var percent:String = "";
var loader = new Loader();
loader.name="videoLoader";
loadermc.visible=false;
cat.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
cat.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
cat.addEventListener(MouseEvent.CLICK, onClickCat);
btnback.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
btnback.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
btnback.addEventListener(MouseEvent.CLICK, onClickBack);
cat.buttonMode = true;
btnback.buttonMode = false;
btnback.visible = false;
function onOverCat(e:MouseEvent):void{
Tweener.addTween(e.target, {alpha:.5 , time:.5});
function onOutCat(e:MouseEvent):void{
Tweener.addTween(e.target, {alpha:.25 , time:.5});
function onClickBack(e:MouseEvent):void{
loader.unloadAndStop();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
lcontent.visible = false;
cat.visible = true;
Tweener.addTween(cat, {alpha:1, time:1});
btnback.buttonMode = false;
btnback.visible = false;
cat.buttonMode = true;
toptxt.text = "SELECCIONE UNA CATEGORIA"
function onClickCat(e:MouseEvent):void{
lcontent.visible=true;
cat.buttonMode = false;
Tweener.addTween(cat, {alpha:0, time:1, onComplete:function(){
cat.visible = false;
btnback.buttonMode = true;
btnback.visible = true;
loaderTweenIn(e.target.name);
function loaderTweenIn (c:String):void{
var category:String = c+".swf";
trace(category);
loader.load(new URLRequest(category));
loader.contentLoaderInfo.addEventListener (Event.COMPLETE, movieLoaded);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, movieProgress);
function ioErrorHandler(e:IOErrorEvent):void{
trace("ioErrorHanlder: "+e);
function movieLoaded(e:Event):void{
trace("The movie has loaded");
lcontent.addChild(loader);
loadermc.visible=false;
function movieProgress(e:ProgressEvent):void{
loadermc.visible = true;
// percent=String(Math.floor(e.bytesLoaded / e.bytesTotal * 100)) + "%";
trace("The movie is loading "+Math.floor(e.bytesLoaded / e.bytesTotal * 100));
The code on my external SWF is:
import caurina.transitions.*;
volume_mc.slider_mc.buttonMode = true;
var myXML:XML;
var thb:Thbs;
var myThumbs:XMLList;
var totalThumbs:Number;
var thumbHeight:Number=50;
var i:uint = 0;
var preloader:LoaderAnim;
var yCounter:Number = 0;
var container:MovieClip;
var musicReq:URLRequest;
var music:Sound = new Sound();
var sc:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var songPlaying:Boolean = false;
var songlist:XMLList;
var currentIndex:Number = 0;
mc_sound.mute.visible=false;
var xmlLoader:URLLoader = new URLLoader();
///////////////////////////PLAYLIST//////////////////
function initMediaPlayer(e:Event):void{
myXML = new XML(xmlLoader.data);
myThumbs = myXML.*;
totalThumbs = myThumbs.length();
trace("The total thumbs are "+totalThumbs);
createContainer();
callThumbs();
xmlLoader.load(new URLRequest("audio.xml"));
function createContainer():void{
container = new MovieClip();
list.ch.addChild(container);
container.y = 0;
container.x = 0;
container.buttonMode = true;
function onOver(e:MouseEvent):void{
var t:Loader = Loader(e.target);
Tweener.addTween(t, {alpha:.5, time:1});
function onOut(e:MouseEvent):void{
var t:Loader = Loader(e.target);
Tweener.addTween(t, {alpha:1, time:1});
function callThumbs():void{
var thumbURL = myThumbs[i].@thumb;
var thumbTitle:String = myThumbs[i].@title;
var thumbDesc:String = myThumbs[i];
trace("Loading "+thumbURL);
trace("Title "+thumbTitle);
trace("Desc "+thumbDesc);
var thumbLoader = new Loader();
thumbLoader.load(new URLRequest(thumbURL));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumbLoader.name=i;
thumbLoader.x=5;
thumbLoader.y=5;
thb = new Thbs();
container.addChild(thb);
thb.thb_title.htmlText = thumbTitle;
thb.thb_desc.autoSize = TextFieldAutoSize.LEFT;
thb.thb_desc.htmlText = thumbDesc;
thb.y = (thumbHeight+2)*yCounter;
preloader = new LoaderAnim();
preloader.x = thb.x + 20;
preloader.y = thb.y+ 20;
container.addChild(preloader);
yCounter++;
function thumbLoaded(e:Event):void{
var thbx:Loader = Loader(e.target.loader);
thb.addChild(thbx);
thbx.addEventListener(MouseEvent.MOUSE_OVER, onOver);
thbx.addEventListener(MouseEvent.MOUSE_OUT, onOut);
container.removeChild(preloader);
i++;
if (i<totalThumbs){
callThumbs();
if (i==totalThumbs){
startAudio();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
///////////////////////////////////////AUDIO//////////////////////////
function startAudio():void{
songlist = myXML.*;;//this is the same as myXML.*;
trace("This is the first song "+songlist[0].@song);
musicReq = new URLRequest(songlist[0].@song);
music.load(musicReq);
sc = music.play();
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
next_btn.addEventListener(MouseEvent.CLICK, nextSong);
prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);
stop_btn.addEventListener(MouseEvent.CLICK,stopSong);
function nextSong(e:Event):void
if (currentIndex < (songlist.length() - 1))
currentIndex++;
else
currentIndex = 0;
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
var nextTitle:Sound = new Sound(nextReq);
sc.stop();
sc = nextTitle.play();
songPlaying = true;
currentSound = nextTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
function prevSong(e:Event):void
if (currentIndex > 0)
currentIndex--;
else
currentIndex = songlist.length() - 1;
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
var prevTitle:Sound = new Sound(nextReq);
sc.stop();
sc = prevTitle.play();
songPlaying = true;
currentSound = prevTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
function pauseSong(e:Event):void
pos = sc.position;
sc.stop();
songPlaying = false;
play_btn.addEventListener(MouseEvent.CLICK,playSong);
function playSong(e:Event):void
if(songPlaying == false)
sc = currentSound.play(pos);
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
songPlaying = true;
play_btn.removeEventListener(MouseEvent.CLICK,playSong);
function stopSong(e:Event):void
sc.stop();
pos = 0;
songPlaying = false;
play_btn.addEventListener(MouseEvent.CLICK,playSong);
///////////////////////////////VOLUME/////////////////////////////
var xOffset:Number;
var xMin:Number = 0;
var xMax:Number = volume_mc.track.width;
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, sliderDown);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
stage.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
function sliderDown(e:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
xOffset = mouseX - volume_mc.slider_mc.x;
function sliderUp(e:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
function sliderMove(e:MouseEvent):void{
volume_mc.slider_mc.x = mouseX - xOffset;
if(volume_mc.slider_mc.x<=xMin){
volume_mc.slider_mc.x = xMin;
if(volume_mc.slider_mc.x>=xMax){
volume_mc.slider_mc.x = xMax;
var vol:Number = volume_mc.slider_mc.x*.01;
var st:SoundTransform = new SoundTransform(vol,0);
sc.soundTransform = st;
trace("The volume is "+vol);
if(vol==0){
mc_sound.mute.visible=true;
}else{
mc_sound.mute.visible=false;
e.updateAfterEvent();I found the solution.
-
Problem with XML loading and xmlns
I'm having a problem with loading an XML file that was created by Filemaker. Filemaker will output an XML file using one of two different grammars. One outputs in a mostly standard form that I can use with one glitch. Flash CS4 AS3 seems to have a problem with the xmlns in one of the nodes.
Specifically:
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
If I remove the xmlns="http://www.filemaker.com/fmpdsoresult" the file loads properly and I can access the various fields with no problem. However, when I leave the xmlns=... in, it will trace out the XML properly but I can't access the fields using the code listed below. This is driving me crazy!
With the xmlns part in the XML file I get the following error when it tries to load the thumbnail files:
TypeError: Error #1010: A term is undefined and has no properties.
I need to have it so that the user can enter/edit data and simply output the XML file from Filemaker and then Flash will load up the unaltered XML file and show the info requested by the user. That is to say I could have the user open the XML file in a word processing application and have them delete the xmlns..., but that is rather cumbersome and not very user friendly.
I've tried every xml.ignore function I could find but it doesn't help. Hopefully someone out there can help
Thanks,
-Mark-
Partial XML:
XML From Filemaker Export:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This grammar has been deprecated - use FMPXMLRESULT instead -->
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>Sport.fp7</DATABASE>
<LAYOUT></LAYOUT>
<ROW MODID="1" RECORDID="1">
<FirstName>Mark</FirstName>
<LastName>Fowle</LastName>
<Sport>Sailing</Sport>
<Medal>None</Medal>
<CourseOfStudy>Design</CourseOfStudy>
<Year>1976-1978</Year>
<HomeState>California</HomeState>
<ImageName>93</ImageName>
</ROW>
</FMPDSORESULT>
AS3 Code:
import fl.containers.UILoader;
var aPhoto:Array=new Array(ldPhoto_0,ldPhoto_1,ldPhoto_2,ldPhoto_3,ldPhoto_4,ldPhoto_5);
var toSet:int=10;//time out set time
var toTime:int=toSet;
var photoPerPage:int=6;
var fromPos:int=photoPerPage;
var imgNum:Number;
//var subjectURL:URLRequest=new URLRequest("testData_FM8.xml");
var subjectURL:URLRequest=new URLRequest("Sports.xml");
var xmlLoader:URLLoader=new URLLoader(subjectURL);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var subjectXML:XML = new XML();
subjectXML.ignoreWhitespace=true;
subjectXML.ignoreComments=true;
subjectXML.ignoreProcessingInstructions=true;
function xmlLoaded(evt:Event):void {
subjectXML=XML(xmlLoader.data);
if (root.loaderInfo.bytesTotal==root.loaderInfo.bytesLoaded) {
removeEventListener(Event.ENTER_FRAME, xmlLoaded);
trace("XML Data File Loaded");
trace(subjectXML);
} else {
trace("File not Found");
imgNum=2;//subjectXML.ROW.length;
trace(subjectXML);
loadThumb(0);
function loadThumb(startPos:int):void {
var count:Number=aPhoto.length;
trace(subjectXML.DATABASE);
for (var i=0; i<count; i++) {
try{
aPhoto[i].source="images/"+subjectXML.ROW[startPos+i].ImageName+"_main.jpg";
}catch (e:Error){
trace(e);
aPhoto[i].mouseChildren=false;
aPhoto[i].addEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
ldAttract.visible=false;
function unloadThumb():void {
var count:Number=aPhoto.length;
for (var i=0; i<count; i++) {
aPhoto[i].unload();
aPhoto[i].removeEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
function onThumbClick(evt:MouseEvent) {
var i:Number;
//trace("Thumbnail Clicked " + evt.target.name);
i=findPos(evt.target.name);
ldLrgPhoto.source="images/"+subjectXML.ROW[i+fromPos].LOCAL_OBJECT_ID+"_main.jpg";
ldLrgPhoto.visible=true;
btnPrev.visible=false;
btnNext.visible=false;
gotoAndStop("showPhoto");
function findPos(thumb:String):Number {
var pos:Number;
var count:Number=aPhoto.length;
for (var i:Number=0; i<count; i++) {
if (thumb==aPhoto[i].name) {
pos=i;
return pos;Hi,
I was trying to use xml namespaces, so in my application I receive an XML file from the server. The file has a namespace, so when I parse the file I need to specify the namespace:
I got the following piece of xml:
<ls:exchange xmlns:ls=".../tsw" xmlns:tm="http://kxa">
<ls:projects>
<tm:annotation id="" date="" action="getprojects" status="responseok"/>
<ls:project id="" name="proj" description="..." owner="asss" release="2" />
<ls:projectV id="" version="" creationdate="" modificationdate=""/ >
</ls:project>
</ls:projects>
</ls:exchange>
and the following code
<mx:VBox label="WELCOME" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Tree id="tree" dataProvider="{srv.lastResult.project}" labelField="@name" width="300" height="100%" itemOpen="itemOpenEvt(event);" />
</mx:VBox>
So i want to display the content of the xml (project nodes”) in a tree view, but i don’t know how to includes the namespace"ls:" in the data provider “srv.lastResult.project”. can u help me it’s urgent.
sincerly
Celine -
Hello.
I am having a weird problem when trying to test a movie or publish preview -> flash on mac with Leopard os.
The result is a blank movie with the usuall "movie not loaded" if u right click on it and the output returns the "Error opening URL 'the path of the swf here'.
This has nothing to do with loading external files or something like that. It happens even in blank movies and it gives the same error if I try to open a swf from flash ide.
I can publish the project or export the movie with no problem at all.
I can preview the movie in html. I can run all the swf files in my hard disk, network, usb stick, dvd etc., but when I try to open any of these files from flash ide I got that stupid error.
Its not something that stops me from working in flash ide but its slow to export movie any time I want to test it.
Things that I've tried so far but nothing worked:
Update the flash cs4 to the latest version
Update the flash players
Restored the release flash player as default player (I am using as default the debug player)
Cleared the preferences
Move the flash cs4 folder to another location in hd
Saved the fla document first before testing the movie (in different places with or without spaces in document name or folder)
Give read & write permissions for everyone for flash.app, players and for fla files when saved first before test movie
Unistall and install the application 3-4 times.
Test every as version just in case.
Also I've checked the folders when testing movie and I can see that it creates an swf file, which I can run it outside flash ide (the one that the flash ide player cannot load) with no problem.
The mac os has the default set up as it came. Nothing chnaged in permissions or security settings.
Thanx in advance.In this particular example I am using this code to start the
xml file load:
// now load the XML file that contains the content strings
var sXMLFile:String = "xml/home.xml";
var xmlContent:XML = new XML();
xmlContent.ignoreWhite = true;
xmlContent.onLoad = onXMLLoadComplete;
xmlContent.load( sXMLFile );
But I don’t think the code is the problem here . This
happens on every file I load when I am using a relative path to the
content, regardless of how I load the content (XML object,
loadMovie, MovieClipLoader, etc…) and the same code executes
perfectly on every other machine in the office(Mac and PC).
I’m more concerned with the semi-colons and .swf filename
that Flash is putting into my relative path on the error message.
Is that normal? -
Strange problem with ProgressEvent.PROGRESS in different laptob
i made simple of my project to show the problem
the code
package
import flash.display.MovieClip;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.events.MouseEvent;
import flash.events.*;
import flash.net.URLRequest;
import flash.net.FileReferenceList;
import flash.net.URLVariables;
import flash.net.URLRequestMethod;
public class Control extends MovieClip
public var allTypes:Array;
public var imageTypes:FileFilter;
public var textTypes:FileFilter;
public var fileRef:FileReference;
public var request:URLRequest;
public function Control()
imageTypes = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
textTypes = new FileFilter("Text Files (*.txt, *.rtf)", "*.txt; *.rtf");
allTypes = new Array(imageTypes, textTypes);
upload_icon.addEventListener( MouseEvent.CLICK, upload_icon_click);
add_icon.addEventListener( MouseEvent.CLICK, add_icon_click);
function add_icon_click (e:MouseEvent):void
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,uploadCompleteDataHandler);
try
var success:Boolean = fileRef.browse();
catch (error:Error)
trace("Unable to browse for files.");
function uploadCompleteDataHandler(event:DataEvent):void {
//result = ExternalInterface.call("error_file_upload", "uploadCompleteData: " + event.data);
trace("uploadCompleteData: " + event.data);
function selectHandler(event:Event):void
testout.text=testout.text+fileRef.name+"==="+fileRef.size+"==="+fileRef.type+"\n";
trace(fileRef.name+"==="+fileRef.size+"==="+fileRef.type+"\n");
function upload_icon_click (e:MouseEvent):void
request = new URLRequest("http://egyouth.com/mahmoud/test/upload.php");
var valebal:URLVariables = new URLVariables();
valebal.login_send_info = 4;
valebal.user = 'mahmoud';
request.method = URLRequestMethod.POST;
request.data = valebal;
try
fileRef.upload(request);
catch (error:Error)
trace("Unable to upload file.");
function completeHandler(event:Event):void
trace("trace");
function progressHandler(event:ProgressEvent):void
testout.text=testout.text+fileRef.name+"==="+fileRef.size+"==="+fileRef.type+"=="+event.bytesLoaded+"==="+event.bytesTotal+"\n";
trace(fileRef.name+"==="+fileRef.size+"==="+fileRef.type+"=="+event.bytesLoaded+"==="+event.bytesTotal+"\n");
this code you can test on
http://egyouth.com/mahmoud/test/mahmoud.html
the problem is when i try this code in my computer progressHandler function work very good
like if i upload 5mb it take like 1m and every 1sec he run progressHandler function
but when i run this code in deferent computer use the same speed ( same network)
i upload 5mb and progressHandler function run very fast and just take 2 secand and tell me the file upload
but the file not upload and after 1 m i will see it in the upload folder
http://egyouth.com/mahmoud/test/files/
so what the problem now ( i think in the secand computer the as3 thought that he upload use the speed of computer not the speed of the network like my laptob )
just for trace my laptob run with adobe flash player 10.0.2.54
and
the second computer run with adobe flash player 10.0.45.2in the second computer run with adobe flash player 10.0.45.2 progressHandler function run very fast ex
when i upload a 100mb it must take 30min but it just take 4 sec !! and it tell me the upload done
but when i open the folder of upload i didnt see the file
and if i still open the page of upload i will see the folder after 30min
i think that progressHandler function in this computer use the speed of computer not the speed of network
Maybe you are looking for
-
Why can't i activate my iphone 3gs after upgrading it to ios 6?
why can't i activate my iphone 3gs after upgrading it to ios 6? It says, ''There is no sim card installed in the iphone you are attempting to activate'' Thanks for your help in advance! Kayl07
-
Radeon 9800 AIW pro compatability?
Anybody know of any compatability issues w/ATI/radeon 9800 AIW pro and 865PE NEO-2 FIS2R mobo's during POST??? See my other thread, I'm having a hell of a time getting my new system to pass POST and get to bios screen, monitor stays in standby, am
-
Email in photos not working in iPad 2
Email in iPad 2 not working , any one help me
-
Help with installation of Illustrator (CS3 on Windows Vista)
I downloaded Illustrator onto my laptop, but when I go and try and nstall it, it gives a message saying: installation cannot continue until the following applications are closed: internet explorer. Please close the applications listed above and click
-
When I try to down load the software i get "this link needs to be opened with an application"
help please when I try to down load the software i get "this link needs to be opened with an application" What kind of application do I need to choose?