Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Moviecliploader In Swishmax, a little bit crippled, this notwithstanding useful
gkaizer
post Jan 23 2006, 08:39 AM
Post #1


New Member
Group Icon
Group: *Premier*
Posts: 3
Joined: 11-January 06
Member No.: 8,910





I searched on many forums for an easy implementation of the topic of this little tutorial, the MovieClipLoader class.

Unfortunately I've been soon discouraged by the really poor piece of information found, so I decided to test some code myself, and after some efforts found out how to implement this really useful object.

Off we go.

First open your swishmax application, and add a new two text objects, call them "bb_text" and "txt_perc", and a new sprite, and call it "gs" (or whatever, the important thing is to mirror these
changes in code).
Movie need to be at least 640*480 for this tutorial to work properly.
Change gs position to x = 0, y = 0 (so that it will be at the top left corner, so perhaps you will have to arrange its anchor point to top left), bb_text at x = 162 and y = 412, and finally txt_perc
x = 463 and y = 439.
We should have something like this:

Attached Image


and
Attached Image


and
Attached Image

Attached Image


As you can see I flaged bb_text to be a target and under Advanced added a variable whose name is "nome", and the same for txt_perc with the variable name "percent".
Well, this done select Scene_1, pass to script tab, and add this code

CODE
onload(){
   mcl = new MovieClipLoader();
   mcl.onloadInit = function(target){
      with(target){
          _xscale = 30;
          _yscale = 30;
          nome = "Complete!"
       }
    };
    gs._x = 40;
    gs._y = 150;
    mcl.loadClip("http://www.ilgeko.net/kvd/home.swf", this.gs);
}

onEnterFrame(){
    percent = gs.percentLoaded();
    if ( percent >= 100){
        this.onEnterFrame = null; // or delete this.onEnterFrame;
    }
}


Some explanations are needed.

First, at onload event, we create a new object of type MovieClipLoader and give it a name "mcl".
We then add a new event method to the newly created instance mcl, onloadInit. This name is important, because this is an abstract method of class
MovieClipLoader, i.e. only its name and signature (number of paramaters and type of paramenters) have been defined by actionscript, but not its implementation.
This means, we can change the body of this method, but not its name!
As for its paramenter, it is optional, but we will use it, as this permit to easily arrange container properties (_xscale and _yscale).
In fact, MovieClipLoader is just a sort of wrapper object to "load" content, but it needs a place where to put loaded data, and in this case, with

CODE
mcl.loadClip("http://www.ilgeko.net/kvd/home.swf", this.gs);


we are loading a swf file (the content) inside our sprite gs (the container).

I know what you now are thinking, this is very like to loadMovie, what's the use of this method over the other?

onloadInit fires only when a content is ready to start, so no more need to write something like
CODE
if (_totalframes == _framesloaded)

and using setInterval to call that code every so many milliseconds...so less code is a big advantage.

The bad news are that I could only run loadClip, unLoadClip and onloadInit methods, all the others for this class are not handled the right way, for example
onloadProgress seems to behave wrongly, and the same getProcess.

So that's why in my example I have used the onEnterFrame event to handle loading progress of sprite gs.
This event fires on entering every frame of my movie, it puts the percentage of loaded bytes into percent variable, and when loading process of sprite "gs" content is over,
exits deleting itself.

You can find an example swi file here Attached File  moviecliploader.swi ( 3.34K ) Number of downloads: 2689
or here for those who cannot download from the attachment bigwink.gif.

I hope this little tutorial cleared some doubts on this useful object.

Cheers

gkaizer
 
+Quote Post  Go to the top of the page
*D*
post Feb 22 2006, 02:46 PM
Post #2


Merry KissMoose
Group Icon
Group: Main Team
Posts: 15,990
Joined: 18-May 04
From: North Pole
Member No.: 2





hiya.gif Hello gkaizer and welcome to 13dots, apologies in late reply to your tutorial I hadn't actually seen this til today.

Thankyou for submitting this very helpful. thumbsup.gif
 
+Quote Post  Go to the top of the page
Ghallya
post May 2 2006, 10:25 PM
Post #3


New Member
Group Icon
Group: Member
Posts: 6
Joined: 30-April 06
From: UAE
Member No.: 11,016





thanx alot smile.gif
 
+Quote Post  Go to the top of the page
RedDragon
post May 2 2006, 10:36 PM
Post #4


insert coin
Group Icon
Group: Main Team
Posts: 5,344
Joined: 24-May 04
From: Maastricht
Member No.: 35





Never noticed this one either.. sorry!

Thanks a lot for adding Ghallya, and congrats on the Premier status victory.gif
 
+Quote Post  Go to the top of the page
osta90
post May 3 2006, 07:03 PM
Post #5


New Member
Group Icon
Group: Member
Posts: 23
Joined: 28-November 04
Member No.: 1,224





thanx alot
 
+Quote Post  Go to the top of the page
mikelowe983
post Aug 24 2007, 04:52 AM
Post #6


New Member
Group Icon
Group: Member
Posts: 12
Joined: 26-July 07
From: Canada
Member No.: 17,055





Hey,

Having a hard time implementing this on my own. I followed the steps precisely and substituted my own url into the mcl.loadClip function, However, when I test the movie all I get is the number 100. I realize this is supposed to be the loading percentage, but it is immediately 100 and then nothing else happens everytime I play the movie. What would make this happen? any thoughts?

thanks

EDIT: from the debug frame: " ERROR: Unknown class 'MovieClipLoader' ". Im not TOO savy when it comes to the swish script just yet. Is this a class you have to define? or is it predefined and included in swishmax?

This post has been edited by mikelowe983: Aug 24 2007, 05:59 AM
 
+Quote Post  Go to the top of the page
axivelet
post May 20 2008, 07:25 PM
Post #7


Getting Used To The Dots
Group Icon
Group: Member
Posts: 45
Joined: 19-March 08
Member No.: 19,875





thank you
 
+Quote Post  Go to the top of the page
mostafaihab
post Jan 28 2009, 12:12 PM
Post #8


Getting Used To The Dots
Group Icon
Group: Member
Posts: 32
Joined: 25-July 05
Member No.: 5,579



good work
 
+Quote Post  Go to the top of the page

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 29th July 2010 - 10:53 PM
Marketing articles | Find jobs | Find jobs | Artigos Sobre Saúde | Health 2007