Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-07-2012, 06:22 PM   #1
jackyjohnson
Registered User
 
Join Date: Jun 2012
Posts: 4
Default External swf loaded into holder not repositioning

Hello,

i've been trying to get this to work for 2 days now but i'm getting tired of it.

As far as loading the external swf into the holder. That's working fine. The tricky part is getting the holder to reposition when the browser is being resized. Right now it doesn't respond to the code. When i don't load the external swf into the movieclip with the instancename "holder" however, the movieclip does respond to the actionscript and repositions upon resizing the browser.

This is the code i'm using for it:


ActionScript Code:
Stage.align = "LT"; // base measurements on the top left corner of the movie Stage.scaleMode = "noScale"; // prevent items being scaled by default when the movie is resized // external swf loader // var mcl = new MovieClipLoader(); var mclL = new Object(); mcl.addListener(mclL); mcl.loadClip("ext.swf", holder); // external swf loader // holder.onResize = function() {     // set the point we want the clip to move to     this.targetX = 800;     this.targetY = -100;     this.onEnterFrame = reposition; }; Stage.addListener(holder); holder.onResize(); function reposition() {     // move towards the target position     this._x += (this.targetX - this._x) / 6;     this._y += (this.targetY - this._y) / 6;     // if we are very close to the target position - stop     if (Math.round(this._x) == Math.round(this.targetX) && Math.round(this._y) == Math.round(this.targetY)) {         this._x = this.targetX;         this._y = this.targetY;         delete this.onEnterFrame;     } }

Help would be greatly appreciated, this is driving me nuts.
jackyjohnson is offline   Reply With Quote
Old 06-08-2012, 08:16 AM   #2
Noct
Toys in the Attic...
 
Noct's Avatar
 
Join Date: Oct 2006
Location: NY
Posts: 3,022
Default

Welcome aboard,

You're loading into the same scope that the script is applied to, and killing the script in the process; that's why it works if you bypass that step.

When you load into any clip/scope, you basically wipe it clean of any previously applied scripting. You actually wipe it free of any children at all, vars, clips, etc.

To fix it:
Use a listener object to tell you when the file is fully loaded, and then apply your re-size method then.
__________________
http://rwithers.com

Last edited by Noct; 06-08-2012 at 08:22 AM.
Noct is offline   Reply With Quote
Old 06-14-2012, 09:05 PM   #3
jackyjohnson
Registered User
 
Join Date: Jun 2012
Posts: 4
Default

Thanks Noct!

that makes sense. Well, since i'm a noob to Action Script this will probably look like gibberish but it' s all i could come up with. I put the onResize function inside the onLoadComplete evenhandler but as i kind of expected, it still ain't working.

ActionScript Code:
// external swf loader // var mcl = new MovieClipLoader(); var mclL = new Object(); mcl.addListener(mclL); mcl.loadClip("ext.swf", holder); // external swf loader // mc1L.onLoadComplete = function(mc1L:MovieClip){ holder.onResize = function() {     // set the point we want the clip to move to     this.targetX = 800;     this.targetY = -100;     this.onEnterFrame = reposition; }; }; Stage.addListener(holder); holder.onResize();
jackyjohnson is offline   Reply With Quote
Old 06-21-2012, 09:31 PM   #4
jackyjohnson
Registered User
 
Join Date: Jun 2012
Posts: 4
Default

here's an atachment with the fla and swf files.
Attached Files
File Type: zip AS2 question.zip (167.4 KB, 50 views)
jackyjohnson is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:06 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.