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 ;)
Similar Messages
-
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 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. -
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 KumarYou 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: -
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)); -
Adding one audio file to multplie movie clips
Hi all
I have two movie clips in my project and I was successful on adding music to one clip. Now how can I make this same audio file last the duration of both movie clips? I want to add the single audio to both. Thanks, web dudeI want to add the single audio to both.
Place another copy at the end of the first. -
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 small photo in corner while movie clip is running
Hey,
This is my first time using Imovie 08' and I'm a little confused. What i'm trying to do is place a small .gif in the bottom left corner of a movie clip, almost like a title. I have tried placing the picture into the title, but that only supports fonts, not .jpeg or .gif files. When i try placing the picture over the selected clip itself, the picture just takes up the whole screen, covering up the existing clip. Help would be much appreciated.
BenWhen i try placing the picture over the selected clip itself, the picture just takes up the whole screen, covering up the existing clip.
Clips/pictures are automatically scaled for the project resolution and aspect selected that was user selected. You basically have two options:
1) You can create your image in a graphic application on a canvas of the same resolution and aspect ratio as your iMovie '08 project and in the location desired, export your image in an alpha-channel format (e.g. PNG), drop/add it to the project as a still frame sequence, reset the duration, and "clone" it as needed for continuous or periodic display.
2) If you want it displayed for the entire length of your video and you have QT Pro, I prefer to simply use the "Add to Selection & Scale" Edit option in QT Pro on the finished project export. (In this case you only need to create your image on a canvas large enough for the image at the approximate size you want it to display since you can independently scale and position the image anywhere within the display screen area. -
Adding two more Star Trails in movie clip
Hi All,
I bought a flash file the other day which i plan to modify and use for an intro to a project i am working on. Currently there is one instance of a Star which follows a path and emits "sparkles" while tracing the path. I would like to add two more stars/ paths. I tried modifying some of the code, and am working through it, but wanted to know if anyone could help me out a bit.
thanks!
Patrick
import flash.filters.*;
//--------------variables to change--------------------------//
//modify the size of the sparkles
var maxSparkSize:Number = 25;
var minSparkSize:Number = 8;
//set the speed the sparkles fade, 0 is never fade,the higher number quicker the fade
var fadeSpeed:Number = 1//5;
//speed which the sparkles fall, 0 is no fall, the higher the number the quicker the fall
var fallSpeed:Number = 0.5;
//the speed which the particles drift sideways. 0 gives no drift, positive numbers give right drift
// negative numbers give left drift
var windSpeed:Number = 0;
//change the colour
var randomColour:Boolean = true;
defaultColour = 0xFFcc00;
// the path to the followe_mc
path = this.holder_mc.follower_mc;
path = this.holder2_mc.follower2_mc;
//you do not need to modify the code below here...
var sparkle:Number = 0;
var mousePosX:Number;
var mousePosY:Number;
var whichBat:Number;
var count:Number = 0;
this.createEmptyMovieClip("empty",this.getNextHighestDepth());
//make the shape on top of the sparkles
path.shape_mc.swapDepths(1000);
startSparkles();
function startSparkles() {
this.onEnterFrame = function() {
var pathX:Number = path._x;
var pathY:Number = path._y;
xPos = randRange(pathX-2, pathX+2);
yPos = randRange(pathY-2, pathY+2);
createSparkle(xPos,yPos);
function createSparkle(xPos, yPos) {
movingSparkle = this.attachMovie("colouredSparkle", "s_"+sparkle, sparkle+10);
movingSparkle2 = this.attachMovie("colouredSparkle", "ss_"+sparkle, sparkle+101);
sparkle++;
if(sparkle>100){
sparkle = 0;
setParams(movingSparkle);
setParams(movingSparkle2);
function setParams(movingSparkle){
//position the sparkle
movingSparkle._x = xPos;
movingSparkle._y = yPos;
//set initial size
movingSparkle._xscale = movingSparkle._yscale=Math.random()*maxSparkSize+minSparkSize;
movingSparkle._rotation = randRange(0, 360);
if (randomColour == true) {
col = Math.round(Math.random()*0xFFFFFF);
} else {
col = defaultColour;
colouredFill = new Color(movingSparkle.colour_mc);
colouredFill.setRGB(col);
colouredFill = new Color(movingSparkle.white_mc);
colouredFill.setRGB(col);
moveSparkle(movingSparkle);
function moveSparkle(movingSparkle) {
var rot = randRange(-15, 15);
var blurX = randRange(1, 5);
var blurY = blurX;
var blurFilter = new BlurFilter(blurX, blurY, 3);
//add some blur to the sparkle to make it softer
movingSparkle.white_mc.filters = [blurFilter];
//calculate the amount the sparkle will fade
var alphaDrop = randRange(1, fadeSpeed);
//commit the movements...
//this onEnterFrame moves the spark, rotates it, scales it and fades it.
movingSparkle.onEnterFrame = function() {
//change speed
this._y += fallSpeed;
this._x += windSpeed;
//change rotation
this._rotation = this._rotation+rot;
//make it smaller
this._xscale = this._yscale=this._xscale*0.98;
//fade the sparkle
this._alpha = this._alpha-alphaDrop;
//remove the movieclip if it get tiny
if (this._alpha<10) {
this.removeMovieClip();
if (this._height<4) {
this.removeMovieClip();
function setColour(mc, col) {
colourIt = new Color(mc);
colourIt.setRGB(col);
function randRange(min:Number, max:Number):Number {
var randomNum:Number = (Math.random()*(max-min))+min;
return randomNum;1 ) Increase the FrameRate (or)
2 ) Call the createSparkle(xPos,yPos); function more than once with new randRange -
Removing movie clips with added children
If I have a movie clip added as a child to another movie clip
on the stage, and I remove it's parent, and null all references to
the parent, will both the parent and child movie clip be deleted by
the garbage collector? If so, will it be done on it's regular pass
or by mark and sweep?OK, so if I add a movie clip like this:
function addMovie()
var toAdd:MovieClip = new Example(); // example extends
movieclip
this.addChild(toAdd);
I'm assuming that toAdd will be nulled when the function is
complete, because it's a local variable. Then if I put code inside
the movie clip at a certain frame or in a function in the class
Example to get rid of it:
this.parent.removeChild(this);
I'm assuming that's all i need to do to get rid of it. I
can't null the instance of the class Example using this = null from
inside it, and the only reference to it is the child reference from
the parent.
Am I right or is there more I need to do to make the instance
of example eligible for GC? -
Video fading in, but not out in movie clip.
Hi.
I need to run a video which I can turn off and on on top of other flash content.
Since I also need to add sub titles I decided to import the video clip into a movie clip. The movie clip now has as many frames as the video.
I added the subtitles by keyframing a text line in the movie clip and synched it up with the movie. (this was not real easy..)
I placed an instance of the movie clip on my main stage in frame 10. I added an on and and off button that simply would take you to a later frame without the movie clip instance, and back to frame 10 again if you want to see the video again. This worked well.
To make the transistions elegant I wanted to fade the video in and out. So on the main stage in frame 10 I placed this action script:
(+ gave my movieclip the instance name mc)
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var myTween:Tween = new Tween (mc,"_alpha",Strong.easeIn,0,100,2,true);
which nicely fades the video in when the playhead gets to frame 10.
There is another part of the script that should be able to tell the upcoming end of the movie clip and fade it out:
myTween.onMotionFinished = function () {
new Tween (mc,"_alpha",Strong.easeOut,100,0,2,true);
This however I can not get to work:
1) If I place this code in frame 10, the video first fades in but immideately fades out again.
2) I tried to put the code 15 frames from the end of the movie clip, and that did not work.
3) I tried to put the code 15 frames from the end of the movie clip and add _parent. and that did not work either.
Can this be made to work, and if so how?
If not, please let me know if you have any other proven approach to suggest.
ggaardeHi Ned
This does not work for me.
Again the instance of the movieclip is on the main timeline in frame 10 with stop action
I have put the code you suggested in frame 13 of the main time line. also with a stop action.
Then in the movieclip I have put this code approx 100 frames from the end of the clip:
_parent.gotoAndPlay(13);
How else would he main movieclip know when to start the fadeout?
The myTween.onMotionFinished = function should maybe detect it, but i have not had luck using it. The only time it works is like described in my first post, but it triggers right away and fades out as soon as it is done with the fade in.
Is there a way to tell it on which frame in the mc it should start the fade out?
ggaarde -
How do I recerence Movie Clips on the Main Timeline from inside a class?
Hey everyone, this might be a stupid question but I thought
I'd ask cause it's making me nuts. I'm all of 2 days into AS3
(coming from not using Flash at all in YEARS) so feel free to
consider me ignorant. I do have plenty of application development
experience in other areas though.
I can't seem to create a class that can reference an instance
of a movie clip on my main timeline. I'd post code of what I've
tried but I've gone through so many desperate edits & wild
guesses that it was just garbled junk before I deleted it all.
Basically here's how I figured Flash could work, though maybe
it doesn't work this way at all.
I'm assuming that with AS 3 being so big on being a true
object oriented environment, I wouldn't need to mix my code and
interface together. Preferably I'd be using the Flash authoring
tools just to design my interface. Create a button... place it
somewhere... give it an instance name. Roughly the equivilant of
Apple's InterfaceBuilder for those of you that might be familiar
with Cocoa development. I can see maybe having to put a few lines
of ActionScript onto frame 1 (though really I'm hoping Flash would
have a better method of kicking off the application at this point
that using code tied to frames) to load my classes & such, but
after that I'd like all of my code to be held in external class
files.
So maybe I've got:
Interface.fla - My interface
Button_1
Button_2
TextField_1
Main.as - My main controller class using to handle all of my
applications behavior
SomeClass.as - Some helper Class
SomeOtherClass.as - Some helper Class
Main.as would have instructions in its initialization method
to go ahead & attach events to buttons & initialize
anything else that needs to happen when the application starts.
From there on it would all be objects communicating back &
forth. Button_1 would get clicked with would fire
Main.someMethod(). Main.someMethod() would then do it's thing and
set the value of TextField_1. All very clean & code is very
separated from interface.
Unfortunately I can't for the life of me figure out how AS3
classes reference each other like that. There doesn't seem to be
any kind of a global 'root' or '_root' I can use to locate any
movie clips on the stage. I've searched the help & the web for
any kind of simple tutorial but to no avail. My job has tasked me
with building a flash app for a project but I'd really rather not
have a tone of ActionScript just shoved into frame 1. That just
seems... ugh! (::shudder::)
Can someone maybe point me in the right direction here? I'm
really willing to do my homework but I can't seem to locate the
info I need to get started. Also, is there an ActionScript IRC
channel or something maybe?
Thanks,
CliffI worked with the problem last night and the solution I
started coming to involved creating my own custom document class
based off which extends MovieClip. My thought is that way I have
access to the initialization routine of the timeline itself and
that all of the elements on the main timeline should be
"properties" of my custom class.
Is this correct? Is there a down side to doing this & if
so what is it & why?
Also, just for my reference, the last time I did anything
with ActionScript I think I was using '_root' to target the main
timeline. WHat are the global variable names in AS 3? Is it just
'root' & 'stage' or 'Root' & 'Stage' or what? -
hi,
I recently downloaded a flash template that was built on AS2
and have been trying to figure out how it works for a couple of
weeks now (excuse my ignorance when it comes to AS). I have a
question about nested Movie Clips. The way the template is
constructed invovles a massive amount of nested movie clips and a
large number of instances of each movie clip. The way i understand
it is that if an instance of a movie clip is put on the stage and
given an instance name, any modifications to that movie clip should
be unique to that instance. However when i modify the colour of any
of the movie clips i select, it changes the colour of all other
instances.
Am i missing something obvious here??
Thanks in advance for your help
Kind Regards
DamienYea. This particular template i am working with appears to
change and manipulate colours dynamically as you said. Also it
doesn't have all of the content (txt and images) within the actual
flash document. They are all loaded dynamically through a txt
document and external files (jpgs amoungst others) which makes it
alot harder to edit since i dont fully understand the xml format
they have in the txt document. As well as this, the template has
no, and i mean NO documentation what so ever which makes it much
more difficult to work through. But i guess i will keep pluggin
away at it :)
Thanks again for your help Ned
Damien -
Loading Movie Clip from a button
Hi,
How do I load a movie clip from a button? So far on my button
(b1), I have this AS: and I want the button to load the movie clip
"char1." My button already has some AS:
b2.onRollOver = function() {
_root.captionFN(true, "Hi!", this);
this.onRollOut = function() {
captionFN(false);
How would I go about adding more script to load a movie clip
to my button b2?
ThanksHey - Unfortunately I'm going to be in meetings for most of
the day, so
it'll take me a while before I can go through this in any
detail. One thing
that struck me though is that your two functions (captionFN
and
hoverCaption) are in the main1_mc not on the main timeline.
Then the
buttons are calling _root.captionFN(); which refers to the
main timeline.
I would expect that they should be calling
_root.main1_mc.captionFN(),
because that is the path to where the function is. Does that
make any
sense?
One thing that I do when I'm writing code is to always keep
all functions on
the main timeline. That way you are sure that they are being
registered
(i.e. if you call a function before the playhead reaches
where that function
is written, the function won't work. If the function is in
the first frame
of the main timeline, you know that the playhead has reached
it). What you
might want to do is to move all your functions to the very
first frame of
your movie. Then you can call them with the path:
_root.myFunction() and
you are sure that they will be found.
Maybe give that a try and let me know if it helps. In the
meantime, I'll
try to go through your code, but like I said, today's a bit
of a gong show
for me.
Sorry - I don't mean to just sluff you off or anything.
Cheers,
Brock
"respondplease" <[email protected]> wrote in
message
news:[email protected]...
> Hi Brock,
>
> Thanks again, your sample file really helps but I'm
still having problems.
> What it boils down to is that my buttons don't fully
function properly. It
> works correctly sometimes, but not consistently enough.
So if I fast
> forward
> too much or rewind and then FF, the buttons aren't
either isn't clickable
> or
> the hover text and caption box doesn't show up, etc.
This usually happens
> when
> I press FF too many times or too fast. But regardless of
how many times I
> press
> FF I would like my buttons to work
>
> Your sample file is very useful but unlike mine I have
perhaps too many
> MC's
> w/in MC's, etc. I will try to clarify my setup in hopes
of finding a
> (better)
> solution to my problems. My main timeline has my "prev",
"next", and
> "pause"
> buttons which also has the actionscript for my NEXT
BUTTON, PREV BUTTONS.
> And
> now I've added your SHOW BUTTONs function as well. I've
minorly modified
> your
> showButtons function adding a couple of more lines and
actually deleting
> the
> _root because I found that it doesn't work sometimes.
Anyhoo, here it my
> entire
> code in one frame on my main timeline:
>
> // ===== NEXT BUTTON ===== \\
> next.onPress = function() {
> _root.screen.showButtons();
> _root.createEmptyMovieClip("controller_mc", 1);
> controller_mc.onEnterFrame = function() {
> _root.screen.gotoAndPlay(_root.screen._currentframe+10);
> if
(_root.screen._currentframe+10>_root.screen._totalframes) {
> _root.screen.gotoAndStop(_root.screen._totalframes);
> }
> };
> };
> next.onRelease = function() {
> controller_mc.removeMovieClip();
> _root.screen.showButtons();
> };
> next.onReleaseOutside = function() {
> controller_mc.removeMovieClip();
> _root.screen.showButtons();
> };
>
> // ===== REWIND BUTTON ===== \\
> prev.onPress = function() {
> _root.createEmptyMovieClip("controller_mc", 1);
> controller_mc.onEnterFrame = function() {
> _root.screen.gotoAndStop(_root.screen._currentframe-10);
> if (_root.screen._currentframe-10<1) {
> _root.gotoAndStop("screen");
> }
> };
> };
> prev.onRelease = function() {
> controller_mc.removeMovieClip();
> };
> prev.onReleaseOutside = function() {
> controller_mc.removeMovieClip();
> };
> // ===== SHOW BUTTONS ===== \\
> function showButtons() {
> for (i=1; i<=6; i++) {
> _root["b"+i]._visible = true;
> _root["char"+i].removeMovieClip();
> chars._visible = true;
> cap.desc._visible = true;
> cap._visible = true;
> }
> }
> Still from my main timeline, my main1_mc is called from
the frame labeled
> "screen." My main1_mc has the b1 - b6 buttons which has
the HOVER CAPTIONS
> and
> HIDE BUTTONS FUNCTION coding. And each button calls each
movie clip ie.
> char1_mc, char2_mc, etc. Here's all my code on one frame
(in my main1_mc):
> // ===== HOVER CAPTIONS =====
> b1.onRollOver = function() {
> _root.captionFN(true, "pick me!", this);
> //display the function (true) or to hide the function
(false)
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char1_mc", "char1",
_root.getNextHighestDepth(),
> {_x:595,
> _y:345}); //this attaches movie to the _root timeline,
and renames it to
> "char1".
>
> _root.char1.swapDepths(_root.cursor_mc);
> //swaps the depth that the cursor is on and the new
movieClip is on. So
> the
> cursor will stay on top.
> };
> };
> b2.onRollOver = function() {
> _root.captionFN(true, "Hi!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char2_mc", "char2",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b3.onRollOver = function() {
> _root.captionFN(true, "Get Jac'd Up!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char3_mc", "char3",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b4.onRollOver = function() {
> _root.captionFN(true, "Boo!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char4_mc", "char4",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b5.onRollOver = function() {
> _root.captionFN(true, "I'll be your guide", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char5_mc", "char5",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b6.onRollOver = function() {
> _root.captionFN(true, "Welcome!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char6_mc", "char6",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> _root.captionFN = function(showCaption, captionText,
bName) {
> if (showCaption) {
> createEmptyMovieClip("hoverCaption",
this.getNextHighestDepth());
> cap.desc.text = captionText;
> // cap._width = 7*cap.desc.text.length;
> cap._alpha = 75;
> if ((bName._width+bName._x+cap._width)>Stage.width) {
> xo = -2-cap._width;
> yo = -17;
> } else {
> xo = 2;
> yo = -17;
> }
> hoverCaption.onEnterFrame = function() {
> cap._x = _xmouse+xo;
> cap._y = _ymouse+yo;
> cap._visible = true;
> };
> } else {
> delete hoverCaption.onEnterFrame;
> cap._visible = false;
> }
> };
> // ===== END OF HOVER CAPTION ===== \\
>
> // ===== HIDE BUTTONS FUNCTION ===== \\
> function hideButtons() {
> for (i=1; i<=6; i++) {
> this["b"+i]._visible = false;
> }
> chars._visible = false;
> cap.desc._visible = false;
> }
> Sorry for copying and pasting all my code - I know it
must be annoying,
> but I
> can't seem to find what's wrong. Again, ANY help would
be greatly
> appreciated.
> Thanks for your patience. Your talent is very much
appreciated and I'm
> very
> grateful for all your help.
>
> Kindest regards
> -
AS3: Checking if movie clip chiled is added
hey,
I have few movie clips that are added and removed automaticly by users choice. The problam is I can't find a correct "if" condition that will check if the movie clip exists before I remove it. This is the part of the code:
function removeAnimation():void {
if(Boolean(getChildByName('wheelChair'))){
removeChild(wheelChair);
chairTimer.stop();
I tryed getChildByName and everything I could find in google and came up empty.
Any help will be appriciated.Just on the chance that it might apply, since you do use the wheelChair as an instance name in one line, try the following...
function removeAnimation():void {
if(contains(wheelChair)){
removeChild(wheelChair);
chairTimer.stop();
Maybe you are looking for
-
i am using this formula {USR_CR_RISK_CHANGE;1.DETAIL}[instrrev({USR_CR_RISK_CHANGE;1.DETAIL},'OLD: LowRisk')-1 to length({USR_CR_RISK_CHANGE;1.DETAIL})]; this retrieves OLD: LowRisk NEW: MediumRisk which is what i want i want to then get a count of h
-
Native essbase and admin services
My users are only using Essbase, the AAS Console, and the Excel Add in. It dosn't make much sense to install any additional Hyperion components if they are not used. As a result, I'm considering installing a native version of Essbase 9.3.1. and Admin
-
Edge Animate 1.0 Install Error
After removing Edge Animate Preview 7 program by dragging the application icon to a wastebasket icon on Mac OS, new version Edge Animate 1.0 does not installed. When installing it with Adobe Application Manager that shows an error message: Delete pre
-
How Do I Pause Slide Show in Screen Saver?
How do you copy a screen? I have forgotten the command
-
If the battery pack is ruined do you think the computer will turn on if I use the charger
If the battery pack is ruined do you think the computer will still work and turn on if I use the charger