Quick thought before going to sleep:  ModuleLoader extends VBox so if
its layout code runs it will reposition the child in its upper left.
That might be what is getting you.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of flashcrow2000
Sent: Thursday, May 24, 2007 11:22 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: changing states in module behaves strange

 

To add the module loader, i'm using a somewhat strange method: I 
have a singleton which selects an object I know for certain resides 
in the main window, and i'm adding the module loader to thast 
object's parent. So this is something like this:

ml = new ModuleLoader();
ml.url = "mySwf.swf"
ml.loadModule()
Singleton.getInstance().getDefault().parent.addChild(ml).

now...the module is dragable...I've traced some of the variables and 
I can say for certain that when I drag the module, I'm actually 
dragging the content, because the moduleLoader stays at the same 0, 
0 coordinates (the top-left corner)

Also, all transitions are acting on the module because that is the 
only way they work at all. (I have played with the transitions 
target and tried this.parent, this, this.parent.parent.parent and 
they don't work).

I'm transcripting some of the code below:

/////////module/////////
<mx:Module
xmlns="com.esri.aws.awx.widget.*"
xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
xmlns:widget="com.esri.bmw.widgets.FindWidget.view.*"
initialize="onInit()"
autoLayout="true"
>
<widget:WidgetWindow id="WidgetWindow" 
showInfoButton="false"
widgetTitle="Find"
hideEffect="Fade"
autoLayout="true"
/>
<mx:Script>
<![CDATA[
import com.esri.bmw.widgets.FindWidget.view.WidgetMainView;
import com.esri.bmw.widgets.FindWidget.view.WidgetWindow;
import mx.core.UIComponent;

private function onInit():void
{ 
var mainView : WidgetMainView = new WidgetMainView();
WidgetWindow.setContent( mainView );
WidgetWindow.width = 394;
WidgetWindow.height = 140;
} 
]]>
</mx:Script> 
</mx:Module>

////////////////// widget window ////////////////

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas 
xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
backgroundColor="#e7e7e7" 
backgroundAlpha="0.83"
mouseDown="onBackgroundMouseDown(event)" 
mouseUp="onBackgroundMouseUp()"
initialize="onPreInit()" 
autoLayout="true"
hideEffect="Fade"
verticalScrollPolicy="off"
horizontalScrollPolicy="off"
effectStart="onEffectStart(event)"
effectEnd="onEffectEnd(event)">
<mx:Script>
<![CDATA[
import mx.events.EffectEvent;
import mx.modules.ModuleLoader;
import mx.events.FlexEvent;
import mx.core.UIComponent; 
public var showInfoButton:Boolean = true;
public var widgetTitle:String = "Widget Window"
private var content:UIComponent; 

private function onInfo():void {
trace(content)
content.currentState = "info"
}

private function onPreInit():void {
if (showInfoButton == false)
infoBtn.visible = false;
titleLabel.text = widgetTitle;
}

public function setContent(obj:DisplayObject):void {
holder.addChild(obj);
content = obj as UIComponent;
}

private function onClose():void { 
this.visible = false;
}

private function onBackgroundMouseDown(event:MouseEvent):void {
if (this.mouseY < 40 && (event.target == this || 
event.target.parent == titleLabel))
this.startDrag(false);
}

private function onBackgroundMouseUp():void {
this.stopDrag();
}
]]>
</mx:Script>

<mx:Canvas backgroundColor="#ffffff" 
left="10" 
right="10" 
bottom="10" 
top="40"
verticalScrollPolicy="off"
horizontalScrollPolicy="off"
id="holder" borderColor="#b0b0b0" autoLayout="true" 
borderStyle="solid">
</mx:Canvas>

<mx:Button y="10" id="closeBtn" click="onClose()" right="10"
label="close"/>
<mx:Button y="10" id="infoBtn" click="onInfo()" right="42"
label="infoState"/>
<mx:Label y="17" text="Label" left="15" id="titleLabel"/>
</mx:Canvas>

////////transitions from the content window//////
<mx:transitions>
<mx:Transition id="resUp" fromState="*" toState="results">
<mx:Parallel>
<mx:Resize target="{this.parent}" heightTo="460" 
suspendBackgroundProcessing="true"/>
<mx:Resize target="{this.parent.parent}" 
heightTo="460" suspendBackgroundProcessing="true"/>
</mx:Parallel>
</mx:Transition>

<mx:Transition id="hisUp" fromState="*" toState="history">
<mx:Parallel>
<mx:Resize target="{this.parent}" heightTo="460" 
suspendBackgroundProcessing="true"/>
<mx:Resize target="{this.parent.parent}" 
heightTo="460" suspendBackgroundProcessing="true"/>
</mx:Parallel>
</mx:Transition>

<mx:Transition id="resDn" fromState="results" toState="*">
<mx:Parallel>
<mx:Resize target="{this.parent}" heightTo="140" 
suspendBackgroundProcessing="true"/>
<mx:Resize target="{this.parent.parent}" 
heightTo="140" suspendBackgroundProcessing="true"/>
</mx:Parallel>
</mx:Transition>

<mx:Transition id="hisDn" fromState="history" toState="*">
<mx:Parallel>
<mx:Resize target="{this.parent}" heightTo="140" 
suspendBackgroundProcessing="true"/>
<mx:Resize target="{this.parent.parent}" 
heightTo="140" suspendBackgroundProcessing="true"/>
</mx:Parallel>
</mx:Transition>
</mx:transitions>

////////////////////the module loading sequence/////////////////
findMod = new ModuleLoader();
SingletonObject.getInstance().getDefaultObj().parent.addChild
(findMod);
findMod.url = m_widgetSwf_URL;
findMod.loadModule();

This is about it....i know it's a lot of code, I tried to cut out 
most of the unneccessary code for this issue.

Any ideas?
Cosmin

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> I get a feeling that the reference point for the state is relative 
to
> where it got loaded and not where it is. Maybe showing more code 
will
> help
> 
> 
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>

[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of flashcrow2000
> Sent: Wednesday, May 23, 2007 11:16 PM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Re: changing states in module behaves strange
> 
> 
> 
> I'm pretty sure the custom window shifts when transitions are 
> applied to the content. I'll try and explain some more how 
> everything is built:
> 
> the custom window is a canvas with a label, a close button and 
> another canvas (contentHolder) which will hold the window's 
content.
> 
> the module contains an instance of this custom window, and ads the 
> content to it via actionscript (I have a method in the custom 
window 
> class which sets the content and the dimmensions of the 
> contentHolder)
> 
> the transitions are implemented in the content class.
> 
> So: schematic this would look like this:
> 
> content -> {contentHolder} Custom Window -> Module -..-> Module 
> Loader.
> 
> calling this.parent.parent from content would highlight 
CustomWindow 
> (seeing that this.parent would highlight contentHolder which is a 
> child of the custom window).
> 
> this.parent changes only the inner canvas and even though I have 
set 
> autolayout=true, the custom window doesn't enlarge.
> 
> this.parent.parent.parent doesn't work.
> 
> Any ideas?
> 
> --- In flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
40yahoogroups.com>
> , "Alex Harui" <aharui@> wrote:
> >
> > If you don't use a module, do you have the same problem? I'm more
> > interested in who the parent of the custom window and content 
is, 
> and
> > whether it is the content that shifts or the custom window.
> > 
> > 
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
40yahoogroups.com>
> 
> [mailto:flexcoders@yahoogroups.com
<mailto:flexcoders%40yahoogroups.com>  <mailto:flexcoders%
40yahoogroups.com>
> ] On
> > Behalf Of flashcrow2000
> > Sent: Wednesday, May 23, 2007 8:35 AM
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
<mailto:flexcoders%
40yahoogroups.com> 
> > Subject: [flexcoders] changing states in module behaves strange
> > 
> > 
> > 
> > Hello,
> > 
> > Here's the story:
> > I have a custom window and a class which defines a specific 
> content 
> > (pictures, text, other components and so on).
> > 
> > My module loads a custom window and sets its content to that 
> > specific class (much like a popupmanager, if you like, but i 
can't 
> > use that for this project).
> > 
> > My problem is that, whenever one of the windows changes state, 
it 
> > jumps back to the upper left corner, where all moduleLoaders 
> objects 
> > are. 
> > 
> > I have implemented transitions between the states, and if I 
remove 
> > them, the window doesn't jump anymore.
> > 
> > One of the transitions looks like this:
> > <mx:Transition id="resUp" fromState="*" toState="results">
> > <mx:Sequence target="{this.parent.parent}">
> > <mx:AddChildAction/>
> > <mx:Resize target="{this.parent.parent}" heightTo="460"/>
> > </mx:Sequence>
> > </mx:Transition>
> > 
> > where this.parent.parent leads to the custom window.
> > 
> > Any ideas?
> > Thanks!
> >
>

 

Reply via email to