To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 10-22-2004, 12:54 AM   #1
yankmoura
Senior Member
 
Join Date: Oct 2004
Location: Rio de Janeiro, Brazil
Posts: 344
Containers in Flash?

I was thinking if there is a way to put a "container" in a MC timeline. My idea would be to have these "containers" where I could instantiate pictures, in accord of my needings.

For instances, suppose that you have 10 photographies and would like to randomize this photographies, in order to show an animation with one of them, each time.

Then, the animation would be done with the "containers" and not with the photos, and the photos would be instantiated inside the "containers".

This is possible in Flash?
yankmoura is offline   Reply With Quote
Old 10-22-2004, 01:56 AM   #2
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
Yes it's possible. There are a few ways to do it.

The loadMovie() function can be used to load images or movies into container movieclips. In this case, the images or SWFs would be served up separately from your web server.

If you want to keep all the pictures in your library, you can export them, and then use attachMovie() to dynamically instantiate them from variable names, which change each time you run animations.
__________________
jbum is offline   Reply With Quote
Old 10-22-2004, 09:21 PM   #3
yankmoura
Senior Member
 
Join Date: Oct 2004
Location: Rio de Janeiro, Brazil
Posts: 344
What's the trick to create a container MC?
I am trying, but think that I dont know exactly what to do...

I created an empty MC and called it "empty". Then I hard-instantiated (clicked and dragged from library to the stage) it in my main timeline as "empty1", and made a simple motion tween. Of course, when I run that, nothing appears, because the hard-instantiated MC has nothing.

Then I created another MC with just one frame with a photography, called "pic".

Now, my idea is from within code (with actionscript) to instantiate the "pic" MC as "pic1" into "empty1", in the very first frame of the main timeline. Well, the problem is that I cant see HOW can I instantiate a MC inside another!!!

Can you help me????

Thanks!
yankmoura is offline   Reply With Quote
Old 10-22-2004, 09:26 PM   #4
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
_root.createEmptyMovieClip()

can be used to create movieclips. Most folks tend to use it TWICE when using it in conjunction with loadMovie().

Like so:

code:

_root.createEmptyMovieClip('mc1', 1);
mc1.createEmptyMovieClip('mc2', 1);
mc1._x = 100;
mc1._y = 150;
// etc...
mc1.mc2.loadMovie("mypicture.jpg");



The reason for creating two nested movieclips is that the loadMovie() call completely wipes out all the properties (of mc2, in this case), so this allows you to place the loaded movieclip at a particular location, becaue mc1._x & _y won't get wiped out.

If you're using attachMovie(), you dont' need to use createEmptyMovieClip - just attach the movie and put it where you want.

_root.attachMovie("mypicture", "mc1", 1);
mc1._x = 100;
mc1._y = 150;

However, in this case, "mypicture" needs to be in the library and exported.
__________________
jbum is offline   Reply With Quote
Old 10-22-2004, 09:34 PM   #5
yankmoura
Senior Member
 
Join Date: Oct 2004
Location: Rio de Janeiro, Brazil
Posts: 344
Hi! Thanks for the help!
I think that I am almost there, but nothing yet!!!

I am trying to use attachMovie (I use Flash 5).
The situation is that I want to have a MC with an animation (just like something sliding from left to right). But this "something" will be changed from times to times.

Well, I made this animation with a "nothing" sliding from left to right. This "nothing" is a MC with just one blank frame. Then I am trying to instantiate another MC inside that.

I put in the first frame of the main timeline the following code:

empty1.attachMovie ("pic","pic1",1);
empty1.pic1._x = 100;
empty1.pic1._y = 100;

PS: pic is exported through "linkage" option.

Nothing happens!!!
yankmoura is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:23 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.