Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:32
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  stand alone swf working but breaking when embedded
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: stand alone swf working but breaking when embedded  (Read 914 times)
takid88
Jr. Programmer
**
Posts: 51


View Profile
« on: 03/04/10, 17:14 »

hey guys just s quick question.  I've got a swf file that stand alone works perfect, until I load it into my main swf, then it break everything.  I think I've narrowed it down to this bit of code which sets the 3d axis depending on mouse position.

Code:
stage.addEventListener(MouseEvent.MOUSE_MOVE, sliderRotate);

function sliderRotate(event:Event) {
mc_name.rotationY = -((((0 - -4)/stage.stageWidth)*mouseX) + 4);
mc_name.rotationX = (((8 - -8)/stage.stageHeight)*mouseY) - 8;

}


Works fine alone but when I load it into a container swf I get a term undefined error.

Thanks for the help
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6161


View Profile WWW Email
« Reply #1 on: 03/05/10, 01:51 »

Hi - question:

is my_name a reference to a movieclip object stored in a variable?
Logged

happy flashing
Cool
Ronald
takid88
Jr. Programmer
**
Posts: 51


View Profile
« Reply #2 on: 03/05/10, 12:50 »

mc_name is the instance name of the movieclip inside of the swf I would like to be loaded into main swf

also that code in placed inside the swf that is being loaded into main swf.  The swf stand alone works perferct but as soon as it is loaded into another is when that code breaks it
« Last Edit: 03/05/10, 13:03 by takid88 » Logged
takid88
Jr. Programmer
**
Posts: 51


View Profile
« Reply #3 on: 03/09/10, 21:30 »

I have been able to figure out about 2/3 of the problem.  When I was adding my event listener to stage of swf being loaded it would break. 

Changing it to "this.eventlistener" fixed a majority of the problem.  However it also raised a new problem.

I am creating a fullscreen (no scale) site, so I am placing the position of my movieclips by referring the stage.  Such as....

movieClip.x = stage.stageWidth / 2;

that code sets the x property of the movie clip fine when stand alone but when loaded into another swf it has trouble accessing the stage. 

How can I access the height and width of the stage from a child swf?

Thanks for any help
Logged
takid88
Jr. Programmer
**
Posts: 51


View Profile
« Reply #4 on: 03/09/10, 21:38 »

also i forgot to add that I have tried both parent.x and root.x which both give no errors, however they are not giving a proper value and doesn't display right
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #5 on: 03/10/10, 04:49 »

Every element in the displaylist have a stage property that points to the main stage, so try

myElement.stage.stageWidth

Where myElement is any element in the displaylist, also this.stage could works for a loaded swf, as far as itīs added to the main DisplayList

Jorge
Logged

takid88
Jr. Programmer
**
Posts: 51


View Profile
« Reply #6 on: 03/12/10, 19:17 »

Figured it out.....

It was because I was referencing the stage in the swf being loaded, and the split second before you addChild, there is no stage so it broke all my code.

I added a ADDED_TO_STAGE listener that ran all my stage references and it fixed the problem..

Thank  Smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!