PDA

View Full Version : Preloader to 2nd Frame of another swf



jjdelv
March 29th, 2009, 09:09 AM
I am just wondering if anyone knows how to make it so my preloader takes me to frame 2 of the main page rather than frame 1. I have added my code below. Basically I just want it to take me to frame 2 of main.swf (which is in a separate swf to 'main.swf'). Is there a simple way to do this?

[is there for example a way to insert a gotoAndPlay which deletes itself after its first use at the beginning of frame 1 in main.swf... just an idea!]

I need this really badly so THANK YOU SO MUCH to anyone who can help me out...



var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent .PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLET E, done);
l.load(new URLRequest("main.swf"));

function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
TweenMax.to(preFrame, 0, {alpha:0});
TweenMax.to(preFrame, 0, {x:298.0, y:-152.0});
TweenMax.to(percentage, 0, {x:298.0, y:-152.0});

}

import gs.TweenMax;

cinicoTHC
March 29th, 2009, 11:41 AM
I would use a Localconnection

In the caller:
var toMainSWFLC:LocalConnection = new LocalConnection();
toMainSWFLC.send("MyConnection","moveToFrame", 2);

in main.swf (in frame 1)

var toMainSWFLC:LocalConnection = new LocalConnection();
avm2LC.connect("MyConnection");

avm2LC.moveToFrame = function (frameToGo:Number):Void {
gotoAndPlay(frameToGo);
}


* NOTE: Void if AS1-2 / void fi AS3
not very expert but for me it works.

Bye