Hi,
Just getting to grips with as3 and have hit a stumbling block!
I have an fla that has four mc's - that together with this script create a carousel - with one mc acting as the hub and the other three rotating around it .
PHP Code:
import idv.cjcat.display.carousel.Carousel;
import idv.cjcat.display.carousel.Pony;
var balls:Array = [ball1_mc, ball2_mc, ball3_mc];
var carousel:Carousel = new Carousel;
//centers and radii for the (x, y) coordinate
carousel.centerX = stage.stageWidth/2;
carousel.radiusX = 150;
carousel.centerY = stage.stageHeight/2;
carousel.radiusY = -50;
//center and radius for the scaleX and scaleY property
carousel.centerS = 1;
carousel.radiusS = 0.5;
carousel.axis = axis_mc;
for (var i:int = 0; i < balls.length; i++) {
carousel.add(new Pony(balls[i], Math.PI * 2 / 3 * i /*this is the 'phase' of the Pony around the carousel*/));
}
addChild(carousel);
addEventListener(Event.ENTER_FRAME, rotate);
function rotate(e:Event):void {
carousel.phase = getTimer() / 500;
carousel.render();
}
addEventListener(Event.ENTER_FRAME, tweak);
function tweak(e:Event):void {
carousel.phase = mouseX / -100;
carousel.render();
}
This all works great until I complicate matters by trying to integrate some liquid layout type stuff - by using this script:
PHP Code:
import flash.display.*;
//set stage position
stage.align = StageAlign.TOP_LEFT;
//do not let any of the stage scale
stage.scaleMode = StageScaleMode.NO_SCALE;
//add stage resize listener,
//this is called when the browser or flash movie is resized
this.stage.addEventListener(Event.RESIZE, resizeHandler);
//create trigger that is fired when resize is triggered
function resizeHandler(event:Event):void {
position();
}
//call resize function at start of movie
//this way everything starts in the right place
position();
//this is the function contains all your code
//you can add your own as long as there
//is a movie clip on the stage that you named correclty
function position(){
middleClip.x = stage.stageWidth/2;
middleClip.y = stage.stageHeight/2;
axis_mc.x = stage.stageWidth/2;
axis_mc.y = stage.stageHeight/2;
ball1_mc.x = stage.stageWidth/2;
ball1_mc.y = stage.stageHeight/2;
ball2_mc.x = stage.stageWidth/2;
ball2_mc.y = stage.stageHeight/2;
ball3_mc.x = stage.stageWidth/2;
ball3_mc.y = stage.stageHeight/2;
topClip.width = stage.stageWidth;
topClip.y = 0;
topClip.x = 0;
botClip.width = stage.stageWidth;
botClip.x = 0;
botClip.y = stage.stageHeight - topClip.height;
}
This works great and positions 'all' the elements on the stage as they should be. But, but, but when I resize the stage everything moves in relation apart from the three mc's that rotate (ball1_mc, ball2_mc, ball3_mc) which simply stay where are?
What am I doing wrong or not doing at all that makes this happen? I have going at this most of the afternoon to no avail
I have attached the folder as a .zip file if anyone needs it to see what I mean?
Really grateful to anyone that can offer me some experience in the field of the workings of AS3
Here's hoping!
***crosses fingers***