You must be logged in to post Login Register
Search 

preloader between pages

User Post

1:56 am
October 11, 2009


attila

New Member

posts 1

1

hi ! Got a little problem here : I've seen thousands of tutorials explaining preloaders, but none that explain how to put them into an already made site, between the pages (external SWF pages, called by buttons on stage). I'm desperate ! Thanks for any help…  

4:53 pm
February 2, 2010


Inter-Reality

Member

Netherlands

posts 8

2

Hi attila,

Surely thou eyes have tricked you!

Each button will need an extra instruction:

for instance:

button1.addEventListener (mouseEvent.CLICK, getPage);

function getPage(e:Event):void {

LoadPagePrloaded(“target.swf”, 0, 0); //this is a preload function I am about to explain

}

//the preload function covers all areas…except errorhandling.

function LoadPagePrloaded(targetSwf:String, xPos:Number, yPos:Number)

{

function startLoad()
{
var sLoader:Loader = new Loader();
var sRequest:URLRequest = new URLRequest(targetSwf); //this is where you reference the targetswf in the button eventlistener function
sLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
sLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, busyLoading);
sLoader.load(mRequest);
}

function swfLoaded(loadedSwf:Event)
{
addChild(loadedSwf.currentTarget.content);
}

function busyLoading (swfProg:ProgressEvent)
{
var percent:Number = swfProg.bytesLoaded/swfProg.bytesTotal;
trace(percent);
//you could animate a preloader here
}

startLoad(); //this starts your instruction to load the file you requested under the button.

}

I did not explain the xPos and yPos but generally speaking if you where to load an external file into a movieclip then you could adjust the movieClip position by changing:

function swfLoaded(loadedSwf:Event)
{
addChild(loadedSwf.currentTarget.content);
}

to

function swfLoaded(loadedSwf:Event)
{
var mySwfHolder:MovieClip = new MovieClip;
addChild(mySwfHolder);
mySwfHolder.addChild(loadedSwf.currentTarget.content);

mySwfHolder.x = xPos;
mySwfHolder.y = yPos;

//pretty neat huh?

}

For the words you place on a pad are the codes we all shall read!

Happy coding!

Cool


Inter-Reality – the true art of coding http://www.inter-reality.nl

3:50 am
March 29, 2010


artlass

New Member

posts 1

3

Hi, another Atila here,

when implementing your code I recieve a syntax error 1093 for the line


LoadPagePrloaded(“target.swf”, 0, 0);


any idea why?


tanks

5:36 am
March 29, 2010


Inter-Reality

Member

Netherlands

posts 8

4

hi artlas,

seeing that i can not see the code usage you used for implementation i would like to suggest that if using #include – please don't. Futher more I just reran the script posted above and the quotation marks seemed to be weird in my actionscript panel. It is possible this is causing the error.  After changing the quotation marks it seems to work. Would you want me to set up a class file so you can call the class for dynamic usage?

let me know.


Each bit of information will give me a byte of knowledge.


Happy coding!

Cool

Inter-Reality – the true art of coding http://www.inter-reality.nl

Topic RSS 
Search