PDA

View Full Version : loop this how the F....



Psyme
February 20th, 2009, 10:32 AM
how do i loop this mess after it finishes . it also contains a looping flv video plus a song .

And would be nice if some genius out there could tell me to boil all this ****e down - but first of all i like to know how to loop it - loop it All ?

best regards psyme



import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import fl.transitions.*;


stop();
var AWARD1:award1 = new award1;
var AWARD2:award2 = new award2;
var AWARD3:award3 = new award3;
var AWARD4:award4 = new award4;
var AWARD5:award5 = new award5;
var AWARD6:award6 = new award6;
var REVIEWS1:reviews1 = new reviews1;
var REVIEWS2:reviews2 = new reviews2;
var REVIEWS3:reviews3 = new reviews3;
var PICTURECAST:pictureCast = new pictureCast;
var GOLDEN:golden = new golden;
var MASKED:masked = new masked;
addChild(PICTURECAST);
addChild(GOLDEN);
addChild(MASKED);
setChildIndex(MASKED,6);
MASKED.x = 728.3;
MASKED.y= 90.3 ;
PICTURECAST.x = 651;
PICTURECAST.y = 120;
GOLDEN.x = 396.9;
GOLDEN.y = 35.7;
var JOHN:john = new john;
var JON:jon = new jon;
var MOSS:moss = new moss;
var myTween3:Tween = new Tween(MASKED, "x",Strong.easeOut, 728.3, 1395.3, 6, true);
myTween3.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished3);
function transitionFinished3(e:TweenEvent):void {
var myTween4:Tween = new Tween(MASKED, "x",Strong.easeOut, 1395.3, 728.3, 4, true);
myTween4.removeEventListener(TweenEvent.MOTION_STO P,transitionFinished3);
removeChild(PICTURECAST);
removeChild(GOLDEN);
myTween3.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished5);
function transitionFinished5(e:TweenEvent):void {
removeChild(MASKED);
}
myTween4.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished);
function transitionFinished(e:TweenEvent):void {

var myInterval:Number=setInterval(setTween,0);
function setTween():void {
addChild(REVIEWS1);
REVIEWS1.x = 601.3 ;
REVIEWS1.y = 37;
clearInterval(myInterval);
TransitionManager.start(REVIEWS1, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
var myInterval1:Number=setInterval(setTween1,1000);
function setTween1():void {
addChild(REVIEWS2);
REVIEWS2.x = 597.3 ;
REVIEWS2.y = 89.3 ;
clearInterval(myInterval1);
TransitionManager.start(REVIEWS2, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
var myInterval2:Number=setInterval(setTween2,2000);
function setTween2():void {
addChild(REVIEWS3);
REVIEWS3.x = 608.3 ;
REVIEWS3.y = 139.3 ;
clearInterval(myInterval2);
TransitionManager.start(REVIEWS3, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
}
myTween4.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinishedn);
function transitionFinishedn(e:TweenEvent):void {

}
var myInterval:Number=setInterval(setTweenaw,10000);
function setTweenaw():void {
addChild(AWARD1);
AWARD1.x = 434.5 ;
AWARD1.y = 29.6;
clearInterval(myInterval);
TransitionManager.start(AWARD1, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});
removeChild(REVIEWS1);
removeChild(REVIEWS2);
removeChild(REVIEWS3);

var myInterval12:Number=setInterval(setTween12,300);
function setTween12():void {
addChild(AWARD2);
AWARD2.x = 663.8 ;
AWARD2.y = 71.5 ;
clearInterval(myInterval12);
TransitionManager.start(AWARD2, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval13:Number=setInterval(setTween13,400);
function setTween13():void {
addChild(AWARD3);
AWARD3.x = 884.8 ;
AWARD3.y = 71.5 ;
clearInterval(myInterval13);
TransitionManager.start(AWARD3, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});


var myInterval14:Number=setInterval(setTween14,500);
function setTween14():void {
addChild(AWARD4);
AWARD4.x = 370.6 ;
AWARD4.y = 136.3 ;
clearInterval(myInterval14);
TransitionManager.start(AWARD4, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval15:Number=setInterval(setTween15,600);
function setTween15():void {
addChild(AWARD5);
AWARD5.x = 662.8 ;
AWARD5.y = 159.5 ;
clearInterval(myInterval15);
TransitionManager.start(AWARD5, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval16:Number=setInterval(setTween16,700);
function setTween16():void {
addChild(AWARD6);
AWARD6.x = 886.8 ;
AWARD6.y = 159.5 ;
clearInterval(myInterval16);
TransitionManager.start(AWARD6, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myIntervalN:Number=setInterval(setTweenawN,5000);
function setTweenawN():void {
removeChild(AWARD1);
removeChild(AWARD2);
removeChild(AWARD3);
removeChild(AWARD4);
removeChild(AWARD5);
removeChild(AWARD6);

clearInterval(myIntervalN);
var MASK1:mask1 = new mask1;
var myInterval17:Number=setInterval(setTween17,1);
function setTween17():void {
addChild(MASK1);
addChild(PICTURECAST);
MASK1.x = 728.3 ;
MASK1.y = 90.3 ;
PICTURECAST.x = 598 ;
PICTURECAST.y = 96 ;

TransitionManager.start(PICTURECAST, {type:Blinds, direction:Transition.IN, duration:1, easing:None.easeNone,numStrips:30, dimension:0});
clearInterval(myInterval17);
var myInterval18:Number=setInterval(setTween18,1);
function setTween18():void {
addChild(MOSS);
addChild(JON);
addChild(JOHN);
JOHN.x = 367.4;
JOHN.y = -2.4;
JON.x = 528.6;
JON.y = -2.4;
MOSS.x = 688.5;
MOSS.y = -2.4;
clearInterval(myInterval18);
var myInterval19:Number=setInterval(setTween19,3500);
function setTween19():void {
var BG:bg = new bg;
removeChild(MOSS);
removeChild(JON);
removeChild(JOHN);
removeChild(PICTURECAST);
addChild(BG);
BG.x = 465 ;
BG.y = 90 ;
TransitionManager.start(BG, {type:Wipe, direction:Transition.IN, duration:1, easing:None.easeNone,startPoint:1});
clearInterval(myInterval19);


var myInterva20:Number=setInterval(setTween20,3500);
function setTween20():void {
removeChild(BG);
clearInterval(myInterva20);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);

}
}
}
}
}
}
}
}
}
}
}
}
}

e_owen
February 20th, 2009, 12:56 PM
First of all, lets post any Actionscript inside the
tag so that it is legible...
[code]
ActionScript Code:

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import fl.transitions.*;


stop();
var AWARD1:award1 = new award1;
var AWARD2:award2 = new award2;
var AWARD3:award3 = new award3;
var AWARD4:award4 = new award4;
var AWARD5:award5 = new award5;
var AWARD6:award6 = new award6;
var REVIEWS1:reviews1 = new reviews1;
var REVIEWS2:reviews2 = new reviews2;
var REVIEWS3:reviews3 = new reviews3;
var PICTURECAST:pictureCast = new pictureCast;
var GOLDEN:golden = new golden;
var MASKED:masked = new masked;
addChild(PICTURECAST);
addChild(GOLDEN);
addChild(MASKED);
setChildIndex(MASKED,6);
MASKED.x = 728.3;
MASKED.y= 90.3 ;
PICTURECAST.x = 651;
PICTURECAST.y = 120;
GOLDEN.x = 396.9;
GOLDEN.y = 35.7;
var JOHN:john = new john;
var JON:jon = new jon;
var MOSS:moss = new moss;
var myTween3:Tween = new Tween(MASKED, "x",Strong.easeOut, 728.3, 1395.3, 6, true);
myTween3.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished3);
function transitionFinished3(e:TweenEvent):void {
var myTween4:Tween = new Tween(MASKED, "x",Strong.easeOut, 1395.3, 728.3, 4, true);
myTween4.removeEventListener(TweenEvent.MOTION_STO P,transitionFinished3);
removeChild(PICTURECAST);
removeChild(GOLDEN);
myTween3.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished5);
function transitionFinished5(e:TweenEvent):void {
removeChild(MASKED);
}
myTween4.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinished);
function transitionFinished(e:TweenEvent):void {

var myInterval:Number=setInterval(setTween,0);
function setTween():void {
addChild(REVIEWS1);
REVIEWS1.x = 601.3 ;
REVIEWS1.y = 37;
clearInterval(myInterval);
TransitionManager.start(REVIEWS1, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
var myInterval1:Number=setInterval(setTween1,1000);
function setTween1():void {
addChild(REVIEWS2);
REVIEWS2.x = 597.3 ;
REVIEWS2.y = 89.3 ;
clearInterval(myInterval1);
TransitionManager.start(REVIEWS2, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
var myInterval2:Number=setInterval(setTween2,2000);
function setTween2():void {
addChild(REVIEWS3);
REVIEWS3.x = 608.3 ;
REVIEWS3.y = 139.3 ;
clearInterval(myInterval2);
TransitionManager.start(REVIEWS3, {type:Iris, direction:Transition.IN, duration:4, easing:Strong.easeOut});
}
}
myTween4.addEventListener(TweenEvent.MOTION_FINISH ,transitionFinishedn);
function transitionFinishedn(e:TweenEvent):void {

}
var myInterval:Number=setInterval(setTweenaw,10000);
function setTweenaw():void {
addChild(AWARD1);
AWARD1.x = 434.5 ;
AWARD1.y = 29.6;
clearInterval(myInterval);
TransitionManager.start(AWARD1, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});
removeChild(REVIEWS1);
removeChild(REVIEWS2);
removeChild(REVIEWS3);

var myInterval12:Number=setInterval(setTween12,300);
function setTween12():void {
addChild(AWARD2);
AWARD2.x = 663.8 ;
AWARD2.y = 71.5 ;
clearInterval(myInterval12);
TransitionManager.start(AWARD2, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval13:Number=setInterval(setTween13,400);
function setTween13():void {
addChild(AWARD3);
AWARD3.x = 884.8 ;
AWARD3.y = 71.5 ;
clearInterval(myInterval13);
TransitionManager.start(AWARD3, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});


var myInterval14:Number=setInterval(setTween14,500);
function setTween14():void {
addChild(AWARD4);
AWARD4.x = 370.6 ;
AWARD4.y = 136.3 ;
clearInterval(myInterval14);
TransitionManager.start(AWARD4, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval15:Number=setInterval(setTween15,600);
function setTween15():void {
addChild(AWARD5);
AWARD5.x = 662.8 ;
AWARD5.y = 159.5 ;
clearInterval(myInterval15);
TransitionManager.start(AWARD5, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myInterval16:Number=setInterval(setTween16,700);
function setTween16():void {
addChild(AWARD6);
AWARD6.x = 886.8 ;
AWARD6.y = 159.5 ;
clearInterval(myInterval16);
TransitionManager.start(AWARD6, {type:PixelDissolve, direction:Transition.IN, duration:2, easing:Strong.easeOut,xSections:100, ySections:100});

var myIntervalN:Number=setInterval(setTweenawN,5000);
function setTweenawN():void {
removeChild(AWARD1);
removeChild(AWARD2);
removeChild(AWARD3);
removeChild(AWARD4);
removeChild(AWARD5);
removeChild(AWARD6);

clearInterval(myIntervalN);
var MASK1:mask1 = new mask1;
var myInterval17:Number=setInterval(setTween17,1);
function setTween17():void {
addChild(MASK1);
addChild(PICTURECAST);
MASK1.x = 728.3 ;
MASK1.y = 90.3 ;
PICTURECAST.x = 598 ;
PICTURECAST.y = 96 ;

TransitionManager.start(PICTURECAST, {type:Blinds, direction:Transition.IN, duration:1, easing:None.easeNone,numStrips:30, dimension:0});
clearInterval(myInterval17);
var myInterval18:Number=setInterval(setTween18,1);
function setTween18():void {
addChild(MOSS);
addChild(JON);
addChild(JOHN);
JOHN.x = 367.4;
JOHN.y = -2.4;
JON.x = 528.6;
JON.y = -2.4;
MOSS.x = 688.5;
MOSS.y = -2.4;
clearInterval(myInterval18);
var myInterval19:Number=setInterval(setTween19,3500);
function setTween19():void {
var BG:bg = new bg;
removeChild(MOSS);
removeChild(JON);
removeChild(JOHN);
removeChild(PICTURECAST);
addChild(BG);
BG.x = 465 ;
BG.y = 90 ;
TransitionManager.start(BG, {type:Wipe, direction:Transition.IN, duration:1, easing:None.easeNone,startPoint:1});
clearInterval(myInterval19);


var myInterva20:Number=setInterval(setTween20,3500);
function setTween20():void {
removeChild(BG);
clearInterval(myInterva20);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);

}
}
}
}
}
}
}
}
}
}
}
}
}





Now, just to be clear it sounds like you want to build a much more modular function that will handle the functionality in order? The below is a bit of a mess, I would write a funtion and pass in the elements you want to modify when you call it...

and to write a loop, you do the following



ActionScript Code:

var noOfLoops:int = 20; // number of times to run the loop
for (var i:int = 0; i < 20; i++)
{

trace (i); // will output 0 - 19
}

Psyme
February 21st, 2009, 06:19 AM
ty so much for your reply - "I would write a funtion and pass in the elements you want to modify when you call it..." <---- Got to look into that

I'm making a banner for a film company where I work - they promote their films on 8 different sites (in my banner) - b4 I did more then one frame movies - now i keep to one frame. so till I get a hang of the new coding style it is messy.

well... the looping it say 20 times ? - I like it to be infinty since its on a site - how do i do that ?

thankful for your reply already - I'm not hoping I'm sqeezing the lemon too much X)

Psyme
February 21st, 2009, 06:25 AM
erm... ****e - i cant get it to work . after the banner finishes It just finishes... any idea ?

snickelfritz
February 21st, 2009, 11:12 AM
There are numerous violations of AS3 best practices and naming conventions in your script.
(these are probably not causing errors per se, but they do make your script far more difficult to evaluate)
for example:
var AWARD1:award1 = new award1;

should probably be something more like:
var a1:Award1 = new Award1;

You are using "setInterval" and "clearInterval" in your AS3 script.
This has been replaced with the Timer class.

The function "loop" is called in the following eventlistener, but the function does not exist.
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);

The cascading functions nested in "setTweenaw()" seems like it would be potentially problematic.
My first impression is that you are attempting to simulate a switch statement or something to that effect.

Overall, I think your problem is mostly the apparent commingling of AS2 and AS3 methods.
Also, change the naming convention to conform to AS3 best practices; it'll be far easier for others to read the script.
A few examples:
STATIC_CONSTANT is all caps.
Classes are capitalized.
instanceNames and variables usually begin with lowercase alpha character.

Looping the script is as simple as using a recursive function call (function calling itself), but I think you need to simplify the script first.

Psyme
February 22nd, 2009, 07:34 AM
ty for your advices - its really appriciated - though it dosen't get me closer right now and here - to get the dang actionscript to loop :( - and since the deadline is soon I'm desperate for a solution.