Loading JPGs into Movie Clip
Can anyone help? I am building a site that requires the user
to click on a button to change a large JPG image in a movie clip.
The button is part of a small movie clip that contains a text
number which is the button in question and a thumbnail of the large
image. I need the button to play when rolled out (to fade out the
thumbnail image) and I need the large JPG image to be replaced by
another large JPG image when the button is released. The button
instance is "Load Image" and the movie clip I want the new JPG to
load into is called "Holding Pic". Should I put the action script
on the main timeline? If so, where? Or should I attach the script
to the button?
Many thanks.
This is an article on AS3 but the answer to your question is
the same. You can find it in the first few paragraphs.
http://www.adobe.com/designcenter/flash/articles/flacs3it_astimeline.html
Similar Messages
-
Successfully imported external swf, can not put it into movie clip
Hello all,
I have started learning AS3 and gradually getting used to, trying to put external swf into movie clip.
Successfully imported target swf and put into stage, when I publish this I see target swf is playing.
import flash.display.MovieClip;
var BGLoader:Loader = new Loader();
var BGurl:URLRequest = new URLRequest("HomeBG.swf");
BGLoader.load(BGurl);
BGLoader.y = 0;
BGLoader.x = 0;
addChild(BGLoader);
As next step I want to put this swf into movie clip and get more control, but when I publish bellow only I see is empty background, without any errors.
import flash.display.MovieClip;
var BGLoader:Loader = new Loader();
var BGurl:URLRequest = new URLRequest("HomeBG.swf");
BGLoader.load(BGurl);
BGLoader.y = 0;
BGLoader.x = 0;
//addChild(BGLoader);
var animMC = MovieClip(BGLoader.content).getChildAt(0) as MovieClip;
addChild(animMC);
Is anything missing?
Any help would be appreciated, thanks.You can only access Loader.content after Load completed successfully.
Try this,
import flash.events.Event;
var BGLoader:Loader = new Loader();
var BGurl:URLRequest = new URLRequest("HomeBG.swf");
BGLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
BGLoader.load(BGurl);
BGLoader.y = 0;
BGLoader.x = 0;
//addChild(BGLoader);
var animMC:MovieClip;
function completeHandler(event:Event)
animMC = event.currentTarget.content;
addChild(animMC); -
Convert Gaphics into Move Clip
Here, I am create three files. Box.as for making graphich dimentional box, Drag.as is for dragging movieClip and ShowBox.as is to display draggalbe box. I would like to see box with draggable faclity. But I am getting error followig error.
Description : 1067:Implicit coercion of a value of type Box to an unrelated type flash.display:MovieClip on Show Box
Might be I am getting problem of converting into move clip but I am not sure. Would u mind u you gind me in this problem/
Box.as
package {
import flash.geom.*;
import flash.display.Shape;
import flash.display.Sprite;
public class Box extends Sprite {
public var box:Shape;
public var boxWidth:Number;
public var boxHeight:Number;
public var boxColor:Number;
public var boxBorderSize:Number;
public var boxBorderColor:Number;
public function Box() {
//Assign Value
boxHeight=100;
boxWidth=100;
boxColor=0x000000;
boxBorderSize=1;
boxBorderColor=0xCCCCCC;
box=new Shape();
box.graphics.lineStyle(boxBorderSize,boxBorderColor);
box.graphics.beginFill(boxColor);
box.graphics.drawRect(0,0,boxWidth,boxHeight);
this.addChild(box);
Drag.as
package{
import flash.events.*;
import flash.display.Sprite;
import flash.display.MovieClip;
public class Drag extends Sprite
public var clip:MovieClip;
function dragBox(myClip:MovieClip)
clip=myClip;
clip=new MovieClip();
clip.addEventListener(MouseEvent.MOUSE_DOWN,startMyDrag);
clip.addEventListener(MouseEvent.MOUSE_UP,stopMyDrag);
addChild(clip);
function startMyDrag(evnt:MouseEvent)
clip.startDrag();
function stopMyDrag(evnt:MouseEvent)
clip.stopDrag();
ShowBox.as
package{
import flash.display.Sprite;
public class ShowBox extends Sprite
public var myMask:Box;
public function ShowBox()
myMask=new Box();
myMask.boxHeight=100;
myMask.boxWidth=100;
myMask.boxColor=0x000000;
myMask.boxBorderSize=1;
myMask.boxBorderColor=0xCCCCCC;
addChild(myMask);
var myDrag:Drag=new Drag();
myDrag.dragBox(myMask);
addChild(myDrag);I do not understand. Acutally, I want to drag the box . Thus, I want to make it movie clip throug AS. I have made graphic rectangular but could not convert nto movi clip. Is there any function so that I could change my graphic into movie clip .
-
Closing swf loaded into movie clip
I have built a movie clip on my main flash file that I am loading separate swfs into. On the separate swfs I have a close button, but do not know what action script to attach to it to make the movie clip go away? I want these to go away every time you hit the close button on the separate Flash swfs loading into the main movie clip.
if the target movieclip has a non-negative depth and the close button is encoded on the loaded swf's main timeline, you can use:
var tl:MovieClip=this;
path.closeBtn.onRelease=function(){
tl.removeMovieClip(); -
Problem attaching external .jpgs to movie clips
Hi There,
I am not able to attach a file (.jpg) outside of flash to a
movieClip without it changing the scale of the image. Stepping
through with the debugger, its clear the image loads correctly til
it is applied to the movie clip, I assume with the attachBitmap
function. It scales it up a little more than 50% and I can't figure
out where that scale is coming from. It appears to scale up from
the upper left corner. We have checked to make sure all the
movieclips within our flash file are the exact same size as the
image files (150 X 150). Please see code example. Everything is
fine except for this. We tried using the matrix transformation to
down size the images but the quality was not acceptable even with
using smoothing and pixel snapping.
So, the basic question being, how do we use attachBitmap and
have it preserve the original size? Any ideas for how to get this
to work is greatly appreciated...
thanks,
Laurawell I'm afraid there are a few things that are not quite
right with the method here - however, the real problem is most
likely that the original image resolution is higher than 72 dpi -
it must be set at standard screen res or Flash will scale it up
uniformly to work at 72.
I think that you may have more success with something more
like this: -
Loading and Unloading Movie Clip
I'm trying to create a timer that would affect when a movie
clip reloads after it has intitially unloaded using AS2. Could
anyone offer any possible options.
Thanks in advance.Look into the setInterval and setTimeout functions
-
Putting movie clips in AS3 package into movie clip on stage
Hi - I am a as2/flash animator and am working on an AS3
project. The AS is in a separate file, inside a package. I am
modifying existing code.
The script adds movie clips in a function via addchild.
What I am hoping to do, is have the movieclips added to a
clip that already exists on the stage.
I put a clip on the stage named holder, with the instance
name holder_mc - and I tried to add the clip with
holder_mc.addchild in the AS3 file - it seemed to work, but
manipulating the holder_mc - it looks like the added clips are not
affected?
Any help is appreciated.Child_array is a property of the Parent class.
It's only added to in one point, in a function that creates a
Child and adds it to the array.
I think I might have found out the problem with my code after
adding a trace to the function, think I'm creating twice the number
of clips I'm removing, and the deletion part of my code is fine!
Turns out AS3 is maybe not so bad after all :P
Thanks alot for taking the time to reply though kglad! -
Loading .jpg into from .jsp?
I'm working on a .jsp that generates a graph from database data, and outputs a byte stream that is an .jpg image of the graph. The problem I've ran into, is I'm tring to load a .jpg file for use as a background image, but I cannot seem to find a way to do this. I've tried published ways for doing this in applications, and applets, but I think my case is a bit different... I have no paint() method, so I cannot figure out how to use the drawImage() method. Any ideas?
Thanks in advance.
BrianNevermind.. I figured it out.
Thanks
Brian -
Loading an external movie clip
Hi team,
Last time I wanted to load an external clip I could do it like this
on (release) {
unloadMovieNum(1);
loadMovieNum("whatever.swf",1);
So now I want to achieve exactly the same thing in AS3,
I have been looking at examples on the web but am getting all sorts of errors and basically don't know what I am doing. I also want to know how to navigate to .swf files in a file structure, as I have to build an old school fscommand file structure for a cd-rom.
Any and all help greatly appreciated.
Cheers,
SubHey worked it out guys!
var myLoader:Loader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("whatever.swf"); // in this case both SWFs are in the same folder
myLoader.load(url); // load the SWF file
addChild(myLoader); // add that instance to the display list, adding it to the Stage at 0,0
But now I need to know.. How do I unload it?
Cheers
sub -
Make action script into movie clip
Hi,
I have used some action script to make a turning wheel with several logos in it. Now I want to make that wheel into one single movie click so I can zoom in and out when mouse over. How would I do this?
Here is the file with the action script
http://www.weidts.de/cs3.zipyou have a button with what instance name on which timeline
that should direct which movieclip to what frame? -
Turning a layered animation into movie clip
I am a flash newbie so this may be a retarded question. I am
trying to turn a multilayered Flash animation into a movieclip
symbol. I have shapes on different layers that are shape tweened
and many shape hints that go with them. When I go to create a new
symbol and paste my frames the shape hints don't end up in the same
place as the shapes. Is there a way to keep the shapes and hints
together as I copy and paste frames? Is there an easier way to turn
this into a movieclip in the fist place?knealis wrote:
> I am a flash newbie so this may be a retarded question.
I am trying to turn a
> multilayered Flash animation into a movieclip symbol. I
have shapes on
> different layers that are shape tweened and many shape
hints that go with them.
> When I go to create a new symbol and paste my frames the
shape hints don't end
> up in the same place as the shapes. Is there a way to
keep the shapes and
> hints together as I copy and paste frames? Is there an
easier way to turn this
> into a movieclip in the fist place?
No, there is no easier way, only Copy Paste frames.
Regards
Urami
Happy New Year guys - all the best there is in the 2006 :)
<urami>
http://www.Flashfugitive.com
</urami>
<web junk free>
http://www.firefox.com
</web junk free> -
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{ -
Playing a mp3 when a movie clip loads
I am using Adobe Flash Professional CS6
What I am trying to do is play a mp3 file that I have in my library when the clip loads and stop playing it when the a new clip is selected from the menu I created. On the button that loads the movie clip (Instance name: Slideshow), I have the following code:
[code]
on (release){
gotoAndPlay(120);
onClipEvent (load){
mySong = new Sound();
mySong.attachSound("MastersThisHall");
mySong.start(0,50);
onClipEvent (unload) {
mySong.stop();
[/code]
- I went to the properties of the MastersThisHall.mp3 file in my library,
- Selected the "ActionScript", tab,
- Checked the box that says "Export for ActionScript",
- Unchecked the "Export in frame 1" check box, and
- Added MastersThisHall in the "Identifier" field.
The sound is NOT playing when I when the "Slideshow" button is pressed.
Ideas?Thank you for all of this; it is very helpful.
I have series of 6 buttons I created, each of them load a different movie clip. I need to have the music from the slideshow NOT continue to play when a new movie clip is selected.
I have the following code.
Frame 1:
SlideshowMusic = new Sound(this);
SlideshowMusic.attachSound("MastersThisHall");
stop();
Frame 120 (attached to the Slideshow movie clip object):
onClipEvent (load) {
SlideshowMusic.play();
The "Mute" Button:
on (release) {
SlideshowMusic.setVolume(0);
The "Resume Sound" Button:
on (release) {
SlideshowMusic.setVolume(100);
And the "Pause" Button:
on (release)
if (SlideshowMusic.position < SlideshowMusic.duration)
SlideshowMusic.start(SlideshowMusic.position / 1000);
It is loading and working perfectly. However, I have two more questions:
1. How do I make the the sound automatically stop when a new movie clip is played?
2. How do I change the "pause" symbol to the "play" symbol when the "Pause" button is pressed? -
I have two dynamic texts, both of them are going to generate numbers. If one has a greater value then the other one, a movie clip must be loaded, else, another movie clip must be loaded.
assuming you meant they're input textfields, use Event.CHANGE listeners to determine when a user changes the text property of those textfields.
tf1.addEventListener(Event.CHANGE,textF);
tf2.addEventListener(Event.CHANGE,textF);
function textF(e:Event):void{
if(!isNaN(Number(tf1.text)) && !isNaN(Number(tf2.text))){
var mc:MovieClip;
if(Number(tf1.text)<Number(tf2.text){
mc=new MovieClip1();
} else {
mc=new MovieClip2();
addChild(mc) -
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
Maybe you are looking for
-
Open Purchase Orders not considered as requirement for MRP Run
Hi , We are facing a issue of Open Purchase orders not appeared in Stock requirements list and also it is not considered as requirement for MRP Run against reservation. As aresult for a reservation demand of 10 units we are ending with Open POs 10 un
-
Placing photoshop eps's into Illustrator - file size
I used to place very large/high res photoshop eps files into Illustrator (as low res proxy) and it would allow my Illustrator file size to stay very small, however, once I switched to CS5 I noticed the way I was saving the eps's wouldn't show up in I
-
Summary field printing on the first line when it supposed to prin last page
i have created manual report. in the end of the report i have summay columns. wheni run in oracle reports it perfectly shows the grand totle. when i generate to file (PDF) thegrand total print on the first line. can some one tell me wht is it printig
-
Trying to check for updates but I keep getting an error from the plugin checker.
I try to find updates for the plugins I have installed and when I get to the site I get this message:Plugin Finding Service Error We've encountered an error. Please try your request again later.
-
I have a hp pavilion dv6-6c16nr. i can not use either microphone or webcam.
i have a hp pavilion dv6-6c16nr. i can not use either microphone or webcam. Programs say that I do not have a microphone or webcam. I use Windows 7 Home Premium 64 bit. I suspected that there is a problem with the current Windows 7 Home Premium 64