• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 358
  • Last Modified:

No longer able to set coordinates of external SWF.

Hello Experts,

I had to restructure my original post, so here I go...

I have a SWF file that its X,Y coordinates were set to 560,225 respectively.  Then I added an Event Listener and the coordinates no longer take effect and my SWF is placed at 0,0.

I've even placed the code into the onCompleteHandler function, with no luck.  I would appreciate some help on fixing this.

function quizFunc(arg1):void
{
		var xmlData:XML = new XML(arg1);
		
		var fl_Loader:Loader;
		fl_Loader = new Loader();
		fl_Loader.load(new URLRequest("Questionnaire.swf"));
		addChild(fl_Loader);
		
		//This following two lines did work... 
		//until the 'addEventListener' was added below, now the SWF is at (0,0)
		fl_Loader.x=560;//Does not work, though tracing out fl_Loader.x does reflect the value
		fl_Loader.y=225;//Does not work, though tracing out fl_Loader.y does reflect the value

		fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);	
		function onCompleteHandler(loadEvent:Event)
		{
			addChild(loadEvent.currentTarget.content);
			loadEvent.currentTarget.content.questionText_txt.text = xmlData.questionType[0].question[0].@text;
			loadEvent.currentTarget.content.q1_txt.text = xmlData.questionType[0].question[0].possibleAnswer[0].@text;
			loadEvent.currentTarget.content.q2_txt.text = xmlData.questionType[0].question[0].possibleAnswer[1].@text;
			loadEvent.currentTarget.content.q3_txt.text = xmlData.questionType[0].question[0].possibleAnswer[2].@text;
			loadEvent.currentTarget.content.q4_txt.text = xmlData.questionType[0].question[0].possibleAnswer[3].@text;			
		}
}

Open in new window

0
ModifyMe
Asked:
ModifyMe
  • 2
1 Solution
 
ModifyMeAuthor Commented:
How dumb of me for something so simple.  I tried MANY different ways since yesterday pulling my hair and it was something as simple as placing:
var xFL = loadEvent.currentTarget.content.x;
var yFL = loadEvent.currentTarget.content.y;

Open in new window

...at the end of the code in the onCompleteHandler function.
0
 
dgofmanCommented:
Look, that is so easy, create a sprite "holder"

var holder:Sprite = new Sprite();

add to stage

addChild(holder);

You can set location

holder.x = 560;
holder.y = 225;

Now load your SWF

                                           var fl_Loader:Loader;
            fl_Loader = new Loader();
            fl_Loader.load(new URLRequest("Questionnaire.swf"));
            
and attach to holder

holder.addChild(fl_Loader);
0
 
ModifyMeAuthor Commented:
Thx, had my head in my .... today.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now