Hi all,
SO finally after a long time strungeling and searching Kirupa forum I have managed to more or less get my presentation working. I want to use my flash movie as a presentation and ofcourse as a learning as3 project.
When previewing the movie and you start clicking the movie you notice that it bugs alot, sometimes images dissapear or the movie get stuck somehow. I can not figure out why, I remove all my eventlisteners on time and get them back again when is needed…I hope somebody can tell me why it behaves like that…
Thanks
p.s. the images are still rubbish, but thats for later when in runs smooth:top_hat:
I know it’s a bunch text, but still I hope someone can figure it out…
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.xml.XMLDocument;
import fl.transitions.TweenEvent;
var Num:Number;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("dataXML.xml"));
var home:MovieClip = this;
var container:MovieClip;
var geklikt:String;
var counter:Number = 0;
var counter2:Number = 0;
var s:Object;
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
var list:XMLList = xmlData.snipper;
Num = list.length();
for(var i:Number = 0; i<Num;i++){
container = new Container();
container.name = "snipper"+ i;
container.addEventListener(MouseEvent.CLICK, onClick);
container.buttonMode = true;
container.Tekst.text = list*.@snippertekst;
var l:Loader = new Loader();
l.load(new URLRequest(list*.@image));
l.x=0;
l.y=-40;
container.addChild(l);
container.setChildIndex(container.getChildAt(1), 0);
var radius1:Number = stage.stageHeight/2.2;
var radius2:Number = stage.stageHeight/5;
var hoek:Number =(2*Math.PI)/(Num/2);
if(i < (Num/3)*2){
container.x = (stage.stageWidth/2.5) + radius1 * Math.cos(((2*Math.PI)/(Num/3))*counter2);
container.y = (stage.stageHeight/2) + radius1 * Math.sin(((2*Math.PI)/(Num/3))*counter2);
counter2++;
home.addChild(container);
}else if (i>=(Num/3)*2){
container.x = (stage.stageWidth/2.5) + radius2 * Math.cos(((2*Math.PI)/(Num/3))*counter);
container.y = (stage.stageHeight/2) + radius2 * Math.sin(((2*Math.PI)/(Num/3))*counter);
counter++;
home.addChild(container);
}
addChild(container);
}
}
function onClick(e:MouseEvent):void{
for(var i=0;i<Num;i++){
var t:MovieClip = this.getChildByName("snipper"+i) as MovieClip;
t.removeEventListener(MouseEvent.CLICK, onClick);
if(t.name == e.currentTarget.name){
t.xPos = t.x;
t.yPos = t.y;
t.theScale = t.scaleX;
var tw:Tween = new Tween(t,"scaleX",Strong.easeOut,t.scaleX,2,1,true);
var tw2:Tween = new Tween(t,"scaleY",Strong.easeOut,t.scaleY,2,1,true);
var tw3:Tween = new Tween(t,"x",Strong.easeOut,t.x,stage.stageWidth/2.5,1,true);
var tw4:Tween = new Tween(t,"y",Strong.easeOut,t.y,stage.stageHeight/2.3,1,true);
tw.addEventListener(TweenEvent.MOTION_STOP, function()
{ s.addEventListener(MouseEvent.CLICK,unReleased) } );
geklikt = t.name;
}else {
t.buttonMode = false;
t.Tekst.visible = false;
var tw5:Tween = new Tween(t,"alpha",Strong.easeOut,100,0,0.2,true);
s = this;
}
}
}
function unReleased(e:MouseEvent):void{
delete this.onRelease;
for(var i=0;i<Num;i++){
var t:MovieClip = this.getChildByName("snipper"+i) as MovieClip;
if(t.name == geklikt){
var tw:Tween = new Tween(t,"scaleX",Strong.easeOut,1.5,t.theScale,1,true);
var tw2:Tween = new Tween(t,"scaleY",Strong.easeOut,1.5,t.theScale,1,true);
var tw3:Tween = new Tween(t,"x",Strong.easeOut,t.x,t.xPos,1,true);
var tw4:Tween = new Tween(t,"y",Strong.easeOut,t.y,t.yPos,1,true);
tw.addEventListener(TweenEvent.MOTION_STOP, function()
{ s.removeEventListener(MouseEvent.CLICK,unReleased) } );
t.Tekst.visible = true;
t.addEventListener(MouseEvent.CLICK, onClick);
t.buttonMode = true;
}else {
var tw6:Tween = new Tween(t,"alpha",Strong.easeOut,0,100,1,true);
tw6.addEventListener(TweenEvent.MOTION_STOP, function()
{ s.removeEventListener(MouseEvent.CLICK,unReleased) } );
t.Tekst.visible = true;
t.addEventListener(MouseEvent.CLICK, onClick);
t.buttonMode = true;
}
}
}