Preloader and moviecliploader class
Hello
Firstly thanks to kglad for some advice yesterday. More needed
I am using FlashMX 2004 Professional.
I have been having problems with my preloader which i have placed as a movieclip at the start of the pertinent scenes where it is needed. The problem has been one of file size in frame one - a common problem I beieve. This causes the preloader script to malfunction and come in late and show just 100% loaded of the preloader animation - again a common problem I am reading. SO it seems clear having designed the whole website using LoadMovie Number that the movieClipLoaderClass would be the solution to getting my Preloader to work. Hmm..
So can people tell me that if I now create a seperate scene for the preloader and have it listen for any downloading swf to activate using the moviecliploader class will this work ok in tandem with how I have connected all the other scenes using the loadmovienumber? Just need to now before I start trying that out. My hope is that the Preloader will then overcome the file size issue of the first frame because and it will not have to load itself every time afresh.
Hope this makes sense, I am fairly inexperienced here...
Cheers
Pete
I know everything about the file, I know that the sound starts on the first frame and also I know it ends on the last frame. If the sound data are on the main timeline, the sound could be streamed and you don't have to load it fully to start playback. The question is the same, how much I need to load to start the sound.
I think it's not very clear why I need this. Imagine:
- you need to play the external SWF file
- you start to load it via the MovieClipLoader class
- onLoadInit you stop the movie and wait for the load
- check, if you can run the movie - based on bytes and/or frames you can determine, you preloaded enough, so the movie won't be stopped and you don't have to load more to continue
- but, when you run the movie, the animation starts, just the sound doesn't, because more of it needs to be loaded.
- then after short time the sound start to play and since it's streamed and on the timeline, it's sync with the animation
So, in this scenario a few seconds of the sound are skipped / missing in playback. Of course, it could happen that the sound runs fine, because the SWF content could be different. I can't say 20% of the file size is audio and the rest is the animation.
I wanted fully flash solution, but it seems I'll have to find it in combination with Java, because it seems there is no way to distinguish between audio and other data in the Flash movie in AS.
Anyway, thank you for your help.
Similar Messages
-
Preloader and Document Class BIG question (yeap please help)
Hy,
I know that this its a question posted many, many times, but
after searching the net, reading a lot of books and searching this
forum too, I cant get out with a solution. If I'd say for sure
there is no possibility to create something like this, I just go
back to old methods but is not the scope of Adobe with AS3 to
encourage the use of OOP principle or not?
The problem:
I have a single fla file (AS3) with a single frame on
timeline, frame that its there when you will create the file with
flash. In the library I have different symbols, that for simplicity
are only jpg image, (BitmapData) checked for export for
ActionScript and exported on frame one. An external .as file called
DocumentClass its off course my Document Class
This its all that I want to do with the fla, the goal its to
create, animate etc. only with AS3 in external classes, no timeline
script. I don't want to load external files, XML, or else in this
movie. I just want a single swf after compilation, no additional
files.
Ok, how do I create a preloader that will take care of
starting the logic after the whole swf its loaded and in the same
time shows the user a percentage or a load bar or something that
its not the blank screen when the swf its downloading. I want to do
this without another swf that load this swf, or timeline scripts,
or place all the content on second frame and then gotoAndStop to
the third frame. All this are not solution but cheap tricks, that
are against all this OOP principle that I just continue to read in
books and here from guru programmers.
The big question is:
It is possible to create a preloader, when use a document
class with your fla? And if yes, how?
I know that the Document Class its not instantiated if its
not fully loaded, if that's true when the document class will be
fully loaded? maybe after the whole movie its loaded? And, if its
true, it will never show a percentage bar "while" the movie its
loaded. And if that's true WHY use a document class anyway?
Thank you for reading this and I really wait to get some
answer.I am pretty sure you cannot do self preloader with one frame
and all the objects in the library. I guess the key here is
one-frame design. Screen refreshes (renders) only when all the
scripts in the frame are executed - this is a very important thing
to understand about how Flash works. Yes, you can force screen
refresh with updateAfterEvent() method but it is attached to a
handful of events only (MouseEvent and TimerEvent) but, again, all
this functionality is available only after first frame scripts are
executed. Thus, it seems like the only way to create preloader from
within SWF is to use multiple frames and set library objects to
load in later (not first) frame.
quote:
And if that's true WHY use a document class anyway?
Well, preloader is the last thing that would be on my mind in
terms of using AS3 ability to link DocumentClass to the top movie.
This feature allows for very sophisticated architectural
approaches. It has no connection to preloader as to any other
features developer wants to implement. Neither it depends on or
negates timeline. As a matter of fact, although I love one-frame
applications, I find on numerous occasions that my application
would be more efficient if I used several (at least two) frames.
gotoAndStop is not deprecated. It is a valid MovieClip class'
method. After all, having only one frame doesn't mean not having
frames at all - there is one already. Frames are fundament of
Flash. AS3 did introduce frameless entities like Sprite, etc. but
it doesn't mean that frames are going anywhere.
I would agree that timeline code is inferior to
classed/packaged (read: better organized) code but, still, how is
it not OOP? Frame is an Object, right? Why using timeline is cheap
and not a solution?
On a side note, I see too many times how some authors (and
managers) are pushing their agenda (or close mindedness) onto their
audience with no real substantiation. Claiming that timeline in
Flash is not valid architectural decision from OOP standpoint is
totally wrong. As wrong as strict adherence to design patterns. I
don't think there is sharply defined "right" or "wrong" in
programming. One finds the best optimal solution. The goal is to
create something that works fine. Unless, of course, the process is
the goal - but very few of us can afford focusing on the process. -
My Flash site has a media player which uses the attachSound
method to play and skip through 3 mp3s. As a result the preloader
shows up after the movie has loaded 60%. To rectify this, i changed
the Publish Settings under the Flash Tab so that the classes for AS
2.0 load in the 2nd frame of the Preloader Scene(I have separated
the preloader and the main movie to diffrerent scenes..)
I read it somewhere that to correct a similar problem with
MCs, you need to place them somewhere in the timeline (say,Off
Stage), But how can same be done for Sound Objects.???if i do that then the preloader works fine,however the player
doesnt work...since the audio files dont get loaded.. -
MovieClipLoader Class doesn't allow function calls
I have functions within a movieClip that loads into a main
movie. The functions operate with no problem when using loadMovie
method, but I need to execute some script after loading so I
switched to the movieClipLoader class instead.
Problem is, after the movieClip is loaded, any function calls
from a keyframe (or even a button) are totally ignored.
What am I missing. Should I be doing something different?
here is my movieClipLoader code:Actually, I think I found the solution after looking at some
other posts. I changed "onLoadComplete" to "onLoadInit" and it
worked.
As I found in another post, onLoadComplete doesn't mean all
of the code is loaded yet, but onLoadInit means the movie and code
is loaded. -
For some reason, I'm having difficulty wrapping my head
around how to implement and use the MovieClipLoader class. Here's
where I'm stuck. I have a bit of code that looks like this:
function showImage(filename:String):Void {
var image:MovieClip = imagePlaceholder_mc.image_mc;
image.loadMovie(filename);
//Center images
xPos = (900 - image._width)/2;
yPos = (600 - image._height)/2;
image._x = xPos;
image._y = yPos;
imagePlaceholder_mc._alpha = 0;
imagePlaceholder_mc.onEnterFrame = fadeIn;
Now, whenever showImage() is called, the picture loads and
properly fades in. However, the image is not correctly centered.
However, if showImage is called a second time on the same image,
THEN the image properly centers. Basically, showImage uses the last
._width and ._height values. I assume this is because the clip
hasn't finished loading when xPos and yPos are set, and that if I
had the calculations occur when the .jpg is completely loaded, then
the correct results will occur.
However, I can't seem to figure out where to put my
MovieClipLoader class, where to stick the listeners, or anything.
I'm having some sort of problem conceptualizing how the class is
supposed to work, and for some reason the tutorials are not helping
me out. If it were explained to me in relation to the code I have
above, it would help.
Thanks,
PeterCan't really explain it in terms of your code above because
it is different that your code above. The MCL just gives some nice
packaging to starting, progressing through, and ending, the load of
external assets. The listeners just listen for the different
"events" in this process and then can run certain bits of code when
those events happen.
So lets go to it. We start out well enough:
function showImage(filename:String):Void {
Then we need to make an instance of our MCL. It is also
possible to have it outside your function, but for now lets keep it
inside.
var myMCL:MovieClipLoader=new MovieClipLoader;
Next we need to make an object to attach the various events
to. There are a lot of ways they could have designed this, but this
is how they did it so that is what we do!
var myListener:Object=new Object()
Now there are several different events that the MCL might
have, but for the moment we are going to worry about only one of
them. You want to do something when the external asset is fully
loaded – you can't set the width or height until after the
whole thing is done.
myListener.onLoadInit=function(target:MovieClip){
Pos = (900 - target._width)/2;
yPos = (600 - target._height)/2;
target._x = xPos;
target._y = yPos;
target._parent._alpha = 0;
target._parent.onEnterFrame = fadeIn;
Notice how basically your same code goes in there, but with
the difference of target? (BTW, I could have called that grapefruit
or anything I wanted, but target seemed good.) That is because the
onLoadInit event returns a reference to the thing that has just had
content loaded into it. So we can use that instead of having to
hard code the names of our movie clips. That makes it a lot more
flexible.
Okay we could now issue our load, close up the braces, and be
done with it. But we still have one more thing. Let's look at what
we have. We've made a function that sets up an MCL, makes and
Object to hold listeners, and set up an event inside that object.
But we still haven't told our MCL instance that it needs to report
its events to that object.
It is a great philosophical debate of whether events happen
if there is nothing there to listen for them! :) But on the
practical side, nothing will happen if we don't tell flash to
listen for them. That is way we need the next line:
myMCL.addListener(myListener);
That tells our MCL that when it has events it needs to tell
myListener about them. Now the MCL has many events onLoadStart,
onLoadProgress, etc. and it will dutifully tell our listener object
about them. Inside that listener we have only set up an action for
one of them, but hey, laissez les bon temps rouler.
So finally we can issue our load statement and close up the
braces.
myMCL.loadClip(filename);
So what happens?
You call your function and pass it the filename.
An MCL is created.
A listener object is created.
Object is given an event handler function.
The MCL is told to report its events to that Object.
The MCL starts loading the file.
The MCL has a onStartLoad event and reports it to the object.
Nope no handler for that, nothing to do.
Several times in a row the MCL has an onLoadProgress event,
and reports it.
Nope no handler for that, nothing to do.
etc.
Finally there is an onLoadInit event – the file is
ready to be mucked with. The MCL reports it to the object, and hey
there is something to do.
So the MCL tells the objects onLoadInit function, "I just
Inited, the following clip."
The function then takes that information and applies the
things you specified.
And that is pretty much it.
A couple of notes. The onLoadProgess event doesn't happen
when you are testing locally. So you won't see it.
It is a good practice to get into that when you are done with
something you remove the listener. So you might want to add the
following line to your onLoadInit function.
myMCL.removeListener(myListener);
(At least I think that is a good idea. I haven't done that
myself in the past, but I have recently become much more aware of
how important it is – at least generally – to remove
listeners. So if you get an error just remove that.) -
Deleting/hiding a preloader and a button
Pls help - i have to figure this out before 2pm ESP today. I
purchased a flash intro template and switched out the text, images,
etc. for a colleague for an internal presentation. Here's the
problem: he wanted the intro to run twice - seemlessly - so at the
end of the first .fla file I changed the 'stop" action to a
loadMovie action. The problem is the preloader and button that is
OK when the first .swf file runs is fine but I can't figure out how
to delete it from the 2nd .swf file. (The company i bought the
template from said this modification is out of their realm...) I'm
desparate now... The .fla files are huge - but I can send a link to
show what I mean. Thanks,
LisaI solved it in this way:
package untitled24;
import javax.swing.UIManager;
import java.awt.*;
import java.io.*;
import java.awt.event.*;
public class Application1 extends Frame
private TextArea tekstgebied;
private MenuItem ok;
public Application1()
MenuBar menubalk = new MenuBar();
setMenuBar(menubalk);
Menu hoogste = new Menu("ok");
menubalk.add(hoogste);
ok = new MenuItem("test");
ok.addActionListener(new MenuHandler());
hoogste.add(ok);
tekstgebied = new TextArea();
add(tekstgebied);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
dispose();
System.exit(0);
setSize(300,200);
setTitle("oef 1");
setVisible(true);
public static void main(String[] args )
new Application1();
public class MenuHandler implements ActionListener
public void actionPerformed(ActionEvent f)
FileWriter uit;
String inhoud;
inhoud = tekstgebied.getText();
try
uit = new FileWriter("bestand.txt");
uit.write(inhoud);
uit.close();
catch (IOException e)
System.out.println("Fout bij het openen, maken of sluiten bestand");
e.printStackTrace();
} -
Using Timer and TimerTask classes in EJB's(J2EE)
Does J2EE allow us to use Timer and TimerTask classes from java.util package in SessionBean EJB's ( Statless or Statefull )?.
If J2EE does allow, I am not sure how things work in practical, Lets take simple example where a stateless SessionBean creates a Timer class
and schedules a task to be executed after 5 hours and returns. Assuming
GC kicks in many times in 5 hours, I wonder if the Timer object created by survives the GC run's so that it can execute the scheduled tasks.
My gut feeling says that the Timer Object will not survive.. Just
want to confirm that.
I will be interested to know If there are any techiniques that can make
the usage of Timer and TimeTask classes in EJB's possible as well as reliable with minmum impact on over all performance.Have a look at J2EE 1.4. I think they add a timer service for EJBs there...
Kai -
Whats the difference between an INTERFACE and a CLASS?
Whats the difference between an INTERFACE and a CLASS?
Please help.
Thanx.http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=%2Bforum%3A31&qt=Difference+between+interface+and+class
-
Page Attributes and Application Class Attributes
Hi, everyone,
I am quite new to BSP.
I have a question here:
what is the difference between page attributes and application class attributes of a bsp application? As they are both global attributes, there seems to be no big difference when we use them.
thanks a lot.
FanHi Fan,
a BSP application can be made up of many pages.
A page attribute is visible only in the page it is associated with.
Attributes of the application class are visible from every page in that application.
Cheers
Graham Robbo -
What is the difference between document class and normal class
Hi,
Please let me know what is the difference between document class and normal class.
And I have no idea which class should call as document class or call as an object.
Thanks
-Actionscript Developerthe document class is invoked immediately when your swf opens. the document class must subclass the sprite or movieclip class.
all other classes are invoked explicitly with code and need not subclass any other class. -
How to get the jar file without knowing its name and any class inside it?
Hello, everybody!
I would like to know if there's a way to get a reference programatically to the initial jar without knowing its name and any class contained in it. By "initial jar" I mean the jar that was called in the prompt, like this:
java -jar jarfile.jaror in another way, in a graphical system. To be sincere what I really want is to get a reference to the jar's manifest, but I know if I can get a reference to the jar I can get a reference to its manifest file. Or if you know a way to get the manifest directly, it would also help. So, is there a way to do this?
Thank you.
Marcosjverd wrote:
marcos_aps wrote:
abillconsl wrote:
Can you be more specific - IOW, can you cite a specific case?Absolutely. I want to access the jar in source code with the java.util.zip.JarFile class, for example.But why? You still haven't provided a use case or explained what you're trying to accomplish. As already pointed out, whatever you're trying to do, this is a brittle solution. If you explain what you're trying to accomplish with this, somebody may be able to suggest a better approach.jverd, I explained for baftos. Anyway, I will try to be more specific. I start my sytem like this, from, say, for example, jar1.jar:
import br.product.System;
public static void main(String[] args)
System.start("NameOfTheSystem");
}The System class is in util.jar, for example. This jar is used by all systems. I wouldn't like to pass in the name of the system, as above. I would like that the System class could read it from jar1.jar's manifest file. I just would like to have this:
import br.product.System;
public static void main(String[] args)
System.start();
}It is more elegant and I don't have the name of the system in two places: code and manifest file.
Marcos -
Problem in generic value copier class / reflection and generic classes
Hello experts,
I try to archive the following and am struggling for quite some time now. Can someone please give an assessment if this is possible:
I am trying to write a generic data copy method. It searches for all (parameterless) getter methods in the source object that have a corresponding setter method (with same name but prefixed by "set" instead of "get" and with exactly one parameter) in the destination object.
For each pair I found I do the following: If the param of the setter type (T2) is assignable from the return type of the getter (T1), I just assign the value. If the types are not compatible, I want to instantiate a new instance of T2, assign it via the setter, and invoke copyData recursively on the object I get from the getter (as source) and the newly created instance (as destination). The assumption is here, that the occurring source and destination objects are incompatible but have matching getter and setter names and at the leaves of the object tree, the types of the getters and setters are compatible so that the recursion ends.
The core of the problem I am struggling with is the step where I instantiate the new destination object. If T2 is a non-generic type, this is straightforward. However, imagine T1 and T2 are parametrized collections: T1 is List<T3> and T2 is List<T4>. Then I need special handling of the collection. I can easily iterate over the elements of the source List and get the types of the elements, but I can not instantiate only a generic version of the destinatino List. Further I cannot create elements of T4 and add it to the list of T2 and go into recursion, since the information that the inner type of the destination list is T4 is not available at run-time.
public class Source {
T1 getA();
setA(T1 x);
public class Dest {
T2 getA();
setA(T2 x);
public class BeanDataCopier {
public static void copyData(Object source, Object destination) {
for (Method getterMethod : sourceGetterMethods) {
... // find matching getter and setter names
Class sourceParamT = [class of return value of the getter];
Class destParamT = [class of single param of the setter];
// special handling for collections - I could use some help here
// if types are not compatible
Object destParam = destination.getClass().newInstance();
Object sourceParam = source.[invoke getter method];
copyData(sourceParam, destParam);
// usage of the method
Souce s = new Source(); // this is an example, I do not know the type of s at copying time
Dest d = new Dest(); // the same is true for d
// initialize s in a complicated way (actually JAX-B does this)
// copy values of s to d
BeanDataCopier.copyData(s, d);
// now d should have copied values from s Can you provide me with any alternative approaches to implement this "duck typing" behaviour on copying properties?
Best regards,
Patrik
PS: You might have guessed my overall use case: I am sending an object tree over a web service. On the server side, the web service operation has a deeply nested object structure as the return type. On the client side, these resulting object tree has instances not of the original classes, but of client classes generated by axis. The original and generated classes are of different types but have the identically named getter and setter methods (which again have incompatible parameter types that however have consistent names). On the client side, I want to simply create an object of the original class and have the values of the client object (including the whole object tree) copied into it.
Edited by: Patrik_Spiess on Sep 3, 2008 5:09 AMAs I understand your use case this is already supported by Axis with beanMapping [http://ws.apache.org/axis/java/user-guide.html#EncodingYourBeansTheBeanSerializer]
- Roy -
Problems using different tables for base class and derived class
I have a class named SuperProject and another class Project derived from
it. If I let SchemaTool generate the tables without specifying a "table"
extension, I get a single TABLE with all the columns from both classes and
everything works fine. But if I specify a "table" for the derived class,
SchemaTool generates the derived class with just one column (corresponds
to the attribute in derived class). Also it causes problems in using the
Project class in collection attributes.
JDO file:
<jdo>
<package name="jdo">
<class name="Project" identity-type="application"
persistence-capable-superclass="SuperProject">
<extension vendor-name="kodo" key="table" value="PROJECT"/>
</class>
<class name="SuperProject" identity-type="application"
objectid-class="ProjectId">
<field name="id" primary-key="true"/>
</class>
</package>
</jdo>
java classes:
public class Project extends SuperProject
String projectSpecific
public class SuperProject
BigDecimal id;
String name;
tables generated by SchemaTool:
TABLE SUPERPROJECTSX (IDX, JDOCLASSX, JDOLOCKX, NAMEX);
TABLE PROJECT(PROJECTSPECIFICX)
Thanks,
Justine ThomasJustine,
This will be resolved in 2.3.4, to be released later this evening.
-Patrick
In article <aofo2q$mih$[email protected]>, Justine Thomas wrote:
I have a class named SuperProject and another class Project derived from
it. If I let SchemaTool generate the tables without specifying a "table"
extension, I get a single TABLE with all the columns from both classes and
everything works fine. But if I specify a "table" for the derived class,
SchemaTool generates the derived class with just one column (corresponds
to the attribute in derived class). Also it causes problems in using the
Project class in collection attributes.
JDO file:
<jdo>
<package name="jdo">
<class name="Project" identity-type="application"
persistence-capable-superclass="SuperProject">
<extension vendor-name="kodo" key="table" value="PROJECT"/>
</class>
<class name="SuperProject" identity-type="application"
objectid-class="ProjectId">
<field name="id" primary-key="true"/>
</class>
</package>
</jdo>
java classes:
public class Project extends SuperProject
String projectSpecific
public class SuperProject
BigDecimal id;
String name;
tables generated by SchemaTool:
TABLE SUPERPROJECTSX (IDX, JDOCLASSX, JDOLOCKX, NAMEX);
TABLE PROJECT(PROJECTSPECIFICX)
Thanks,
Justine Thomas
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com -
Data class and Delivery class in ABAP Dictionary
Hi all,
I want to know the exact information about Data class and Delivery class in ABAP Dictionary
Moderator message : Search for available information. Thread locked.
Edited by: Vinod Kumar on Aug 3, 2011 1:35 PMAs your name Suggests, there were exactly 21 rajapandian already who wanted exact information about Data class and Delivery class. Fortunately some has found the information by own and some were dumped by SAP Police.
Cheers
Amit -
Hi,
Can anybody say when to use BOR object and Abap class in the task with an example.
Thanks,
MugundhanThere is no any specific condition or rule that for this purpose you need to use BOR and Class , it depends on your requirement. not only the requirement but also the new techniques to make classes not just as simple way to create objects but when you use classes in the Workflows they are not simple classes but they are BUSINESS CLASSES which makes a lot of difference.
Check the blogs of [Jocelyn Dart|https://www.sdn.sap.com/irj/scn/wiki?path=/pages/viewpage.action%3fpageid=55566]
Maybe you are looking for
-
Weak and Strongly Typed Reference Cursors in Reports
Our custom reports has been using a reference cursor. I have inherited the code and not sure why there is a need to use a reference cursor when it can be done by a simple select statements. I see no dynamic select statements passed or any special par
-
Buongiorno a tutti, premetto che utilizzo da poco il cRIO. Il mio attuale problema è questo: vorrei acquisire il segnale in arrivo dalle termocoppie collegate al modulo 9213 in tensione e tramite sviluppo polinomiale trasformarle in temperatura. St
-
I wish to download ebooks in.txt format and save them in MS Word 2013. The books are in Russian language and therefore need to be converted into cyrillic. I am now using Windows 8 and Firefox19. On my OLD system (xp) and Word 2000 I had no problems.
-
I am having trouble with my contacts list. Have copied all contacts from SIM to phone and vice versa, but approximately 100 of my contacts are missing from list (Yes, I have phone and SIM memory selected.) The contacts must be somewhere though, as wh
-
my new laptop picks up the signal from the router and says the connection is "excellant", yet when I test the connection, it says it cannot find one and that windows cannot identify the problem. I know for a fact that this is a router problem and not