What error are you getting?

On 7/10/12 4:50 AM, "ZIONIST" <stinas...@yahoo.com> wrote:






Hi guys am trying to follow this example 
http://nightlycoding.com/index.php/2011/05/flex-preloader-with-greensock-tweenlite-and-tweenmax/
 to create the same preloader but am getting so many errors. Below is my code 
please advise where am going wrong.

"CustomPreloader.as"

package preloader
{

import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;

import mx.events.FlexEvent;
import mx.events.RSLEvent;
import mx.preloaders.DownloadProgressBar;


public class CustomPreloader extends DownloadProgressBar
{

[Embed(source="/assets/talking.png")]

private var FlashPreloaderSymbol1:Class;

[Embed(source="/assets/film.png")]

private var FlashPreloaderSymbol2:Class;

[Embed(source="/assets/production.png")]

private var FlashPreloaderSymbol3:Class;


private var clip;

private var clip2;

private var clip3;

public function CustomPreloader()
{

super();

//getting the images into the loader

clip=new FlashPreloaderSymbol1();

clip2=new FlashPreloaderSymbol2();

clip3=new FlashPreloaderSymbol3();


//Adding images to stage

addChild(clip);

addChild(clip2);

addChild(clip3);

}

private var _preloader:Sprite;

public override function set preloader(value:Sprite):void
{

_preloader = value;

//Center the images

centerPreloader();

// runtime shared library

value.addEventListener(RSLEvent.RSL_PROGRESS, onRSLDownloadProgress);

value.addEventListener(RSLEvent.RSL_COMPLETE, onRSLDownloadComplete);

//preloader.addEventListener(RSLEvent.RSL_ERROR, onRSLError);

// application

value.addEventListener(ProgressEvent.PROGRESS, onSWFDownloadProgress);

value.addEventListener(Event.COMPLETE, onSWFDownloadComplete);

// initialization

value.addEventListener(FlexEvent.INIT_PROGRESS, onFlexInitProgress);

value.addEventListener(FlexEvent.INIT_COMPLETE, onFlexInitComplete);

}

private function onRSLDownloadProgress(event:ProgressEvent):void
{

isRslDownloading=true;

rslBytesTotal=event.bytesTotal;

rslBytesLoaded=event.bytesLoaded;

rslPercent=Math.round((rslBytesLoaded / rslBytesTotal) * 100);

updateProgress();

}

private function onRSLDownloadComplete(event:RSLEvent):void
{

// We tween the color of the first image into an green tint, also adding a 
little blur to make it more impressive

TweenMax.to(clip, 2, {tint: 0xA3F40E, glowFilter: {color: 0xA3F40E, alpha: 1, 
blurX: 10, blurY: 10}});

rslPercent=100;

}

private function onSWFDownloadProgress(event:ProgressEvent):void
{

swfBytesTotal=event.bytesTotal;

swfBytesLoaded=event.bytesLoaded;



if (isRslDownloading)
{

// as soon as RSL starts downloading the SWF data are added by the RSL values

swfBytesTotal-=rslBytesTotal;

swfBytesLoaded-=rslBytesLoaded;

}

swfPercent=Math.round((swfBytesLoaded / swfBytesTotal) * 100);

updateProgress();

}

private function onSWFDownloadComplete(event:Event):void
{

//Now tweening the second image (remember we can have as much as we want)

TweenMax.to(clip2, 2, {tint: 0xA3F40E, glowFilter: {color: 0xA3F40E, alpha: 1, 
blurX: 10, blurY: 10}});

swfPercent=100;

}

private function onFlexInitComplete(event:FlexEvent):void
{

//Tweening the last image and onComplete we launch the application, we do this 
to make sure it the effect will play

var myTween:TweenMax=TweenMax.to(clip3, 1, {tint: 0xA3F40E, glowFilter: {color: 
0xA3F40E, alpha: 1, blurX: 10, blurY: 10}});

myTween.addEventListener(Event.COMPLETE, onDoneAnimating);

}

private function onDoneAnimating(e):void
{

// The final event is dispatched. The application will now load.

dispatchEvent(new Event(Event.COMPLETE));

}

}
}






--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui

Reply via email to