Heya
I'm still learning flash and actionscript 3 and i am having trouble with variable and object names. I need to be able to combine variable names together (in the same way as php can combine by doing var1.var2).
My swf contains 4 loaders (image1_loader, image2_loader etc..) which are a child of (image1_content, image2_content etc.....)
I then have 4 buttons which load an image into the loader and while doing so they define the currently active loader.
Finally i have 4 control buttons - scale up/down and rotate clockwise/anticlockwise which should only control the currently active loader (as set by the buttons above)
So my buttons as well as loading the image have the event listener:
So after setting my activeLoader as the string 'imageX' i have a control functions as in this rotate one:Code:image1_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection); image2_btn.addEventListener(MouseEvent.CLICK, setCurrentSelection); (and so on..) function setCurrentSelection(e:MouseEvent):void { if (e.currentTarget===image1_btn){activeLoader='image1';} if (e.currentTarget===image2_btn){activeLoader='image2';} if (e.currentTarget===image3_btn){activeLoader='image3';} if (e.currentTarget===image4_btn){activeLoader='image4';} }
So within the rotateClockwise and rotateAntiClockwise functions i need to be able to recognise which is the currently active loader and have that number instead of the X - so if it is image1_loader - it needs to be image1_content, if 4 - image4_content...Code:rotateClock_btn.addEventListener(MouseEvent.MOUSE_DOWN, rotateClockwise); rotateAnti_btn.addEventListener(MouseEvent.MOUSE_DOWN, rotateAntiClockwise); function rotateClockwise(event:Event):void { rotateAroundCenter(imageX_content, 10, ptR); } function rotateAntiClockwise(event:Event):void { rotateAroundCenter(imageX_content, -10, ptR); }
I had tried to do it as this but it doesn't like it being a string:
Please could anyone help me understand how to solve (sorry if i havent explained it clearly!) and please go easy on me - i'm learning as i go myselfCode:rotateAroundCenter((activeLoader+'_content'), 10, ptR);
Lauren![]()


Reply With Quote


Bookmarks