Sizing an empty movie clip
Hi There,
I have an instance of an empty movie clip object
(imageLoader) to which I load a .jpg image from an external file,
as per the attached code . . .
But I have a problem in that I do not know the dimmensions of
the .jpg image before I load it and in some cases this results in a
large image covering most of my screen, including some of the text
on the screen, I simply can't have this as it looks crap for a
start!
So, my question is this . . . How do I force the image pulled
in from the external file, and/or the movie clip object, to be no
larger than a certain size (i.e. H: 177 pixels x W: 177 pixels)?
I guess Loader will work fine for you, but you might want to
have a look
at the loadInit method of the MovieClipLoader class. That
will allow you
to do what you want also - you just size your holder clip to
whatever
you like - the trick is that you need to wait until the new
clip is
fully loaded and instantiated - exactly what loadInit does
for you.
Dave
Similar Messages
-
Making a loadmovie in an empty movie clip
Hi. I'm making a new as3 file, and there i made an animation, like an intro for my website, in a movie clip. But what i want is, when this animation or this movie clip ends, automatically it charges another swf with my website, without having to press any button. I read some tutorials on internet that i can make this, creating a new empty movie clip, and then writing some code, but it didn`t work me. Please can anybody help me with the exact code i have to write? I will appreciate so much that, because i'm new in this as3 topic. Thanks so much for ur time.
All you need to do is pull the code out of the function...
stop();
var loader:Loader =new Loader() ;
addChild(loader) ;
loader.load(new URLRequest("whatever.swf"));
loader.x =0
loader.y =0
And you mentioned adding the loaded object to a movieclip, so if you still plan to do that then give the movieclip an instance name and use it's name to add the loader to it instead of what your code does above...
Change: addChild(loader);
To: mcName.addChild(loader); -
Empty Movie Clips - Navigation Issue
I'm pretty new to site building so bare with me.
I'm building a site with empty movie clips on each page to
provide navigation to other pages. I'm testing linkage between two
pages, (home page and news page) When I load the home page,
everything works fine, I click the link to my news page, and it
loads in fine, BUT when I click back to home from the news page,
the home page starts playing nested movie clips that should NOT be
auto-playing.
So basically, I have nested movie clips that decide to play
when I click to my home page from another page. If I load the home
page by itself however, it functions properly. Why are these nested
clips playing?
Here is the action script for the nested movie clips as an
example:
_root.rightChair.onEnterFrame = function() {
if (mouse_over_rightChair) {
_root.rightChair.nextFrame();
} else {
_root.rightChair.prevFrame();
Basically they should not be playing unless a mouse rolls
over them.
Thoughts anyone?
-Stephen:
-
Empty Movie Clip Shows White Box before Movie Loads
Hi all!
I created a type of slide show template that imports external
swfs. Everything works, but the client doesn't like the white box
created by the empty movie clip that appears before the external
swf loads. Does anybody know how to get rid of this? Any assistance
would be greatly appreciated!
Sincerely,
rs> I created a type of slide show template that imports
external swfs. Everything
> works, but the client doesn't like the white box created
by the empty movie
> clip that appears before the external swf loads. Does
anybody know how to get
> rid of this? Any assistance would be greatly
appreciated!
Hi there rs
Forum archives:
http://groups.google.com/advanced_group_search?q=group:macromedia.flash.*&hl=en&lr=&ie=UTF -8
search for "white box"
http://groups.google.com/groups?as_q=white+box&num=10&scoring=r&hl=en&as_epq=&as_oq=&as_eq =&as_ugroup=macromedia.flash.*&as_usubject=&as_uauthors=&lr=&as_drrb=q&as_qdr=&as_mind=1&a s_minm=1&as_miny=1981&as_maxd=28&as_maxm=9&as_maxy=2006&safe=off
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Hi,
I work for with Flash CS5 for an advertising company. We make banners and my job is to animate them. Lately I have been having a weird issue.
When I work on a flash file all is well, I save export and all, but later when I come back to the file for modifications some of my elements are disappearing?! Most of the elements are imported from illustrator CS5 and they seem OK when I leave but when I come back I see just empty Movie-Clips.Things seem to disappear without any logic, for example some text layers can disappear while some don’t.
This issue is frustrating since it's causing much work and I would really love to resolve it.
Can anyone guide me as to what I should do. I will gladly provide any info needed.
Thank you.that's a task much easier to do using actionscript rather than use the timeline. each location or parent location (if you want one parent for retail and one for residential etc) could have two keyframes. one for highlighted locations, the other for non-highlighted. you can timeline tween between the two keyframes, if you want.
your main timeline would not change frames. clicking the retail toggle button would cause all retail locations to tween to the highlighted frame. clicking it again, it should cause the retail locations to tween to the non-highlighted frame.
likewise for you other buttons and other locations.
this setup will remove the complications caused by having various combinations of buttons toggled on and off. -
Attaching an embedded movie clip to an empty one
HI,
I am new to Flash and would like some help about the
following. A have an embeded movie clip in my library that i want
to attach to an empty movie clip I am creating with ActionScript. I
want to fix the size of the empty movie clip, that I will use as a
container to for my embedded movie clip. It turns out that when I
fix the size of the empty movie clip container and I use
attachMovie to load the embedded movie clip to it, the image
doesn't show, I can hear the sound but not the image.
So the question is , if I have a movie clip container of a
different size than the movie clipse I want to load into it, what
do I need to do to make sure the movie clip will fit into the empty
container.
thanks
-malenaThanks for the answer, but what I would like to do is to have
a FIXED size empty clip on the stage and be able to load new clips
into that empty clip and have the loaded clips resize to fit into
the empty clip.
For example the FLVPlayback component does that
automatically. I can't use the FLVPlayback component because I want
to be able to control which frame number I want to displaly on the
screen, and it looks like I can only have that type of frame level
control wiht a Movie clip component but not with the FLVPlayback
component.
-malena -
Can't get Simple button to Load Movie Clip
Hi I've looked around for the answer to my question on this
forum
but havent found it so here it goes. I am working on this
company's
Flash site that was built by an outside studio. I am using
CS3.
The url to the site is
http://www.bubbakeg.com.
(this link will take you to the main page click the shadow
graphic
on the left under Bubba and this will take you to the site I
am speaking
of. The site is basically 5 different pages or movie clip.
What I am
trying to do is basically change the "Spring Break" middle
graphic
(which is a Movie Clip) on the HOME page and add a simple
button
that will direct the user to a new page. When I replaced the
graphic
with a new Movie clip there was no problem but I have added
a
button to load a new page (movie clip) and nothing happens.
This
button is in the movie clip of the new graphic which is
called up
when the page loads. If i take this button and just put it
on the
Main Stage in Scene 1 by itself it works and loads the page
(movie clip). It does not however when it is embeded in the
Movie
Clip. The Flash site is basically 5 different Movie Clips
loaded into
an "Empty Clip". This empty clip has a timeline with each of
the
clips labeled and with their respective sized placeholders.
And
when you click on either the links on the Nav bar or the
graphic
for each page it loads that movie clip on the main page. It
seems
like the button only wants to work on the main timeline. I
have
even replaced the code for the "Contact" button with the code
for the new button and it worked (opening new page). Here is
the
code for the new button that does not work:
on (release) {
_root.contentHolder.myHeight = 307;
_root.contentHolder.newLoc = 9;
heightAnimation();
I know the location and height from the above code are
referring to the placement and sizing of each movie clip
in the "Empty Clip". As i said before this heightAnimation
and the resizing of the new clip works fine when the
button resides in Scene 1 on the Main Timeline but not
within the new movie clip (graphic Ive created.)
I will upload the main chunk of the code that resides
in Scene 1 on the first frame of the "Actions" layer.
If anyone has any ideas I would appreciate it very much!
Please let me know if I can provide anymore info.
Thanks!
Gregchange:
function newLayerBT_CLICK(MouseEvent):void{
to:
function newLayerBT_CLICK(e:MouseEvent):void{ -
Movie clip resize not working when image is loaded
Hello,
I'm having some strange luck in building an image slide
show. I load the image paths into an array from an XML
page and then step through the array elements w/ forward and
back buttons.
I have an empty image clip on the stage where I create an
empty movie clip inside each time a new image is loaded. I load the
image into the second movie clip like this:
[code]
_root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader.unloadMovie();
_root.picsPage_mc.mc_pic_loader.createEmptyMovieClip(
'mc_individual_pic_loader', 1 );
_root.load_movie_and_stop(
_root.picsPage_mc.mc_pic_loader.mc_individual_pic_loader,
_root.photo_array[_root.photo_index].image,
_root.picsPage_mc.mc_pbar, 'regular_load');
[/code]
The load_movie_and_stop function is as follows:
[code]
function load_movie_and_stop( target_mc:MovieClip,
movie_clip_to_load:String, p_bar:MovieClip, action:String )
mc_loader._width = 0;
mc_slider_bar.mc_drag_pan._x = 0;
if( action != 'simple_load' )
p_bar._visible = true;
p_bar.bar._width = 0;
var mclListener:Object = new Object();
mclListener.onLoadStart = function( target_mc )
if( action != 'simple_load' && action !=
'regular_load' ){ target_mc.stop(); }
if( action == 'load_and_play' ){ target_mc.play(); }
mclListener.onLoadInit = function( target_mc )
_root.resize_movie_clip(target_mc, 160, 120, 250, 190);
if( action == 'load_and_stop' ){ target_mc.stop(); }
mclListener.onLoadProgress = function( target_mc )
if( action != 'simple_load' )
percentLoaded = Math.floor( (
target_mc.getBytesLoaded()/target_mc.getBytesTotal() )*100);
p_bar.bar._xscale = percentLoaded;
p_bar.txt_percent = percentLoaded + "% loaded.";
mclListener.onLoadComplete = function( target_mc ){
p_bar._visible = false; }
var my_mcl:MovieClipLoader = new MovieClipLoader();
my_mcl.addListener(mclListener);
my_mcl.loadClip( movie_clip_to_load, target_mc );
}//___endFunc___
[/code]
After the image is loaded into the movie clip, I then resize
the image to be a specific width.
The image resizing is done w/ this function:
[code]
function resize_movie_clip(clip_loader_name:MovieClip,
max_width:Number, max_height:Number )
orig_width = clip_loader_name._width;
orig_height = clip_loader_name._height;
aspect_ratio = orig_width / orig_height;
if( (orig_width > max_width) || ( orig_height >
max_height ) ) // If either dimension is too big...
if( orig_width > orig_height ) // For wide images...
new_width = max_height;
new_height = new_width / aspect_ratio;
else if( orig_width < orig_height )
new_height = max_height;
new_width = new_height * aspect_ratio;
else if( orig_width == test_height )
new_width = max_width;
new_height = max_width;
else { trace( "Error reading image size."); return false; }
else { new_width = orig_width; new_height = orig_height; }
clip_loader_name._width = Math.round(new_width);
clip_loader_name._height = Math.round(new_height);
[/code]
Now, 98% of the time this works perfectly, but there is some
certain times where the image resizing is completely ignored and
the image gets loaded as it's normal size.
Can anyone see why the image sizing get's ignored in some
instance?
Thanks for any help,
ClemFound the solution that worked (used ._xscale and ._yscale
instead of ._width and ._height
[code]
function resize_movie_clip(clip_loader_name:MovieClip,
max_width:Number, max_height:Number, center_offset:Number )
if( (clip_loader_name._width > max_width) || (
clip_loader_name._height > max_height ) ) // If either dimension
is too big...
if( clip_loader_name._width > max_width )
_root.picsPage_mc.txt_test = "func if 1";
clip_loader_name._width = max_width;
clip_loader_name._yscale = clip_loader_name._xscale;
if( clip_loader_name._height > max_height )
_root.picsPage_mc.txt_test = "func if 2";
clip_loader_name._height = max_height;
clip_loader_name._xscale = clip_loader_name._yscale;
else { new_width = orig_width; new_height = orig_height; }
[/code] -
Unloading a movie clip from a for statement
Hi,
I have this code:
//create empty movie clips to place bin top, flame and bin
bottom in that order
this.createEmptyMovieClip("holder_mc2",this.getNextHighestDepth());
this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
this.createEmptyMovieClip("holder_mc1",this.getNextHighestDepth());
//attach movie clip/variables
var dsfInstance:DropShadowFilter = new DropShadowFilter(5,
45, 0x000000, 1, 10, 10);
var b:MovieClip =
holder_mc2.attachMovie("binTop_mc","binTop_mc",holder_mc2.getNextHighestDepth());
var a:MovieClip =
holder_mc1.attachMovie("binBottom_mc","binBottom_mc",holder_mc1.getNextHighestDepth());
//property values
a._x = 419;
a._y = 244;
a._width = 112.0
a._height = 140.0
b._x = 419;
b._y = 175;
b._width = 112.8;
b._height = 10.1;
a.filters = [dsfInstance];
//create for loop to place the flame particle on the stage
many times
for(i=0;i<200;i++){
//places in temporary movieclip t
var t:MovieClip =
holder_mc.attachMovie("flame","flame"+i,holder_mc.getNextHighestDepth());
// position the movieclip on the stage for y co-ordinates
t._y = 190;
t._x = Math.random()*80+(Stage.width/2+115);
//give the flame random sizes no larger than 80 pixels and no
smaller than 20
t._xscale = t._yscale = Math.random()*80 + 20;
//randomize the frame the movieclip is going to start in the
flame movie clip is 16 frame long so it will pick number between
that
//because math.random produces decimal values we round the
number using math.ceil to the high whole number
t.gotoAndPlay(Math.ceil(Math.random()*16));
what i want to do is remove the movieclip in the for loop off
the stage when i click on a button. i can manage to remove the
movie clips with the variables a and b but i cant do it with the
one in the for loop.
i put this code in the button:
on(release){
play();
stopAllSounds();
a.removeMovieClip();
b.removeMovieClip();
t.removeMovieClip();
Is there a way to do this?im so dumb! i figured it out.
i used the "holder_mc" the name of the empty movie clip.
holder_mc.removeMovieClip(); -
Finding the width of a JPEG loaded into a movie clip
I will be loading a page of bio information. Next to the
person's photo (photos will vary in width) I want to put a column
of buttons about 20 pixels to the right of the photo. So after I
load the photo into an empty movie clip, I'm trying to get the
width of the photo in order to figure out the x position of the
buttons next to it. Here is what I have:
myImage = "images/" + _level0.images[link];
loadMovie(myImage,image_mc);
// JPEG loads okay into image_mc //
trace("image_mc._x = " + image_mc._x);
// I get "Image_mc._x = 393" as expected //
trace("myImage._width = " + myImage._width);
// I get "image_mc._width = undefined" //
trace("image_mc._width = " + image_mc._width);
// I get "image_mc._width = 0" //
How do I find the width of the loaded JPEG?you are probably trying to get the width before the image has
loaded completely.. use the MovieClipLoader class to load the image
into the empty movie clip, then use the onLoadInit event to get the
movie clips's width(which is the images width);
var mcLoader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myListener.onLoadInit = function(target:MovieClip):Void{
trace(image_mc._width);
mcLoader.addListener(myListener);
mcLoader.loadClip(myImage, image_mc); -
Editable text inside draggable movie clip
I am dinamically creating textfields inside movie clips.
Those movie clips are all dragabble (startDrag).
The problem is that those textfields are supposed to be
editable (input type) but once I attach startDrag to them, it's
impossible for them to get the focus, hence they are not editable.
I tried manually setting the focus on release, but it didn't work
(Selection.setFocus(_root.movieclip.textfield)).
Any help will be rrrrreally appreciated :DWell there does have to be some pixels in the bg clip! (Got
to tease you just a bit, because I run into this ALL the time.)
Some how folks don't take the method at its word.
createEmptyMovieClip() does just that. It creates and empty movie
clip. There are no pixels in it so there is nothing to onPress.
Also I've got a little trick for you – you didn't ask
for it, but it is still free. :)
If you use the MovieClip class' method for
createEmptyMovieClip() it will return a reference to the newly
create clip. You can assign that reference to a variable and use it
again and again. To my eye it makes the code easier to read and
maintain. So your code would change to something like:
var curClip=this.createEmptyMovieClip("mc"+i,1000+i);
curClip.createEmptyMovieClip("bg",100);
curClip.createTextField("myText",2,20,20,"auto","auto");
curClip.myText.text="default value";
curClip.bg.onPress=function(){
this._parent.startDrag();
and so on.
Also I personally think getNextHighestDepth() is a disaster
waiting to happen so I personally never use it. -
Movie Clip loading buttons require double clicking on the first attempt
I have created a number of buttons that load move clips into
an empty movie clip. The problem is that it takes several clicks to
activate the first clip button then the buttons behave as they are
supposed to and load properly. Is there a reason why the first time
you must click several times to activate the button loading a movie
clip?stop();
unloadMovie(1);
agatha_btn.onRelease = function() {
nextFrame();
loadMovieNum("agatha_full.swf", 1);
anastasia_btn.onRelease = function() {
nextFrame();
loadMovieNum("anastasia_full.swf", 1);
chiara_btn.onRelease = function() {
nextFrame();
loadMovieNum("chiara_full.swf", 1);
clarisse_btn.onRelease = function() {
nextFrame();
loadMovieNum("clarisse_full.swf", 1);
fifi_btn.onRelease = function() {
nextFrame();
loadMovieNum("fifi_full.swf", 1);
gigi_btn.onRelease = function() {
nextFrame();
loadMovieNum("gigi_full.swf", 1);
ginger_btn.onRelease = function() {
nextFrame();
loadMovieNum("ginger_full.swf", 1);
ingrid_btn.onRelease = function() {
nextFrame();
loadMovieNum("ingrid_full.swf", 1);
lucrezia_btn.onRelease = function() {
nextFrame();
loadMovieNum("lucrezia_full.swf", 1);
natasha_btn.onRelease = function() {
nextFrame();
loadMovieNum("natasha_full.swf", 1);
philipa_btn.onRelease = function() {
nextFrame();
loadMovieNum("philipa_full.swf", 1);
signy_btn.onRelease = function() {
nextFrame();
loadMovieNum("signy_full.swf", 1);
sophia_btn.onRelease = function() {
nextFrame();
loadMovieNum("sophia_full.swf", 1);
teresa_btn.onRelease = function() {
nextFrame();
loadMovieNum("teresa_full.swf", 1);
trudi_btn.onRelease = function() {
nextFrame();
loadMovieNum("trudi_full.swf", 1);
}; -
I'm working on a project where I need to set the tabIndex on
elements within the flash movie. I'm having a difficult time as it
seems that nothing is really working for me. I have a main swf that
creates an empty movie clip and then adds a swf file that has a
movie clip that acts like buttons.
I need those buttons to have a tabIndex. I saw this
link
to an adobe blog for how to make a movie clip have a tab index.
It only works with case 7 and that is because it looks like
it has a _root reference as all the other examples seem to not work
for me in both IE and Firefox.
Currently this is my code for the movie clip that is within
the swf that gets loaded into the empty movie clip that is placed
onto the main swf timeline.
if (nextButton_mc._accProps == undefined ) {
nextButton_mc._accProps = new Object();
nextButton_mc.tabEnabled = true;
nextButton_mc.tabIndex = 1;
nextButton_mc._accProps.silent = false;
nextButton_mc._accProps.name = "Next Button";
nextButton_mc._accProps.description = "Click the Next Button
to move to next page";
Accessibility.updateProperties();
Any ideas as to what I could be doing wrong?So i just tried diong this:
_root.controls_mc.nextButton_mc.tabEnabled = true;
_root.controls_mc.nextButton_mc.tabindex = 1;
and that did not work either. So there's gotta be something
that I'm totally missing here. -
Preload ALL movie clips?
I am experiencing a delay or pause in the site when my first
movie of content is played ... A frew frames before the initial
animation is finished I add in :
_root.conten.gotoAndPlay("start1");
to start the home page (or the first page of my content
movie, whatever you want to call it)....
Is this a preloader problem? I just can't seem to iron it
out.
To See It:
http://www.itamidesign.com/new.html
The Code is also here:
http://www.itamidesign.com/new.fla
THANKSno no there's always a way, i was just pointing you in the
direction of the easiest way.
the first thing you need to do is check getBytesLoaded at
regular intervals rather than in a loop on a frame. this can be
achieved several ways - i've used setInterval in the example i
prepared for you.
the second thing you need to do is check that getBytesTotal
has been received from the jpg okay - this can be checked by
ensuring that getBytesTotal>4, which is the size of an empty
movie clip.
the code i have attached is independent of your xml code,
which was really confusing things, as it is unrelated to your
loader code (one problem at a time!). once you're happy with your
loader code, then you can integrate it with your working xml code.
good luck
craig -
Trying to remove movie clip with collision?
I am creating empty movie clips and populating them with
movie clips that have "drag and drop" functionality. I can create
the empty movie clip and populate it with an external .swf. I've
even got the drag-n-drop handled. But, I'd like to have them delete
or disappear when they are dropped onto a trash can movie clip. I
just can't seem to figure out the code for this. I would greatly
appreciate any help you could give me.
Thanks.you need to perform a hitTest to determine if the item is
within the bounds of your trashcan, you can also use _droptarget,
but I prefer hitTest with a shapeflag parameter. depending on your
code, when you call stopdrag onRelease, run your test there.
the_mc.onRelease = function() {
stopdrag();
if(_level0.trashcan.hitTest(_xmouse, _ymouse, true)) {
this.removeMovieClip();
}
Maybe you are looking for
-
How to Create a wpl File in PSE 9
Can I create a Windows Media playlist (.wpl) file of pictures (with or without music) in PSE 9? I use such a file to play slide shows on my big-screen TV via my Xbox 360 extender.
-
If I purchase the Lightning to VGA Adapter for my iPhone5 will I be able to use Netflix on my phone and watch it on my tv or do I need to purchase additional cables?
-
IWeb webpage moved to outside hosting/domaine
If I move my fully developed.me webpage to my domaine and have it hosted by GoDaddy, will I lose access to updating my blog? How will I make changes to my webpage if the host changes from .me?
-
Why was this ever changed? Why was it changed without asking/polling? Why is it so spread out? Why would it be purposely made, to make it difficult to browse the web? Why would you sabotage your own product?! I am NOT the only person out here asking
-
Will the New iTunes 11 for Windows work on Windows 98???
Will the New iTunes 11 for Windows work on Windows 98??? A. True. B. False.