Dynamic Instance for a MOVIE CLIP
Hi Please help me!!!!!!!!!!
I am creating dynamic Movie Clip using as3, but I don't have
any idea about dynamic Instance name, please give me some idea that
how I can assign Instance name for a movie clip.
I am waiting your reply.
Thanks
Sushil Kumar
You can assign a value to the name property of the MovieClip,
but refering to the variable name of your MovieClip instance is
preferable. This code illustrates the difference:
Similar Messages
-
HitTest for multiple Movie Clip at the same time
I have a movie it is a triangle.I duplicate it and I want to hitTest on the first triangle movie clip and I added 3 different line movie clips on the 3 side of triangle.I tried to write a code something like that.
if(firstTriangle_mc.hitTestObject(line1_mc,line2_mc,line_3mc){
trace("Ok");
but I've got error.I think it is not allowed hitTestObject for multiple Movie Clips.So is there anyone have an opinion about it?What should I do?Here is another test for multiple movie clips for hitTestPoint but only the first work the others don't
uc_mc.addEventListener(Event.ENTER_FRAME,hitle);
function hitle(e:Event) {
if (uc_mc.hitTestPoint(cub1,cub1Y,true)&&(cub2,cub2Y,true)&&(cub3,cub3Y,true)) {
uc_mc.alpha=0.5;
}else{
uc_mc.alpha=1;
The code above doesn't work.What should I do? -
Dynamically adding multiple instances of a movie clip to the stage with one button
hello,
I was wondering if there was a way to add several instances
of the same movie clip to the stage dynamically utilizing one
button.
I can do one with the following code placed on the button...
on (release) {
attachMovie ("filledCircle", "filled1", 5);
filled1._x = 370;
filled1._y = 225;
But I want the user to be able to hit the button again and
get yet another instance of "filledCircle" on the stage.
I also want the user to be able to drag these instances
around...
Any help would be appreciated...
Thanks,
MuhlMuhl,
> I was wondering if there was a way to add several
> instances of the same movie clip to the stage
> dynamically utilizing one button.
Sure thing.
> I can do one with the following code placed on the
> button...
>
> on (release) {
> attachMovie ("filledCircle", "filled1", 5);
> filled1._x = 370;
> filled1._y = 225;
> }
Gotcha.
> But I want the user to be able to hit the button again
> and get yet another instance of "filledCircle" on the
> stage.
You're in luck, because this isn't very hard to do. The main
thing to
keep in mind is that each instance must have A) its own
unique instance name
and B) its own unique depth. In your example, the instance
name is filled1
and the depth is 5. The next clip's instance name should be
filled2 at a
depth of 6. Then filled3, depth 7, and so on. You can use a
single
variable to handle the incrementation.
// code in a frame
var counter:Number = 1;
// code on your button
on (release) {
attachMovie ("filledCircle", "filled" + counter, counter +
4);
With me so far? The variable counter contains the numeric
value 1. The
second parameter of attachMovie() is provided with a
concatenation of
"filled" + 1, which makes "filled1". The third parameter is
provided with
the sum of counter plus 4, which makes 5. Obviously, we need
a bit more.
The button must, in addition, increment the value of counter.
The ++
operator handles this perfectly.
on (release) {
attachMovie ("filledCircle", "filled" + counter, counter +
4);
counter++;
Now, it seems you also want to position the attached movie
clip to (370,
225). Are they call supposed to go to the same place? If so,
you may use a
second variable to hold a reference to the newly attached
clip. Look up
MovieClip.attachMovie(), and you'll see that the method
returns the exact
reference you need.
// code in a frame
var counter:Number = 1;
var mc:MovieClip;
// code on your button
on (release) {
mc = attachMovie ("filledCircle", "filled" + counter,
counter + 4);
counter++;
mc._x = 370;
mc._y = 225;
Make sense?
> I also want the user to be able to drag these instances
> around...
Then you need to handle a few events. You're dealing with
movie clips
here, so your best bet is to study up on the MovieClip class,
which defines
all movie clips. (Note, also, that the TextField class
defines all input
and dynamic text fields; the Sound class defines all sounds,
etc. This is a
very handy arrangement of the ActionScript 2.0 Language
Reference.)
// code in a frame
var counter:Number = 1;
var mc:MovieClip;
// code on your button
on (release) {
mc = attachMovie ("filledCircle", "filled" + counter,
counter + 4);
counter++;
mc._x = 370;
mc._y = 225;
mc.onPress = function() {
this.startDrag();
mc.onRelease = function() {
this.stopDrag();
Easy as that. You're simply assigning a function literal to
the event
of each new MovieClip instance as you create it. Take a look
and you'll see
each of these class members available to you -- that is, to
all movie clips.
MovieClip.onPress, MovieClip.startDrag(), MovieClip._x, etc.
Wherever it shows the term MovieClip in the Language
Reference, just
replace that with the instance name of your clip -- or a
reference to that
clip (which even includes the global "this" property).
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design." -
How to load dynamic text inside a movie clip?
hello all - i have a main stage where on the first frame my
"home" movie clip displays. i did this by dragging/dropping, and
then i put a stop action. all works fine.
inside this home movie clip on the main stage, there are
links to other movie clips. for example, to get to my faq's page -
you click that button, then it takes you to frame 4 on my main
stage, where my faq's movie clip (followed by stop action) has been
dragged/dropped and displays properly.
within the faq's movie clip this process is repeated, with
buttons taking to you various pages (different frames where
different movie clips play - all works fine).
so now i want to add a dynamic text field within my faq's
movie clip. i have read numerous tutorials where i have created the
text file but i have not been able to display it with success
within my faqs movie clip.
here is some code that my dvd tutorial instructs me to place
on main stage as i practice getting this to work:
var myMCL:MovieClipLoader = new MovieClipLoader ();
var myListener:Object = new Object();
myMCL.addListener(myListener);
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
and here is some code that i place on the faqs button within
my main movie clip that takes me back to main stage and plays faq
movie clip all successfully:
on (release) {
//Movieclip GotoAndPlay Behavior
_root.gotoAndPlay("4");
//End Behavior
and finally, here is some code that i place within my faqs
movie clip in an attempt to display my dynamic text within the faqs
movie clip - so far unsuccessful:
_level0.myLV.load("vars/faqs.txt");
NOTE:
i have published this to view - not working.
i have my faqs text file starting as info=
i have eliminated white space within my text file
i am using flash 8 pro
can anyone offer some sugestions? thanks!hmmmmm lemme double check as i seem to be a bit lost now.
// this is my actions layer code on frame 4 of main timeline:
stop();
var myLV:LoadVars = new LoadVars();
myLV.onLoad = function (success:Boolean) {
if (success) {
_level5.loadedInfo.htmlText = myLV.info;
} else {
_level5.loadedInfo.text = "There has been an error loading
the requested information. Please contact the webmaster.";
myLV.load("vars/faqs.txt");
1. fyi - at frame 4 on main timeline, one layer beneath the
actions layer where i dragged/dropped my faqs movie clip i gave my
faqs movie clip an instance name of "mainfaqs" - although nowhere
do i refer to this specific mc within my code.
2. where would i replace/insert the following code?
_level0.faq_mc.loadedInfo.text = myLV.info;
3. i didn't know about embedding font but i saw the option
and embedded it - still no results.
4. i'm not sure how to do the following:
_level5.loadedInfo.text ='test'; //although I would still
change the path as above
To see if your getting a return from the load call adn text
file, use a trace statment before the success condition and see
what it returns:
trace(myLV);
sorry to be such a pain - i really have looked around for
answers through previous postings and i googled it and i've been
taking instruction through lynda.com and dvds but i seem to be
stuck here.... as always - thanks for your time -
Dynamic text in different movie clip
Inside scene one i have a movie clip that contains a movie
clip that contains a dynamic text field. Also inside Scene one I
have a different movie clip that contains a movie clip that
contains a movie clip that contains a input text field. And I need
for the user to type in to the input text field and see what they
are typing show up in the dynamic text field. What would that
script look like and where would I put it? Can anyone help
please?hi!
Lets say you have your dynamic clip on the same level as the
movieclip containing your input field.
_root.dynamic_texfield_name.text =
_root.name_of_movieclip.input_texfield_name.text;
If you need the dynamic textfield to be updated as soon as
the user types something in the input field you can use a onChange
handler.
_root.name_of_movieclip.input_texfield_name.onChange =
function(){
_root.dynamic_texfield_name.text =
_root.name_of_movieclip.input_texfield_name.text;
} -
Dynamic text in looping movie clip
Hi,
I am looping a movie clip which has a dynamic text box. I
need to call data from XML and place the same in the Dynamic text
box as per the duplicated movie clip. how do i do that.
Thanks,
Ayushon (release) {
_parent.frontFields.topTextArch.ph2TopTextBrush._visible =
false;
That is the script attached to my button. I can see the text
flash for a second when I push the button but it does'nt go away
because the looping movie clip just continually goes back to the
first frame and makes the ph2TopTextBrush text field visible again.
I think I know what your saying. Your saying to attach a
script to the first frame of the looping movie clip that would
check to see which of the 3 dynamic text fields are visible. That
would be perfect but I'm not sure how to do it.
What would the script that I place on my button look like?
What would the script in the first frame of the looping movie clip
look like? -
How to obtain instance name of Movie Clip?
Hello!
Is there a way to get the instance name of a move clip once it's on the stage? In my dress up game, I need to know which items are on the doll in order to keep them visible. My drag and drop feature uses an array and currentTarget:
var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
for(var i:int = 0; i < dragArray.length; i++)
dragArray[i].buttonMode = true;
dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
function item_onMouseDown(event:MouseEvent):void
var clip:MovieClip = MovieClip(event.currentTarget);
clip.startDrag();
function item_onMouseUp(event:MouseEvent):void
var clip:MovieClip = MovieClip(event.currentTarget);
clip.stopDrag();
if(clip.hitTestObject(Doll.Skins))
//Here's where the problem starts! ---------------------------------------------- //
trace("It's on the doll!");
It can successfully run this code. However, instead of tracing "It's on the doll!", I'd like to turn the currentTarget into it's instance name, which should be "Doll.Drawers.Dress1" etc... and then store that name in an array.
How would I do this?
I've looked into e.target.name, but I keep getting errors...use the name property of clip (if that's the movieclip whose name you want):
var dragArray:Array = [Doll.Drawers.Dress1, Doll.Drawers.Dress2, Doll.Drawers.Dress3, Doll.Drawers.Dress4];
for(var i:int = 0; i < dragArray.length; i++)
dragArray[i].buttonMode = true;
dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
dragArray[i].addEventListener(MouseEvent.MOUSE_UP, item_onMouseUp);
function item_onMouseDown(event:MouseEvent):void
var clip:MovieClip = MovieClip(event.currentTarget);
clip.startDrag();
function item_onMouseUp(event:MouseEvent):void
var clip:MovieClip = MovieClip(event.currentTarget);
clip.stopDrag();
if(clip.hitTestObject(Doll.Skins))
//Here's where the problem starts! ---------------------------------------------- //
trace(clip.name); // but that won't be Doll.Drawers.Dress1. it might be Dress1. -
Creating instances of a movie clip using Actionscript
I have a script that pulls a specified amount of Movie clips
from the library to the stage, and that part of my script works. I
want to add a button that will stop the movie clips but the Movie
clips do not have instance names since they were pulled onto the
stage from my script. I was wondering if anyone had an idea on how
I can do this.stop();
var _sixSidedDie:Dice;
chooseDice_btn.addEventListener(MouseEvent.CLICK, onClick1);
random_mc.addEventListener(MouseEvent.CLICK, onClick2);
random_mc.buttonMode = true;
function onClick1(event:MouseEvent):void
var diceTotal:Number = parseInt(totalDice_cb.text);
gotoAndStop(2);
for(var i:Number = 0; i < diceTotal; i++)
_sixSidedDie = new Dice();
_sixSidedDie.label = "SixDie" + i;
_sixSidedDie.name = "sixDie" + i;
addChild(_sixSidedDie);
if(i == 0)
_sixSidedDie.frame = 2;
_sixSidedDie.x = 96;
_sixSidedDie.y = 115.7;
else if(0 < i && i < 5)
_sixSidedDie.frame = 2;
_sixSidedDie.x = i * 168 + 96;
_sixSidedDie.y = 115.7;
else if(4 < i && i < 10)
_sixSidedDie.frame = 2;
_sixSidedDie.x = (i - 5) * 168 + 96;
_sixSidedDie.y = 276;
else if(9 < i && i < 15)
_sixSidedDie.frame = 2;
_sixSidedDie.x = (i - 10) * 168 + 96;
_sixSidedDie.y = 438;
else if(14 < i && i < 20)
_sixSidedDie.frame = 2;
_sixSidedDie.x = (i - 15) * 168 + 96;
_sixSidedDie.y = 598;
function onClick2(event:MouseEvent):void
event.target.sixDie0.gotoAndStop(Math.ceil(Math.random() *
6)); -
Multiple Preloaders for Multiple Movie Clips
Designed in Flash 8, the site's timeline is all in Scene 1
and is comprised of an introduction, which contains a short video,
and 6 movie clip categories that the user selects to view. Since I
want the intro to play as soon as possible, I'd like to limit the
first preloader to just the video in the intro and not
_root.getBytesTotal. Then, as the viewer watches this short video,
the rest of Scene 1 movie clips will keep on loading. After the
intro, the viewer will choose which of the 6 categories to view.
These categories are identified with buttons which play the
particular movie clip. Since I don't know the order of the
categories they will select, I thought there should be a separate
preloader for each category. Hopefully, after they view a category,
the rest of the categories will have loaded and the loading time
will be nil. The design for the preloader is comprised of a status
bar and a percent loaded. Is there a way to limit the
_root.GetBytesTotal to specific frames? I know I could break these
categories up into separate SWF files but then I loose the
advantage of one loading while another is being viewed.MovieClipLoader is a built in class of functions that will
allows you to easily load Media (swfs/jpgs) from external sources.
This will create a MCL object
var mcl:MovieClipLoader = new MovieClipLoader
We want the MCL object to receive events for any movie that
is loaded into the main timeline
mcl.addListener(this);
Ok. now we have a movie clip loader that is able to recieve
events. Since we want to show the progressive download and want to
do something with that content after it loads, we need to declare
two event handlers onLoadProgress and onLoadInit. onLoadProgress is
pretty straight forward. onLoadInit executes it's action as soon
all of the AS on frame 1 of its time has finished loading. In this
case, we want two different things to happen. 1st, load the first
clip and show it.... 2nd, load all remaining clips into the buffer.
But first, lets declare those next...
function onLoadProgress( target:MovieClip,
bytesLoaded:Number, bytesTotal:Number):Void {
// standard preloader code goes here
function onLoadInit( target:MovieClip ):Void {
// display the clip - this will be as easy as just calling
our loadClip function for the mcl...more on that in a minute
// If you want something special to happen, i.e. movie fades
in or a mask is applied to it, you'd do that here.
Now all we need to do is call the loadClip member function
for the MovieClipLoader. Just replace the two parameters with the
location of the swf and then the name of the instance you want it
to load into
mcl.loadClip( "myswf.swf", targetMovieClip );
The other movie clips are now a breeze as well. For each
button, just add an on(release) or onRelease = function (depending
on your situation) to just call that mcl.loadClip() line from up
above. Just change the movie you want loaded.
Let me know if you need more help... -
Using one instance of a Movie Clip to load Graphics from library
Hi all,
another question... How would i go about loading a variable into a movie clip and have it pull different graphics from my library at different spots in the main timeline???
thanks!
PatrickHi NED! thank you for all your help so far!!!
I was wondering about the flexability of loading movies into a movie clip.
Currently, thanks to your help i am well able to load one movie into a movie "loader" clip, but thought maybe there is a way to load additional movie clips into that same "loader" clip, as i am starting to accumulate several different graphics that i need to have be inside movie clips so that i can make them change colors on the same frame when needed.
i shot from the hip and tried this code, but didnt have any luck:
mc_LCD_loader.attachMovie("hilight", "g", 1), ("header", "X", 1);
mc_LCD_loader.g._x = 0;
mc_LCD_loader.g._y = 1000;
mc_LCD_loader."X"._x = 0;
mc_LCD_loader."X"._y = 1000;
- - - where "hilight" is the identifier name of a given movie clip and "header" is the identifier of a given movie clip in the same library...
"hilight" loads fine
i dont fully understand what "g" means to the identifier...
i am just unsure of how or if it is even possible to load another MC into the same MC Loader...
is it possible? if so could you give me a hint?
thank you!
- patrick -
Adding thousands of instances of a movie clip
I am trying to add around 20,000 instances of a single small
movie clip (HexTile) from the library into a container Sprite using
actionscript. The problem is it loads immediately and it loads very
slowly, so I would like to know if there is a way to preload it?
The class that adds the movie clip library symbol (World) is not
the document class, nor is it referenced from the document class. I
have tried dragging an empty sprite linked to World, and I have
tried exporting it to other frames as well is preloading it as it's
own .swf...any suggestions would greatly appreciated! The code
looks like:Hi
I guess you can one thing. add dummy pre-loader before loop
and then just hide it after loop ;) -
Where is the date for my movie clips?
In the previous version of iMovie when you clicked on a movie clip you could see the date near the preview window. Now in iMovie 6 you have to double click on the clip to get the date info. Anybody else notice this. I thought it was useful to have the date there for putting clips in time order...
Mac OS X (10.3.9)Notice that the displayed time is the value of the very first frame of the underlying media clip. I.e. if you split the clip at the playhead, ALL the splitted clips still point to the same time.
iMovie 2.1.2 did this right by always showing the correct time even with splitted media clips! -
Single droptarget for multiple movie clips
I have a movie clip which i use as a drop target. And I have four additional movie clips which can be dragged and dropped into the droptarget movie clip. But when I place a movie clip into a droptarget and I drop the second one too, the droptarget for the second one becomes the first movie clip but not the actual droptarget movie clip.
Please suggest.Thank you for the reply. Can you give me an idea what the below code does?
mainContainer is a movie clip. mc1, mc2 are three movie clips
mainContainer.addChild( mc1 );
and while dropping mc2
mc2._droptarget - what this will refer to? -
ICloud vs YouTube: what's best for storing movie clips?
Hello all, I'm looking for pros and cons of using either of them. With my iPhone I am regularly recording movie clips that a few minutes, and need to store them somewhere and share some of them with specific user. I have an iMac running 10.6 as well.
I am considering YouTube as it is directly integrated with iOS camera but i am wondering what are the limitations in terms of data size. I currently store the 150-350 MB movie clips on my iMac and i've got around 30 of them. But i plan to make more (up to 100?) and to make some space on my Mac.Thanks for the information about iCloud storage, Julian.
However, the purpose of this thread is more to compare online storage solutions and share experience about their online storage rather than talk about iCloud or YouTube (can an admin change the title?). What vendor do you use? What video format? How big are your files? Satisfied with it?
Bellow is a storage vendor comparison from CNET :
http://reviews.cnet.com/8301-13727_7-57428396-263/cloud-based-storage-options-fo r-mac-os-x/
Most of my move clips are actually lower that 150 MB. But somestimes it is higher and when I tested Dropbox, it would not accept a file bigger than 300MB, and 2 GB storage free is quite low.
Therefore, I will most likely choose upload via YouTube as private or unlisted. It looks like the limit is 2GB in size and 15 minutes maximum per file. There is some tuning that is recommended on Mac:
http://support.google.com/youtube/bin/answer.py?hl=en&answer=1297408&hl=en-U S
Thank you. -
How to use common event handler for selected movie clips?
I have a 50-state map in a flash movie. Each state is a movie
clip.
Goal: when mouse moves over a state or is clicked in a state,
the state will be highlighted in a bright color and a small box
will pop up near the state and display some information about the
state.
Question: I know I can add mouse event handler for each state
movie clip. But this is simply not good since this has to be done
50 times and codes thus scattered different places. Ideally, I only
want to have one script that determines where the mouse position is
when events trigged and then do right things (highlight the state
and display info. in a pop-up). How can this be implemented?
Thanks!There are a number of ways. Which way is best depends on how
you have things set up so far.
E.g. If they have an enumerable naming convention:
e.g. each clip is like state_0 , state_1 etc.
Then you can loop through them and assign them all to the
same mouse event handler via the loop. You would need properties
other than the name of the clip to identify the state. E.g. each
clip could contain its own data or the index could be a pointer to
the state data (objects with state name and info properties) in a
separate array.
//state clips named
for (var i=0;i<50;i++) {
this["state_"+i].stateindex=i;
this["state_"+i].onPress= statePressHandler;
var stateData:Array = [{name:"StateName,info:"this state
Info"}, name:"StateName,info:"this state Info"}, etc...]
function statePressHandler() {
trace(this);
trace(stateData[this.stateindex].name+"="+stateData[this.stateindex].info);
Other ways are possible too but the best approach depends on
how you have named the clips and whether you're creating them with
code or whether they're already on stage from authoring (my guess).
If they're already on stage and they're called "Alaska" etc, then I
would be inclined to put them all inside a container clip that
contains nothing else other than states. It would avoid the need
for an array of clip names or for checking some other specific
property of each clip to determine if its a 'state' clip and not
something else in a for..in loop.
Maybe you are looking for
-
Error while executing procedure from the web
Hi, <p> I am developing some procedures that I want to execute from an html form. The problem is that when I am trying to execute it in SQL Developer I got the following error:<br> Connecting to the database oracle.<br> ORA-06502: PL/SQL: numeric or
-
Apple tv keeps asking for store verification?
My apple tv keeps asking me to verify my account on my {mac] pc but the account works fine on the PC so I cant download movies directly to my apple tv unit ?? anybody help ?
-
Auto Clear History/Start in Private Browsing?
I have been using Firefox, but with the release of Lion it just does not look as good as Safari. The full screen mode and scroll bars are much more appealing in the Safari browser, so I am considering switching. My only hitch is that I am unsure of h
-
trying to add album from iphoto into idvd slideshow. Not all photos are loading. Message "creating thumbnail images...(31 remaining). Been there a long time. What is wrong?
-
What is diff between oracle application server and weblogic server?
what is the exact difference between oracle application server and weblogic application server?