ActionScript 3.0 :: How To Pass XML From Preloader To Main SWF
Nov 22, 2009
I have been trying to figure out the following:
main.swf - contains my photo gallery application
preloader.swf - loads the main.swf file and on COMPLETE event displays it
At the moment the gallery list is in the XML file and the XML file is loaded from the main.swf file. However, as the XML file will grow, I want to preload the XML file along with main.swf file in the preloader.swf and then pass the XML data to the main.swf file so that main.swf file can use this XML data and can create the galleries from there. I am using AS3 Project in Flex Builder 3.
I have a main preloader that loads Main.swf. Within Main.swf the user can open up other sub swfs, but they all need a preloader too. I have this all working for one sub swf, but I don't want to make 17 sub swf preloaders, and am wondering how I can - based on the button on stage pushed - pass along to the ONE sub preloader which sub swf to preload...
Is it possible to pass a variable between different swfs?Here's what I have now[code]...
Does anyone know how to pass a "page" variable thorugh link to a main .swf file (index.swf)? The file would normally load "home.swf" into it if accessed by But I would like to able link to a different .swf determind by a varible like "page = contact.swf"
I would like to track the customer experience in downloading and initializing my flex app.
(a) Is there a way to pass data from preloader to the application? I would like to pass the time it takes to download and the time it takes to initialize.
(b)Alternatively: Is there an event at the application level that corresponds to the preloader events:
1. Download complete
2. Initialization complete (same as Application creationComplete)
I know this has been covered, I've read every post on this forum but I just can't make sense of it. I would like to pass a string variable from a preloader swf to the loaded one. My code's on the first frame on the timeline on both swfs and I'm not using classes. Here's my code for the preloader:
I have a main swf that loads different swfs files, one of this swf files is the homepage with navigation items, how can I pass a reference to the loaded home.swf of the main.swf which contains the load methods?
I try creating a var in the home.swf class with the main.swf class type, but the home.swf give me errors that cant find other objects contains in the main.swf
Im trying to pass a number to 1 function in my .as... In 1 part of my project i want to sent a number to .as function, and in another part i want to receive another value... like this.... The sintax is wrong, but i think i can made myself easier to understand...
Im trying to pass a number to 1 function in my .as...
In 1 part of my project i want to sent a number to .as function, and in another part i want to receive another value...
like this....
The sintax is wrong, but i think i can made myself easier to understand...
----------------------------------------------------------------------- In this part i want to send a value to my .as function... Ultimo(var int guardaultimo = 1);
I have a document with main class.I also have some movieclips which have their own class and functions.I am trying to pass a variable from my main class to one of these MovieClips.I tried some stuff, nothing worked.
In Flash CSn/AS3 you associate a Main class with a flash file which when loaded in the flash player "automatically creates an instance of the program's main class."I'd like to know how to pass arguments to the main class, since you don't write it yourself (you put its name in the Document textfield in the IDE).
I have a program that uses a document class. The preloader.swf calls the main.swf. Problem is, the main swf uses FlashVars to set certain parameters. If I use preloader.swf to load the main.swf, FlashVars will no longer work.
So I need some way for preloader.swf to pass the FlashVars to the rest of the program.
I've got a main.as that loads SWF to the stage. the loaded SWF seppoused to pass a link to the main.as and trigger a javascript function to popUp that photo from that link.
I know there are two ways:
((root as MovieClip).parent.parent as Object).somefunction(parameters);
and to dispatch an event. inorder to pass parameters throug the event i need to extend it with another class.
isnt the (root as... ) more efficient if all i need is to pass a link?
In "my actionscript theory", I'm supposed to see a circle that follows the mouse when I click it. (The draggable is not fully implemented) But the circle doesn't even budge .how to access the main class's stage property. I've googled for it, but still no progress.
I have just started to work in AS3 and stuck in a problem. I have created a fla document named main.fla I have defined the document class as Main which is attached. The problem is preloader shows only when the file is completely loaded. How can I appear the progress preloader for the main file.
I'm using the sample external preloader file supplied with CS5 as the basis for my customised pre-loader. It's working fine except that once the main site has loaded and is open, the preloader remains loaded in the background.[code]...
I'm using a preloader SWF to load my content SWF and XML file, and when the COMPLETE event fires I'm using the following code to send my XML data to the content SWF -ActionScript Code:evt.target.content.sendXML(XMLData);I then have a sendXML function in the content SWF that picks up the data.This works - but I can't access XMLData right away (it's null if I trace it). But if I set up a timer with a tiny delay which then checks XMLData, the information is there.It seems to be a bit of a dumb way to do things. Has anoyone else got a better solution or a way that will allow access to the variable right away?
I need to preload 2 external .swfs, one containing animation and one containing sound, and I need them to start playing at the same time. As of now I have a general preloader on the main timeline, but as you might expect, after the preloader finishes, there is a lag while the .swf's are being loaded. I thought everything was solved, until a friend of mine looked at it in dial-up, and the preloader just kept looping 10 times before the animation started, so now I'm starting over. Part of my complication I believe is that I'm using loadMovieNum into levels as opposed to loading the external .swf's in a separate container MC (that's what I've noticed most people recommend for this problem), but I tried doing that technique several times with no luck. Right now my main movie, index.fla, has a preloader MC in the first frame, with this AS attached to the clip:
Code: onClipEvent (enterFrame) { loading = _parent.getBytesLoaded(); total = _parent.getBytesTotal(); percent -= (percent-((loading/total)*100))*.25; per = int(percent); [Code] .....
The clip contains a loadbar, static text (which just says 'Loading'), dynamic text (which tells the percentage), and a 'stop' in the actions layer. In the actions layer within my main movie, there is a 'stop' on the first frame as well. On the second frame, there is this AS: Code: var audioOn = false; loadMovieNum("musicfile.swf", 1); loadMovieNum("1movie.swf", 2); stop();
In order that the animation and music starts at the same time, within my animation .swf (1movie.swf), I have this AS on the first frame of the actions layer: Code: if (_level0.audioOn == true) { gotoAndPlay(2); }
Within my musicfile.swf, there is this AS on the second frame of the mp3: Code: _level0.audioOn = true; My main objective is to be able to use my preloader to preload both of these .swf's concurrently in my main movie so that they may start at the same time.
I have an External Swf with its own Preloader that is loaded into my Main swf,It works fine when i am testing it in Macromedia Flash 8 However when i upload all of it to my site and i click the button that loads the External swf in to my main swf it loads the hole main swf again and not the external swf. (NOTE i load the external swf into a MC ''myContainer2'' on the main swf) Here are my codes:
I have a movieClip named MC, and it's enabled with action script, with the class name MC_Rectangle and a Stage.I override the MC_Rectangle class file in a mc_rectangle.as external file.here is the code:
1. how can i access the variable "sequence" in "mc_rect"
2. how can i pass parametre from main stage to mc_rect via function setSequence(data:int)?
3. how can i call the function in addSequence() in mc_rect.
in asp.net, i usually use mc_rect.sequenct,mc_rect.setSequence(data), mc_rect.addSequence() to achieve my goals......btw, can function in mc_rect return out result to main stage?
this is how i attached the sound in the main swf, im using AS2
Code: var x:Sound = new Sound(); x.attachSound("soundtracky"); x.stop(); x.start(0, 0);
I used the loader and the progress bar components.
The loader loads the main swf fine but the music doesnt play like this.
if I preview the main swf the music plays but with the loader it doesnt.
my first attempt worked with the preloader but by inserting the mp3 straight in the timeline.. I cant use it like this because I also need a mute button and I didnt find a solution.
My external swfs are taking 8-10 secs gap in loading inside main swf, that's why i want to load my external swfs with dynamic content at the same time when my main swf loads.
Code of preloader
Code on 1st frame: onClipEvent (load) { total = _root.getBytesTotal(); }
I have a full flash website which is broken down into:
- Main movie which contains navigation and interface components
- Several content movies which are loaded into the main movie on demand
- An intro movie which is around 3MB in size; its a full CG movie.
At the moment the main movie preloads and then the intro movie preloads afterwards in a sequence; like so:
Main Movie > Intro Movie > Content Loads
There is a skip intro option which will skip the intro movie step and jump right to the content load once the main movie has loaded.
My client wants me to do something which is proving very difficult and I am starting to wonder if its even possible as searches on the net have given results which don't really work properly.
Here is what I need to do:
When the main movie is requested, its preloader appears which it has a load bar and a "skip intro" button. The difference being, this preloader will be loading the main movie AND the preloader; which the load bar representing both movies load progress.
To complicate matters, if the skip intro button is pressed, the preloader needs to drop the intro movie from the equation and just account for the main movie & thus skip the intro; straight to the content.
The way I have tried to do it is to have a preloader code in the intro which sends the total size and bytesloaded back to the main movie which deals with those values, adding it onto its own size. This is proving cumbersome and although appeared to be working, isn't working propery.
I'm trying to set up a preloader to show the load progress of the main swf, which has all of it's assets embedded. I found the factory class method as described on bit-101, but no load progress ever seems to show. The swf loads fine, but the bytesLoaded is always equal to bytesTotal and therefore the preloader is never called.
[Code]...
This correctly calls the Factory class first, and then instansiates Main and calls init(). But as I mentioned above the preloading is never shown as it seems to be loading everything straight away.Is this a problem with the way I'm embedding the images or because I'm testing locally?