Trying to create a movie clip that Bounces off four sides of the stage
using the syntax below I have created a movie clip called 'BALL' that bounces off from the left "x" and moves to the right side of the stage 'x.520' and bounces back to the start "x".
HOW DO I CREATE A MOVIE CLIP THAT BOUNCES FOUR SIDES OF THE STAGE AND STOPS ON THE FOURTH BOUNCE??
var ballTween:Tween = new Tween(ball, "x", Bounce.easeInOut, ball.x,520, 5, true);
ballTween.addEventListener(TweenEvent.MOTION_FINISH,tweenFinishedF);
function tweenFinishedF(e:TweenEvent):void{
new Tween(ball,"x",Bounce.easeOut,ball.x,0,5,true);
Here is a simplest way to do that. This code doesn't use your ball but draws it dynamically. If you want to use your ball instance - replace relevant lines.
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
var ball:Shape;
// speed, naturally
var speed:Number = 7;
// velocity along x
var vx:Number = speed;
// vlocity along y
var vy:Number = speed;
// area within which ball may move
var moveArea:Rectangle;
// radius of ball circle shape
var ballRadius:Number = 20;
init();
function init():void
moveArea = new Rectangle(ballRadius, ballRadius, stage.stageWidth - ballRadius, stage.stageHeight - ballRadius);
drawBall();
addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(e:Event):void
// change direction if ball moves out of allowed rectangle
if (ball.x < moveArea.x)
vx = speed;
else if (ball.x > moveArea.width)
vx = -speed;
if (ball.y < moveArea.y)
vy = speed;
else if (ball.y > moveArea.height)
vy = -speed;
ball.x += vx;
ball.y += vy;
function drawBall():void
ball = new Shape();
ball.graphics.beginFill(0xFF0000);
ball.graphics.drawCircle(0, 0, ballRadius);
ball.x = moveArea.x + Math.random() * moveArea.width;
ball.y = moveArea.y + Math.random() * moveArea.height;
addChild(ball);
Message was edited by: Andrei1
Similar Messages
-
The title I'm trying to create using text tool is cutting off right side
I've looked at all the settings and can find no reason for this.
While I'm still a bit of a novice, I have done titles before and never had this problem.
An additional green box shows up in my canvas, showing me exactly where this it cutting off. I don't know what this is. Is there a way to readjust this?
Under the Motion tab in my Viewer, the Center is set to -55 and -100, because this is where I want the text positioned. It is also aligned left under the Control tab. I can see where, if I were to align center, it would all fit, but then the text isn't appearing where I want it to.
Can anyone help?
Thanks a lot.
J.Well, now I'm feeling even more stupid.
I cannot find the generator button you describe, even after consulting the help manual.
I THINK I know which one it is - the button in the lower right corner of the viewer - the same one that has Text, Crawl, etc....?
But it's not there.
I'm using FCP HD. is that the problem?
Also, Boris is familiar to me - I think I've used it or seen it in the past - but I can't find it. I'm wondering if I'd seen it previously while using Final Cut Express, but somehow, since upgrading to Pro, I don't see it any more.
If you can clarify any of this, i would be vrey grateful. -
How can I load an external SWF into a movie clip that's inside other movie clip?
Hi.
I creating my first flash (actionscript 3.0) website but I'm
stuck with a visual effect I want to create.
I have a window on my website called contentWindow. Every
time you click a button this window is supposed to leave the stage,
load the requested content and return to the stage.
The sliding window is a movie clip with 83 frames, 21 to
enter the stage, 21 to leave the stage again, 20 for nothing (its
just to simulate the loading time) and 21 to return to the stage.
Now my goal is, when the user clicks on a navigation button,
the window exits the stage, loads an external SWF with the content,
and then returns to the stage.
I've the "window" movie clip with an instance name of
"contentWindow". Inside there is another movie clip with an
instance name of "contentLoader". The content that the user
requested should appear inside the "contentLoader".
Now, when the contentWindow leaves the stage, I get this
error message:
quote:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at rwd_fla::MainTimeline/trigger()
If I switch
"contentWindow.contentLoader.addChild(navLoader);" for
"contentWindow.addChild(navLoader);" it works fine, but the
external SWF doesn't move with the window.
How can I load an external SWF into a movie clip that's
inside other movie clip?Hi,
Recently, I have been putting together a flash presentation.
And I am just wondering if the following might help you, in your
communication with the said swf file:
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onComplete);
function onComplete(event:Event):void
event.target.content.thinggy_mc.y -= 100;
Not the best example, but this allows you to target a mc
within an external swf file. I think if you look up this code, you
will have an answer ;)
Kind Regards,
Boxing Boom -
On IDVD, I have 3 consecutive movie clips that I am trying to drop into the drop zone to create a DVD but it only recognizes the first one I dropped and only produced the first one in a DVD. How can I drop all three movie clips into one drop zone.
I have had some luck doing the following: Export each clip from imovie as a quicktime clip. Open iDVD and create a new project. Import a few stills into iDVD and then click on the button that gets created to get into the screen where the individual slides appear. Drag each quicktime into that screen and arrange in the order you want. You can then delete the stills. The button that appeared when you dropped in the stills will launch a complete show.
-
IMovie HD refuses to import .MOV clips that it used to import.
I've got an odd problem. Doing a search didn't turn up anything relevant to my situation so I'm gonna try to pick some brains on here.
My Problem: My version of iMovie(5.0.2) no longer recognizes .mov clips that it used to. Meaning that when I try to import clips using settings that worked previously, I am now confronted with an Error during import message that reads "The file could not be imported: Unknown Error". Two things have changed since I last made a project.
1.) I have added a microphone that now allows me to record stereo audio. I don't think this is the culprit.
2.) I updated to 10.6.6 Recently. I think this may be what messed things up.
After trying to Drag and also import clips through the menu with no success, I tried to import clips that I have used before under the exact same conditions and was greeted with the same error. This is importing using the HDV 720p setting. If I try to import new or old clips using the standard DV (16:9) setting then everything works.
These same clips are able to be imported into iMovie '09 with no trouble but I am uncomfortable with that interface. Is there anything I can do to continue to work in iMovie HD or would I just be better off with getting used to iMovie 09?
Thank you for any replies.I have Mac 10.6.6 and use iMovie 05 transferring it to iDVD 08. It is getting less easy to do, but usually i make the movie in 05, complete with chapter marking and press the export to DVD.
The file for the Movie I have made is saved automatically in the Movie folder on my owner/home page. To get it out to iDVD 08 open 08 and select create new project and click save This puts a small file into Documents, However to get your work into the new DVD select import>video and when the screen opens for you to find it go to your movie folder in your owners area and click to open the file. It works, but there is usually a problem somewhere along the line. Usually a different one each time, occasionally it goes like clockwork. It won't work if you try the drop down 'open' option.
This last time I got so irritated that I've downloaded the last set of film clips to 05 and then transferred them to 08 to compare the results. I still feel that the later versions are less good (?dumbed down) and await to be converted. -
I have numerous music movie clips that I have not purchased through iTunes, Is it possible to stream these "home" movies using iTunes to apple TV?
And if iTunes will not allow it, is there another complete program available that I can purchase to have my music movie clips stream to a TV and/or another computer?
Any help would be appreciated. ThanksThanks, Winston C, I've actually tried everything you suggested. I'm thinking now that the Home Sharing problem likely is related to Bonjour--I've seen several people mention this with similar (but not identical) problems. The solution that seems to work for some people is to uninstall and reinstall Bonjour. Frankly, I don't want to go through the trouble given that the iOS 7 release is imminent.
One thing that I haven't tried is resetting the ATV to factory settings. I'll give that whirl.
Thanks for your advice! -
One set of clips won't sync when trying to create a Multicam clip
I am trying to create a multicam clip using one long audio track, several clips from one camera and several clips from another camera. All three have audio recorded from the same shoot. One camera angle successfully synchronises with the audio track, placing the clips in the correct positions and leaving blank spaces where I don't have a clip. The other set of clips do not sync. It puts them in order by not synchronised. I have named camera angles and camera in the meta fields. Can anyone help? The camera which seems to sync ok was a canon XA10 the camera which doesn't is a canon 60D. The 60D took its audio teach from the linear PCM recorder I used for the Audio track. (It's still a little noisy in case anyone wants to know why I'm still using the PCM track). Can anyone help? I tried to call apple but seemingly they won't help unless I get an error message.
You could probably generate the content of the end file
separately, before including it in the final file to be accessed by
the user.
You could do this using CFSAVECONTENT
<cfquery name="getprinthtml" datasource="#dsn#">
SELECT abstractDirectory
FROM Abstract_tbl
WHERE (Abstract_ID IN (#url.abslist#))
</cfquery>
<cfsavecontent variable="theBody">
<cfoutput query="getprinthtml">
<cfinclude
template="/uploads/#getprinthtml.abstractDirectory#/#getprinthtml.abstractDirectory#_prin t.html">
<hr>
</cfoutput>
</cfsavecontent>
then use
theBody as a variable containing the entire contents at one
time when you generate the final Word doc so it does not have to
run any looping at that time.
Other than that, is there any chance the query is really only
picking up one row based on the cirteria ? -
How to build a custom movie clip that will be used as a cell renderer for column in a grid ?
i want to build a datagrid that shows a picture and underneath it a name.
the problem is i dont want to see all of the pictures, but all the pictures that have certain requirements, so i cant just make one movie clip that includes all the pictures and names.
so my question is how do i build a movie clip that contains photo and text?.You do not create movieclips on the timeline using code, though you can create them and add them as children of something that has been manually placed in the timeline.
To create a MovieClip using code you use:
var mc:MovieClip = new MovieClip();
If you need to add an image, then however you intend to acquire the image, after it has been acquired, you add it to the MovieClip using:
mc.addChild(img);
where img is the instance of whatever form of object the image takes (Bitmap, Loader)
If you need to add a TextField to the MovieClip then you use:
var tf:TextField = new TextField();
mc.addChild(tf);
and you can set up properties for the textfield such as the font and color and position as well after it has been instantiated (the first line). -
Can i assign a child state to a movie clip that is already placed on stage
Hello
Is it possible to add a child state to a movie clip that is
already placed on stage,
i need to do this so i can move the movieclip to the top of
the display list.
thanks for the help
mt"The objects i want it to appear above are loaded swf's onto
the same main stage."
Aha, this is where things can get confusing. The terminology
between the Flash Authoring tool and ActionScript is not
consistent.
In ActionScript, the Stage is the top most DisplayObject. You
probably get that.
In Flash, the canvas that is often referred to as "the stage"
is not the Stage object of ActionScript, rather the Flash stage is
a DisplayObject class called MainTimeline (or if you assign a
document class, it's that class), which is the first and only child
of the ActionScript Stage object. It's the only child unless, of
course, you add something else to the ActionScript Stage object at
runtime... like a loaded swf. ;)
So in other words, if you are doing anything like this:
stage.addChild(myLoadedSWF)
You are actually putting myLoadedSWF above the MainTimeline
object, which is the entire Flash timeline. There's nothing wrong
with that, but in this case it means changing the depth of things
inside the MainTimeline is not going to change the fact that the
MainTimeline itself is below myLoadedSWF.
Most likely the simplest solution is to add your loaded SWFs
to the property "root", not stage. root can refer to different
things in different places, but most of the time it refers to the
MainTimeline, and if I had to guess I would say it almost certainly
does in your case. Note that the "root" property is typed as a
DisplayObject, not a DisplayObjectContainer, so addChild (which is
a DisplayObjectContainer method) will not be recognized unless you
typecast to DisplayObjectContainer or a subclass of
DisplayObjectContainer, like Sprite or MovieClip:
MovieClip(root).addChild(myLoadedSWF)
Also note that, unlike AS2, in AS3 it's very easy to simply
add your loaded SWF below existing objects you create in Flash. You
can use addChildAt(obj,0) for instance to add it to the very
bottom. -
RemoveChild for movie clip that was added in another function?
Hello everyone. I have 3 different functions for my preloader. I have an Event.OPEN, ProgressEvent.PROGRESS, and an Event.COMPLETE. In the event.OPEN function, I create a new variable that is data typed to the class name of my preloader that I set in it's property dialogue box. This is just a simple circle animation. Below is my code for it:
function addPreloader(event:Event):void
var myPreloader:mcPreloader = new mcPreloader();
myPreloader.x = stage.stageWidth / 2;
myPreloader.y = stage.stageHeight / 2;
myPreloader.width = 75;
myPreloader.height = 75;
addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
var myLoadedImage:Loader = Loader(event.target.loader);
addChild(myLoadedImage);
new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
event.target.loader.removeEventListener(Event.OPEN, addPreloader);
event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
The only problem is that when it's done loading, I'd like to remove the myPreloader from the stage. Since it is declared in the Event.OPEN function, I can't communicate with it via my Event.COMPLETE function. How can I successfully remove it from the stage after it's done loading? Thanks!
JesseDuh, thanks Kglad. It's been a long week ;).
Jesse
Date: Thu, 9 Jun 2011 13:47:57 -0600
From: [email protected]
To: [email protected]
Subject: removeChild for movie clip that was added in another function?
var myPreloader:mcPreloader
function addPreloader(event:Event):void
myPreloader = new mcPreloader();
myPreloader.x = stage.stageWidth / 2;
myPreloader.y = stage.stageHeight / 2;
myPreloader.width = 75;
myPreloader.height = 75;
addChild(myPreloader);
My ProgressEvent.PROGRESS function looks like so:
function preloadImages(event:ProgressEvent):void
var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
percent_txt.text = percent + "%";
and my Event.COMPLETE function looks like so:
function imageLoaded(event:Event):void
removeChild(myPreloader);
myPreloader=null;
var myLoadedImage:Loader = Loader(event.target.loader);
addChild(myLoadedImage);
new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
event.target.loader.removeEventListener(Event.OPEN, addPreloader);
event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
> -
Disabling all movie clips that are on lower levels
Hello
I have a movie clip that pops up over all other movie clips.
But it is still possible to interact with these movie clips that
are beneath the mc that has popped up. Is there any way to disable
all of the movie clips that are beneath the one that popped up?
thanksTypically the way to do this is simply create a large
invisible MovieClip which covers everything, and give it a an
interactive event. I often use:
on(rollOver){
useHandCursor = false;
This way not only does it steal interaction from anything
below it, it makes it so the cursor doesn't turn into a hand making
the user think there's something clickable.
You could also make a loop which checks getDepth() and if
it's below a specified depth, set enabled = false, but there's
really no reason in doing that. -
To create unlimited movie clip
How do I create unlimited movie clips by CreateMovieClip by onPress a button ?
Here is a simplest way to do that. This code doesn't use your ball but draws it dynamically. If you want to use your ball instance - replace relevant lines.
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
var ball:Shape;
// speed, naturally
var speed:Number = 7;
// velocity along x
var vx:Number = speed;
// vlocity along y
var vy:Number = speed;
// area within which ball may move
var moveArea:Rectangle;
// radius of ball circle shape
var ballRadius:Number = 20;
init();
function init():void
moveArea = new Rectangle(ballRadius, ballRadius, stage.stageWidth - ballRadius, stage.stageHeight - ballRadius);
drawBall();
addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(e:Event):void
// change direction if ball moves out of allowed rectangle
if (ball.x < moveArea.x)
vx = speed;
else if (ball.x > moveArea.width)
vx = -speed;
if (ball.y < moveArea.y)
vy = speed;
else if (ball.y > moveArea.height)
vy = -speed;
ball.x += vx;
ball.y += vy;
function drawBall():void
ball = new Shape();
ball.graphics.beginFill(0xFF0000);
ball.graphics.drawCircle(0, 0, ballRadius);
ball.x = moveArea.x + Math.random() * moveArea.width;
ball.y = moveArea.y + Math.random() * moveArea.height;
addChild(ball);
Message was edited by: Andrei1 -
I am trying to create a PDF document that calculates Gains and Losses in Mutual Funds. The calculation scripts are repetitive from line to line. The scripts work well until I reach the line 32. Although I am using the same script as the fields above in the columm, the script eventually stops calculating and I can't figure out why. Is there a limit of how many calculation scripts you can enter? I will attempt to attach my pdf as soon as I figure out how. Thanks.
For e31 :
var e30 = +getField("e30").value ;
var c31 = +getField("c31").value ;
if ( (e30 !== 0) && (c31 !== 0) ) event.value = e30 + c31 ;
else event.value = "";
for e32 :
var e31 = +getField("e31").value ;
var c32 = +getField("c32").value ;
if ( (e31 !== 0) && (c32 !== 0) ) event.value = e31 + c32 ;
else event.value = "";
for e33 :
var e32 = +getField("e32").value ;
var c33 = +getField("c33").value ;
if ( (e32 !== 0) && (c33 !== 0) ) event.value = e32 + c33 ;
else event.value = "";
Java console doesn't show any error... That's why I am wondering if it's not a limitation issue... or memory issue, because they are maybe too many rows or something....
The c value is not calculated. -
I am trying to create home movies, and do not have sound on the final disc. The sound is there in imovie and after sharing to idvd. This has only happened a couple of times before and I have made a lot of movies. I have just gone through about 8 discs, all with no audio when I play them!!!
You need to ask for support in the iMovie forum.
-
I am trying to create an executable vi that will call out another vi and show its front panel in the executable. When I try this I recieve this error message "top level vi (my main vi) was stopped at unknown on the block diagram of (my sub vi)
Well the most common way is to enclude the vi's in the build spec either directly in the dependancies that the App builder automatically generates OR by declaring them in the build spec as "additional enclusions" (like you must do for dynamic vi calls in your app.
I have heard rummors about My.app Stuff.vi in a nugget Intaris posted- and I've wanted to dig deaper into Intaris' claims- but have not tried it myself.
If you go down the stuff.vi route Keep us curious guys posted
Jeff
Maybe you are looking for
-
How can I get a list of songs in iTunes to print out?
I am trying to make a list of all the songs I have in my iTunes. How can I do that?
-
I tried to update my iPhone 5s now it won't turn on.
I've plugged it into my laptop and it came up on iTunes stating the phone is in recovery mode, I clicked to restore the iPhone and it is currently doing so now. I don't understand how I updated my ipad and that had no issues yet my phone did? Will my
-
Different fiscal year for extended withholding tax
Hi All SAP Gurus, I have configured the extended withholding tax as per the Indian requirement.But I am unable to meet the following to requirement as per client's need.Can anybody help me out please? 1) My client is following Calander year ( Jan to
-
Alot of issues. bad harddrive?
i have a 30gb 5th gen ipod, and there are many things wrong with it. first it responds very slowly when using it, it will play a few songs, but then it will freeze, the back of it gets very hot, and i hear strange clicking noises coming from it, and
-
Why don't my devices show up in itunes? I'm using a mac.
For some reason all of a sudden my iPad2 and my iPhone (first generation) no longer appear on itunes when I plug them in. How do I port music or sync them if they don't appear?