Hey again,
i can´t figure out my problems on hijacking to have a custom animation beforePreload.
I have a simple preloader (created on runtime over Preloader.as,PreloaderScaffold.as)
In my PreloaderScaffold where i have my code for all Preloader Graphics and the entire
Animation Process of the Preloader (scaling bar) i would like to add my custom animation
MovieClip
before preloadingNow i added the following:
/*****************************************************************************************************
* Gaia Framework for Adobe Flash ©2007-2009
* Author: Steven Sacks
*
* blog: http://www.stevensacks.net/
* forum: http://www.gaiaflashframework.com/forum/
* wiki: http://www.gaiaflashframework.com/wiki/
*
* By using the Gaia Framework, you agree to keep the above contact information in the source code.
*
* Gaia Framework for Adobe Flash is released under the GPL License:
* http://www.opensource.org/licenses/gpl-2.0.php
*****************************************************************************************************/
package pages
{
import com.gaiaframework.templates.AbstractPreloader;
import com.gaiaframework.api.Gaia;
import com.gaiaframework.events.*;
import com.greensock.TweenMax;
import com.pcthomatos.utilities.SpriteRegPoint;
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import com.flinq.ScrollingLetter;
public class BarPreloader extends Sprite
{
public var bar:Sprite = new Sprite ;
private var releaseGaia:Function = Gaia.api.beforePreload(onBeforePreload,true);
public function BarPreloader()
{
super();
alpha = 1;
bar.scaleX = 0;
visible = false;
mouseEnabled = mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
}
private function onBeforePreload(e:GaiaEvent):void
{
// Here i would like to add a instance of ScrollingLetter before the Preloader Starts
var _scroll:ScrollingLetter = new ScrollingLetter ;
addChild(_scroll);
// This is just for timing, it should give my ScrollingLetter instance 3 seconds until the entire preloader comes in and everything resumes
TweenMax.delayedCall(3, releaseGaia);
}
private function onAddedToStage(event:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
stage.addEventListener(Event.RESIZE,onResize);
onResize();
}
public function transitionIn():void
{
TweenMax.to(this,.1,{autoAlpha:1});
//Create the entire Process Bar updating preloading process;
bar.graphics.beginFill(0x000000,1);
bar.graphics.drawRect(0,0,stage.stageWidth,3);
bar.graphics.endFill();
addChild(bar);
}
public function transitionOut():void
{
TweenMax.to(this,.1,{autoAlpha:0});
}
public function onProgress(event:AssetEvent):void
{
// if bytes, don't show if loaded = 0, if not bytes, don't show if perc = 0
// the reason is because all the files might already be loaded so no need to show preloader
visible = event.bytes ? event.loaded > 0:event.perc > 0;
// progress bar scale times percentage (0-1)
bar.scaleX = event.perc;
}
private function onResize(event:Event=null):void
{
x = Gaia.api.getWidth() - width / 2;
y = Gaia.api.getHeight() - height / 2;
}
}
}
So i think i do something wrong here:
private function onBeforePreload(e:GaiaEvent):void
{
// Here i would like to add a instance of ScrollingLetter before the Preloader Starts
var _scroll:ScrollingLetter = new ScrollingLetter ;
addChild(_scroll);
// This is just for timing, it should give my ScrollingLetter instance 3 seconds until the entire preloader comes in and everything resumes
TweenMax.delayedCall(3, releaseGaia);
}
delayedCall is working, it waits to continues with the flow for 3 seconds. But my display list object is not
visible to the stage And i don´t get it why it´s not visible.
This is actually the same problem i have with tweening any stuff here on TweenMax.to() and trying to releaseGaia
with the onComplete() method in my onBeforePreload function. And i wonder why i can have a
TweenMax.delayedCall(time, releaseGaia) but everything else like adding something, tweening it, fails.
Its only visible when everything resumes, but i want a hijacker to make it visible
before it resumes