Maintaining Mouse Control in Embedded swfs (i.e. parent / child ) Flash cs4 AS3
Posted
by garydev
on Stack Overflow
See other posts from Stack Overflow
or by garydev
Published on 2010-05-01T21:33:01Z
Indexed on
2010/05/01
21:37 UTC
Read the original article
Hit count: 151
Hello to all, I have an issue that is driving me nuts. I have an AS3 application that performs a calculation based upon user's input to determine a result. The purpose is to predict the results of a horse's coat color based on the genetics. The results are given in a 3d model swfs that are loaded into the "shell's" UILoader Component and they rotate. I have an example of this here: http://www.provideoshow.com/coatcalculator/coat_calculator.html
As you can see this works fine with an "auto-rotate" feature.
The problem is that my client wants the 3d models to be rotated by the user's mouse. I have the 3d models rotating with the mouse but they only work when they are stand alone swfs. They break when they are loaded into the shell.
Some research informs me that the issue is in the stage properties and the parent not receiving them from the child. I've gotten some advice that I need to pass a reference to the shell's stage and preferably in the init function.
This is the code I have in the child which is loaded as a class
public function Main_master_withmouse()
{
if(stage)
{
_stage = stage;
init(stage);
}
}
protected function init(rootStage:Stage):void
{
if(rootStage)
{
_stage = rootStage;
}
else
{
_stage = this.stage;
}
sceneWidth = _stage.stageWidth
createChildren();
startRendering();
}
I can't figure out what to put in the parent to pass the reference to its stage.
Any help is greatly appreciated. Thank you in advance
© Stack Overflow or respective owner