Thursday, April 1, 2010

Changing .swf Cooridinates

Hey, I am trying to get a music player to play on my flash stage, and so far I have gotten it to work fine, but it's right in the middle of everything (text, links, etc.)

Here is my code to load the .swf:

this.createEmptyMovieClip(''holder'', 100);
holder.loadMovie(''playerMultipleList_old.swf'');

How can I get the coordinates to change so that it's, you know, further to the side..?

Thanks!

Changing .swf Cooridinates

fastpicker89,

聽聽聽聽 The trick is to wait until the SWF has fully loaded.聽 At that point (and not before), you can reference the loaded SWF and treat it the same as any movie clip instance (that is, an instance of the MovieClip class) -- because SWFs actually are movie clips.聽 聽 The MovieClip.loadMovie() method, which is what you're using, is fine ... you can definitely use it, but it's a slightly older method, one that takes a bit more effort to test against.聽 You might want to replace your loadMovie() approach with the MovieClipLoader class, which dispatches an event -- an event you can listen for and respond to -- when its content loads.

聽聽聽聽 Here's a brief article on all of the above:

聽聽聽聽 http://www.quip.net/blog/2006/flash/how-to-tell-when-external-swf-loaded

聽聽聽聽 So once your content is loaded, you reference it and set its MovieClip._x property to whatever value looks right.


聽聽聽聽 If you still have questions, don't hesitate to post again.聽

David Stiller
Contributor, How to Cheat in Adobe Flash CS4
http://tinyurl.com/dpsCheatFlashCS4
''Luck is the residue of good design.''

Changing .swf Cooridinates

Actually got it figured out!

this.createEmptyMovieClip(''holder'', 100);
holder.loadMovie(''playerMultipleList_old.swf'');
holder._x = 250 ;
holder._y = 110;

Thanks though!


fastpicker89,

聽聽聽聽 Ah, I see that.聽 Yup, that'll do it.聽 The extra steps I mentioned are necessary if you want to deal with event handling, such as turning the loaded content into a clickable button.聽 Positioning alone of your holder clip doesn't need what I mentioned.

David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
''Luck is the residue of good design.''

No comments:

Post a Comment