Intervals Using Relative Object Positioning?
Hey guys check this code out: ActionScript Code: function moveClip() { if (myClip_mc._x < 400) { // the _x value is less than 400, so increase _x by 1px, // and let setInterval execute this function again myClip_mc._x += 1; // move the clip 1 px to the right } else { // the _x value is greater than 400, // so stop the setInterval from executing anymore clearInterval(myInterval); } // end "if myClip_mc._x < 400" } // end moveClip()// do this when "myButton_btn" is clickedmyButton_btn.onPress = function() { // execute the "moveClip" function every 10 milliseconds myInterval = setInterval(moveClip, 5);} // end myButton_btn.onPress() I was wondering, is there a way to change if (myClip_mc._x < 400) { to a relative position of myClip_mc.I mean, i want myClip_mc to move 100px from it's current position everytime the button is clicked. Instead of only moving itif it's x position is less than 400. So it needs to somehow check it's current position everytime the button is clicked and then make it shift from that position.I know this is a long winded way of doing it but i want it this way so i can use it for something different.Any ideas?
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 02-20-2007, 10:01 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Relative Positioning...
CANNOT figure this one out...
I have "square_mc" on the stage, moving left to right, and rotating (rolling along).
Inside square_mc I have "point_mc", positioned on a corner of the square.
From the stage, how can I get the position of point_mc relative to the stage at any point in the rotation?
I'm missing something basic...
Relative Positioning
Hi I'm trying to position different Children relatively to eachother in my container. But it seems that height and length properties get altered when I add Children so it doesn't get in the right position. I know I am overlooking something stupid as usual cause I'm a newbie. What am I doing wrong here?
ActionScript Code:
newsBackground.graphics.beginFill (0xFFFFFF);
newsBackground.graphics.drawRect (0, 0, 620, 90);
newsBackground.graphics.endFill();
addChild(newsBackground);
newsThumb.load(new URLRequest(String(getXML.xml.pic.thumb[i])));
newsThumb.x = 60;
newsBackground.addChild(newsThumb);
newsId.text =String(getXML.xml.pic.@id[i]);
newsId.x = insidePadding;
newsId.y = insidePadding;
newsBackground.addChild(newsId);
newsTitle.text =String(getXML.xml.pic.@newstitle[i]);
newsTitle.x = newsThumb.x + newsThumb.width + insidePadding;
newsTitle.y = insidePadding;
newsBackground.addChild(newsTitle);
newsSubTitle.text =String(getXML.xml.pic.@newssubtitle[i]);
newsSubTitle.x = newsThumb.x + newsThumb.width + insidePadding;
newsSubTitle.y = insidePadding + newsTitle.height - newsBackground.height;
newsBackground.addChild(newsSubTitle);
newsDescription.text =String(getXML.xml.pic.newsdescription[i]);
newsDescription.x = newsThumb.x + newsThumb.width + insidePadding;
newsDescription.y = insidePadding + newsTitle.height + newsSubTitle.height;
newsBackground.addChild(newsDescription);
newsDate.text =String(getXML.xml.pic.@date[i]);
newsDate.x = newsThumb.width - insidePadding - newsDate.width;
newsDate.y = insidePadding;
newsBackground.addChild(newsDate);
Relative Positioning
I am creating a slide panel (slideRoll_mc) of photographs at run time. I need to be able to place the photos on the "slideRoll_mc" and then scroll the panel, moving the photos on top with the scroll of the item below. I don't know how to place the items so they are placed relative to the slide panel rather than the stage. As it stands now the slideRoll moves great but the photos stay in place.
swidth = (totalt * 137)+137
var pos=137
var clevel = 51002
attachMovie("slideReceiver_mc", "slideroll_mc",51000, {_x:0, _y:500,_width:swidth,_height:120});
for (var i = 0; i<totalt; i++) {
attachMovie("photoholder_mc","slideroll_mc.photohldr" + i + "_mc", clevel,{_x:pos,_y:510});
pos=pos+137
clevel = clevel +2
Relative Positioning HELP
I'm trying to reposition a video window on full screen event. to global 0,0.. and i'm having a hell of a time. I attached a diagram explaining my problem. basically it's just figuring out how far to the negative x to move the window!
I know there is an easy way to do this and i'm trying to avoid using this.parent to reference the holder.
you guys rule.
AS 'Slider' With Relative Positioning
Hey -
anyone know how to create a Slider using relative positioning instead of an absolute x/y coordinate.
I am creating a full screen site - and would like the position to be relative to the screen size opposed to a fixed digit. A percentage of the screen.
basically - what I have been trying to do is combine these two types codes (these are just generic abrevations for example):
Code:
var homeMCy = new Array(0, -526, 40);
function jumpTohomeMCY(number) {
homeMC.newY = homeMCy[number];
}
Code:
logoBar.onResize = function() {
this._y = Stage.height-40;
this._x = (Stage.width)-240;
};
Stage.addListener(logoBar);
logoBar.onResize();
Anyone have any idea how I could make something work - so that the Array holds relative positioning...??
Positioning MC Relative To The Stage Border
I have several mc's that I want to position about 20 pixels from the right side of the users browser regardless of how big the resize it. Does anybody have any ideas of how to do this. I have been trying to use something like this:
onClipEvent(enterFrame){
this._x = Stage.width - 100;
}
but that still doesn't position it 100 pixels left of the stages width.
any ideas would be greatly appreciated
Mike
Positioning _mc Relative To Browser Size
Hi hope you can help me?
I have a sliding dock utilizing a caurina tweener class however am having problems aligning it on the x y scale. I want it to be able to maintain it's respective position relative to the changing size of the screen. It seems like the x y variable here
var baseX:Number = 200;
var baseY:Number = 200;
keeps it static & I tried to place this code below to keep it's position relative to browser size but it only centers it. I tried playing around with the x y values but it only works bettween 1 & 2. Is there a way to align it to the bottom right of the screen that will adjust accordingly to browser size?
Code:
Stage.scaleMode = "noScale";
Stage.align = "TL";
myListenerload = new Object ();
myListenerload.onResize = function () {
slidingdock_mc._x = Stage.width / 1;
slidingdock_mc._y = Stage.height / 1.5;
};
Stage.addListener (myListenerload);
myListenerload.onResize ();
As you can see I'm a newbie at all this so If I'm doing something worng here can someone point me in the right direction?
Thanks.
Relative Movieclip Positioning To Stage Size
Heya,
I am looking for some code to enable a movieclip to reposition itself according to the stage size
so far I got the footer to resize itself according to stage size.
However I will have some text as well which is supposed to stay position x=10 and y= (depending on height of the stage)
Attach Code
Stage.align = "TL";
Stage.scaleMode = "noScale";
var stageListener:Object = new Object();
stageListener.onResize = function() {
var stageWidth:Number = Math.round(Stage.width);
var stageHeight:Number = Math.round(Stage.height);
trace("Stage size is now " + Stage.width + " by " + Stage.height);
footerBG_mc._width = stageWidth;
footerBG_mc._x = 0;
footerBG_mc._y = stageHeight-150;
footerLinks_mc._x = (stageWidth/2) - (footerLinks_mc._width/2) ;
footerLinks_mc._y = stageHeight-18;
text_mc._x = (stageWidth/2) - (wallPaper_mc._width/2);
[ Static x position and variable y position, according to stage size
};
Stage.addListener(stageListener);
stageListener.onResize();
Relative Positioning External Loaded Elements
I'm trying positioning external loaded images from an XML and position them according to the stage dimensions.
Here's what I've come so far: creating a loader for each image and then position them according to their size.
Is there any way to do this avoiding to create a multidimensional array (that's to say two arrays one for the images name and one for the loaders)?
Code:
private function loadBg():void {
for each (var image:XML in xml.BG..IMG) {
var loader:Loader = new Loader();
loader.load(new URLRequest(image.@url));
loader.addEventListener(Event.COMPLETE, positionBg);
addChild(loader);
}
}
private function positionBg(e:Event):void {
.....
switch (?????) {
case "bg_br.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= stage.stageHeight-loader.height;
break;
case "bg_bl.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= stage.stageHeight-loader.height;
break;
case "bg_tr.jpg":
loader.x=stage.stageWidth-loader.width;
loader.y= 0;
break;
}
......
}
Positioning Xml Text Fields In Flash With Relative Width
Hello, I have a problem that I can not find the solution about XML and Flash text fields..
Let's say I have the flash where I want to show few text fields next to each other like that:
This is one xml driven text field | another xml text | more xml text from text field
How can I make the widths of the the fields relative to the content i.e not to have fixed widths and how to make each text field come next to the end of the previous.
I've tried
Code:
my_txt.autoSize = "left";
my_txt.multiline = false;
to make the width of the text field as long as the text content, but it doesn't seems to be working.
Thank you in advance.
Mc Keeping Relative Positioning Depending On Browser Window Size/resize
hi, i'm redesigning my personal website and i'm trying to figure out how to keep certain objects (btns, mc, gfx) in a certain spot on the browser window and how to "animate" them moving to those positions when the window is resized. the best example i can find is this website (www.superfad.com). when the window is resized, objects move accordingly with sort of an smooth animation. also, how can i get one that doesn't animate (also on the same website with the smoke). i've looked a lot of different websites and forums and can't really find (maybe since i don't know how to ask the question in a search box). if someone can help me on this, it'll be greatly appreciated. thanks.
Relative Reference Outside An Object
i'm stumped. i have a listener object that will execute code when called. I want to get that code to link to objects using a relative path but i can't get it to work with anything but an absolute path.
here's an example of what i'm trying to do:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
//
prev_btn.onRelease = function() {
var vidDone = new Tween(contrib_mc, "_x", Regular.easeOut, contrib_mc._x, contrib_mc._x+50, 1.5, true);
//here's the listener object
vidDone.onMotionFinished = function() {
//here are the absolute paths that i want to turn to relative.
_root.contrib_mc.swapDepths(0);
_root.contrib_mc.removeMovieClip();
};
};
let's say the "contrib_mc" movieclip is sitting on the root with the "prev_btn" movieclip. i've traced everything i can imagine inside the "onMotionFinished" listener:
Code:
trace(this)//[Tween]
trace(this._parent)//undefined
trace(_parent)//undefined
can i even accomplish this?
thanks,
Object Movement Relative To Mouse
code:
if (_root._xmouse>_level0.circle._x) {
_level0.circle._x = (_level0.circle._x+10);
} else {
_level0.circle._x = (_level0.circle._x-10);
}
I've used the above code to make my object movement realtive to mouse. Now, How can I make the object center on the screen when there is no mouse on the screen?
Deturmining The Relative X Of A Display Object
I have a MovieClip, nested withing two MoviecClips on the stage. I understand that when I address the x value of that clip it refers to the x value within it's parent. I'm wondering if there is an easy way to get the x property of a MovieClip, relative to the stage. I tried using localToGlobal() but it's not working correctly, perhaps thats becuase the movie clip is nested several levels down.
Any help would be great,
Dereck
Moving An Object Relative To Mouse Position
I'm very new to actionscript, please help!!
I'm trying to get an object to move very slightly towards the mouse pointer as you move near it. To be honest I don't know where to start. Any help - much appreciated.
X-y Position Of An Object Relative To A Movie Clip
I am using the scroll component in Flash MX.
The document that I show within it is to be scrolled, naturally, by the user.
What I would like to do is to highlight different areas of the document based on an audio script. This means that, the highlight should show up in the same RELATIVE position on the document at any given time.
Is there an easy way to achieve this?
I tried to create the highlight animation within my scrollable document movie clip and it worked: the big disadvantage is that whenever someone pauses my movie, audio will stop but the movie clip and the highlight animation will continue running.
Thanks for the suggestions.
Object Movement Within Navigation Relative To Mouse
Hi,
I'm trying to figure out how to create navigation similar to this:
http://www.hillier.com/home/
I want a bar to follow above the site's navigation so that when a user's mouse goes over one of the links the bar will follow.
I'm fairly new to this all and haven't been able to find an answer anywhere else. Any help would be GREATLY appreciated.
Position Object Relative To Dynamic Moveclip
[im using this code] >
http://www.actionscript.org/showMovie.php?id=754
I want to place the orange buttons next to the grey container and have them move relevtive to its edge, but NOT resize. I want this to happen in the same way as the text links on this rather nice site >
http://www.nooflat.nu
I have ben trying to modify the various tutorials on how to position objects reletive to the stage but havent got anywhere, your help would be much appreciated as always
thanks
Chris
N00b Thoughts On AS3 Relative To The Sound Object
so you got your sound object let's say:
Code:
var mySound:Sound = new Sound(new URLRequest("mysupersound.mp3"));
great and now to make it play it's as adobe docs says "as simple as":
Code:
mySound.play();
fantastic!
but hey what if I want to control the volume or the pan to make some nice fx?
now let's go to the thing:
With all these talented programmers at adobe why on earth they don't make a method "as simple as":
Code:
mySound.pan(-1);
??
instead of this, a n00b like me as to do:
Code:
var mySound:Sound = new Sound(new URLRequest("mysupersound.mp3"));
var channel:SoundChannel = mySound.play();
var sTrans:SoundTransform = channel.soundTransform;
sTrans.pan = -1;
channel.soundTransform = sTrans;
I guess that I can extend the Sound class and do it, but hey I'm the only one out there using pan and volume for the sound??
what you think guys??
Object Movement Relative To Variable Values
Hi
I'm trying to make a simple football freekick game but seem as im not amazing at action script I thought I'd ask the pros! I've come up with the basics of what I need to code but putting it all together looks quite daunting...
1, Random left/right wind direction is generated (horizontal value is assigned)
2, User selects position/direction of shot (vertical number value is assigned)
3, User selects the amount of curl/spin (horizontal number value is assigned)
4, User selects power/strength of shot (vertical number value is assigned)
5, Horizontal number values added together to give value for x position
6, Vertical number values are added together to give value for y position
7, Ball_mc is directed to x y postions
8, Simple hit test to see if ball hits goal area
9, If goal user goes to next level
10, If else user repeats level
Has anyone got any tips, tutorials or resources that might be useful for me please?
Thanks alot
Object Movement Relative To Mouse Position
Hello,
Can anyone teach me how this is done?
http://www.creative.com/iss/images/i...0_template.swf
Guess i need to take multiple pics and place them frame by frame side by side?
I need many pictures of the product?
regards,
chaq
Object Movement Relative To Mouse Position -origin
Hi there, im totally noob at this so please bear with me...
ive looked on the forums and several other ones for solutions but found nothing.
I have this script applied to a MC which will move relative to mouse position. It works fine and also includes easing... BUT how do i set the x/y co-ords for the point of origin??? (ie. when mouse position = object position)
The only way i could change the origin was by changing the dimensions of the object (the movie clip) which is not practical.
The following code is applied to a MC
Code:
onClipEvent (enterFrame) {
//this controls the speed of easing
speed = 5;
//this code calculates the object movement...
//relative to mouse postion
endX = -_root._xmouse;
endY = -_root._ymouse;
//This calculates the ease
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
The .fla & .swf are here
i think im missing something but i just wudnt have a clue.
And is anyone able to please explain the "+" in the code "_x +=" and "_y +=" its on the last two lines. I have no idea wat the "+" means/does to those equations.
Any help appreciated.
thanks guys.
Calculate The X/y Of A Rotated Child Object Relative To Stage
Sorry for the long title, but i couldn't make it any shorter.
In fact i need to calculate the x/y position of a child object of a rotated child object of a rotated displayObject.
Things like this don't work.
ActionScript Code:
object1.object2.object3.x
//0
So i figured out i need to use the localToGlobal function, but i can't get it to work, because i can't get the point object in the last object, no matter how hard i try.
So? Any suggestions on how to do this?
Edit: I already found it out. It's:
ActionScript Code:
var pt1:Point = new Point(0,0)
object1.object2.object3.localToGlobal(pt1)
Positioning LoadMovieNum Object
Hi..
I have this problem where I should place the loaded video to a flash movie to a particular place. I have the line
loadMovieNum ("AnalogClock_4.swf", 1); and it works but it's located in the top-left corner.
How can I set the coordinates to that swf object?
thx
Ralative Positioning A Flash Object
Hi there.
I'm having a problem with positioning a flash object in my site.
The flash object is sitting inside a div element with a relative position. The problem is the flash object is sometimes placed inside the div and sometimes align to the left end of the browser. I think it gut something to do with the swf file loading duration (maybe loaded after the page is already displayed.
You can see an example here:
http://ledesign.co.il/?q=he/node/36
comparing to this
http://ledesign.co.il/?q=en/node/33
Have someone experience this kind of troubles before ? Any ideas how to fix that issue ?
Browser Resize And Object Positioning
I'm currently attempting to make a function that repositions all my display objects on the screen anytime the user resizes the browser. At the moment I only have two objects created, a .FLV and a .PNG
I'm using BulkLoader for all my loading needs. My dilemma is this:
The .FLV repositions as intended perfectly when the browser is resized, but the .PNG will not reposition from it's original coordinates. I receive no errors when I debug. Any thoughts?
Code:
package port {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import br.com.stimuli.loading.*;
import caurina.transitions.*;
public class Portfolio extends MovieClip {
var loader : BulkLoader = new BulkLoader("main-site");
var bgVideo : Video = new Video(737, 600);
var rememberIcon : Bitmap = new Bitmap();
public function Portfolio() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.addEventListener(Event.RESIZE, resizeHandler);
loader.add("background.flv", {type:"video", pausedAtStart:true});
loader.add("iconRemember.png", {id:"remember"});
loader.addEventListener(BulkLoader.COMPLETE, allLoaded);
loader.start();
}
public function allLoaded(e:Event):void {
bgVideo.x = (stage.stageWidth / 2) - (bgVideo.width / 2);
bgVideo.y = (stage.stageHeight / 2) - (bgVideo.height / 2);
var bgNS:NetStream = loader.getNetStream("background.flv");
bgVideo.attachNetStream(bgNS);
bgVideo.smoothing = true;
addChild(bgVideo);
bgNS.resume();
var rememberIcon : Bitmap = loader.getBitmap("remember")
rememberIcon.x = (stage.stageWidth / 2) - (rememberIcon.width / 2);
rememberIcon.y = (stage.stageHeight / 2) - (rememberIcon.height / 2);
addChild(rememberIcon);
}
public function resizeHandler(event:Event):void {
bgVideo.x = (stage.stageWidth / 2) - (bgVideo.width / 2);
bgVideo.y = (stage.stageHeight / 2) - (bgVideo.height / 2);
rememberIcon.x = (stage.stageWidth / 2) - (rememberIcon.width / 2);
rememberIcon.y = (stage.stageHeight / 2) - (rememberIcon.height / 2);
}
}
}
Choosing The Point For Object Positioning?
Hello
In the property of each object, I can set the X and Y position.
This coordinate seems to be for the upper_left corner of the object.
Is it possible to apply the X and Y position to the bottom right corner (for example) ?
Thanks
gz
Browser Resize And Object Positioning
I'm currently attempting to make a function that repositions all my display objects on the screen anytime the user resizes the browser. At the moment I only have two objects created, a .FLV and a .PNG
I'm using BulkLoader for all my loading needs. My dilemma is this:
The .FLV repositions as intended perfectly when the browser is resized, but the .PNG will not reposition from it's original coordinates. I receive no errors when I debug. Any thoughts?
Code:
package port {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.*;
import br.com.stimuli.loading.*;
import caurina.transitions.*;
public class Portfolio extends MovieClip {
var loader : BulkLoader = new BulkLoader("main-site");
var bgVideo : Video = new Video(737, 600);
var rememberIcon : Bitmap = new Bitmap();
public function Portfolio() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.addEventListener(Event.RESIZE, resizeHandler);
loader.add("background.flv", {type:"video", pausedAtStart:true});
loader.add("iconRemember.png", {id:"remember"});
loader.addEventListener(BulkLoader.COMPLETE, allLoaded);
loader.start();
}
public function allLoaded(e:Event):void {
bgVideo.x = (stage.stageWidth / 2) - (bgVideo.width / 2);
bgVideo.y = (stage.stageHeight / 2) - (bgVideo.height / 2);
var bgNS:NetStream = loader.getNetStream("background.flv");
bgVideo.attachNetStream(bgNS);
bgVideo.smoothing = true;
addChild(bgVideo);
bgNS.resume();
var rememberIcon : Bitmap = loader.getBitmap("remember")
rememberIcon.x = (stage.stageWidth / 2) - (rememberIcon.width / 2);
rememberIcon.y = (stage.stageHeight / 2) - (rememberIcon.height / 2);
addChild(rememberIcon);
}
public function resizeHandler(event:Event):void {
bgVideo.x = (stage.stageWidth / 2) - (bgVideo.width / 2);
bgVideo.y = (stage.stageHeight / 2) - (bgVideo.height / 2);
rememberIcon.x = (stage.stageWidth / 2) - (rememberIcon.width / 2);
rememberIcon.y = (stage.stageHeight / 2) - (rememberIcon.height / 2);
}
}
}
Stage Object Movie Positioning In Corner
hello,
does anyone have any advice on this. I am trying to make it so that when a fullscreen movie loads a movie clip is positioned in the top left corner of the full screen flash site.
This code is on the first frame of my flash movie.
It works when i resize the window but not when the movie loads for the first time in an existing window. meaning some poeple cannot see the menu bar .
does this code work on all browsers?
ActionScript Code:
fscommand("allowscale", "false");
Stage.scaleMode = "showALL";
Stage.originalWidth = Stage.Width;
Stage.originalHeight = Stage.Height;
Stage.scaleMode = "noScale";
Stage.getLeft = function() {
return -1*(this.width-this.originalWidth)/2;
};
Stage.getTop = function() {
return -1*(this.height-this.originalHeight)/2;
};
Stage.addListener(titleblocknav);
Stage.addListener(preloader);
titleblocknav.onResize = function() {
this._x = Stage.getLeft()+50;
this._y = Stage.getTop()+25;
};
preloader.onResize = function() {
this._x = Stage.getLeft()+330;
this._y = Stage.getTop()+48;
};
can anyone spot any mistakes?
Thanks
Michael
Positioning Objects, And Object Registration Coordinates.
Thanks for taking the time to read my query.
Here's my problem...
I import png's to my library, and align everything in place where I desire it to be on the mainstage. Next, I distribute each object to it's own respective layer - each object maintaining it's respective X and Y coordinates. I then create a new movie clip, cutting the objects and from the main-stage area, pasting them into the new movie clip. Once I setup my tweening, alpha level etc, I have a perfectly working movie clip that I then place in a single frame of the timeline on the mainstage area.
However, when I preview the animation, the movie clip inside the single frame of the main timeline is not positioned in the center of the stage, but elsewhere resulting in the movie being clipped.
Logically, it would make sense that the original alignment established in setting up the main stage would remain consistent when cut and pasted "in place" to a new movieclip, sadly that's not the case. Instead of the boundaries of the main stage remaining visible when editing a movie, they disappear and the positional coordinates of the content become subjective (or so it appears).
I really have no idea how to fully explain it, but it seems like flash wasn't designed to have things done in a logical manner, but adheres to a system that has become familiar over time, which requires the users to learn to adapt to that system. There seems to be virtually no documentation that I've been able to find that explains the details of "registration" in a clear and concise manner.
Any helps would be great appreciated.
Thanks.
How Can An Object Move "inside A Constraint Area" Relative To The Mouse Movement?
hi,
I'm so glad that this site exists!
I know you have posted a tutorial to teach us how to make an object move relatively to the mouse movement in Flash 5.
However, I tried the code with Flash MX 2004. It did not move so smoothly as the example demonstrated. I am wondering if the code should be slightly changed in the latest version of actionscript?
so, here's my real question: could you please teach me how to write the ActionScript in order to make an object move "inside a constraint area" relative to the mouse movement? For example, how to make an eyeball move inside the eye orbit following the mouse movement?
Thank you for answering my question~!!!
Sincerely,
Hedi
Positioning An Object With The "info" Panel
Hey y'all!
I have a problem with positioning an object in the upper left corner (x=0 and y=0) of the stage.
When I do this using the "info" panel, the object, instead of going to the upper left corner of the stage, will place itself in the exact middle of the stage.
Does any one know why this is and how I can solve it? Is there a way to solve it using ActionScript?
Thanx,
Maurits
Positioning An Object With The "info" Panel
Hey y'all!
I have a problem with positioning an object in the upper left corner (x=0 and y=0) of the stage.
When I do this using the "info" panel, the object, instead of going to the upper left corner of the stage, will place itself in the exact middle of the stage.
Does any one know why this is and how I can solve it? Is there a way to solve it using ActionScript?
Thanx,
Maurits
Intervals?
hi, i have one interval at every 40secs which makes my enemys apear on screen i want another interval that is always 10secs earlier, which will display a warning saying that the enemy are coming.
i tried this but didnt work cant seam to change interval time once set?
setInterval(enemyapear, 40000);
warnspeed = 30000
setInterval(attackwarning, warnspeed);
the attackwarning makes the messge apear and add 1 to a list each time.
then on a onEnterframe i had if statements that if a list was 1 then set warnspeed to 70secs and after that if list >1 then add 40secs to the warnspeed eachtime it was completed.
Help With Some Intervals
i'm trying to make this setInterval. which is supposed to change a swf file every 5 secs but i'm not sure if i'm doing the right thing, ohh yeah i'm making this so it just progresively getting a file with a higher number...
but here is the actual code i got so far.
code: var slideInfoLV:LoadVars = new LoadVars ();
slideInfoLV.onLoad = function(success) {
if (success) {
slideCounter();
} else {
frameNum.text = "error";
}
}
slideInfoLV.load("vars/back_info.txt");
var curFrameNum:Number = 0;
function loadFrame () {
_level0.myMCL.loadClip("background/back" + curFrameNum + ".swf", this.backMC);
}
loadFrame();
onLoad = function (){
if (curFrameNum < Number(slideInfoLV.totalBacks) - 1){
setInterval(loadFrame,50000);
curFrameNum++;
}else {
curFrameNum = 0;
}
loadFrame();
slideCounter();
}
Help With Intervals, AS2
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:
http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)
and here is all the code I am working with, and it's the button codes that are messing things up (I think):
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};
buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};
buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};
buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};
Intervals
I need help setting Intervals.
Here is my code.
intervalId = setInterval(_root, "gotoAndPlay", 3900, "Loader", "1");
stop();
Next frame:
clearInterval(intervalId):
The problem is when I run the swf file or the exe file it doesn't work it skips to the beginning og the movie.
It works just fine when I preview in flash.
Can anybody help?
Different Intervals
Hi. I'm making a slide show. The images are in a txt file so what my script does is this:
I used setInterval to call a function but the time to call the function is always the same. What I want is that every image is displayed on diferent intervals.
My txt file: &time=2000,5000,1500,9000
that's the time for each image. How can I use this?
How can I make each image displays in it's right time?
thank you.
Using Intervals
I want to have a button that when moused over, slowly fades to 100% alpha, and when moused off, fades back away to 0%. My code works fine if I mouseover the button, wait for it to fade all the way up, and then mouse off.
If I quickly mouse over it and then just as quickly mouse off of it, it fades up perfectly fine, but then does NOT fade back away.
I set this up by creating a movie clip of the button fading in for 20 frames, stopping, and then fading out for 20 frames. It is called crystal1.
I am using intervals to run a function every frame that checks what the current frame is, and if it had finished playing the previous part of the movieclip to play the next part.
Any help would be greatly appreciated!
Attach Code
on (rollOver) {
clearInterval( interval1off );
var interval1on
interval1on = setInterval(crystal1on, 83);
function crystal1on() {
if ( _root.crystal1._currentframe == 40 or _root.crystal1._currentframe == 1 ) {
_root.crystal1.gotoAndPlay(1);
clearInterval( interval1on );
} else if ( _root.crystal1._currentframe == 20 ) {
clearInterval( interval1on );
}
}
}
on (rollOut) {
clearInterval( interval1on );
var interval1off
interval1off = setInterval(crystal1off, 83);
function crystal1off() {
if ( _root.crystal1._currentframe == 20 ) {
_root.crystal1.play();
clearInterval( interval1off );
}
}
}
Intervals?
can we have an actionscript where there is a button to control the movement of the object and not add setInterval in it?
A Little Help With Intervals..
Hi all! I need a little help with some stuff again. I've basically got a bit code that produces a line of numbers as navigation and most of it was written by stringy.
Here is the previous thread:
http://www.kirupa.com/forum/showthread.php?t=266639
The buttons work, but when I click on them I also want my slideshow to stop and possibly stay highlighted.
here is the bit of code that controls selecting the image and stuff:
ActionScript Code:
function dorelease() { clearInterval(myInterval); this._alpha = 100; p = this.ivar-1; nextImage();}
The clearInterval stuff normally stops the slideshow, but in this location it doesn't so I'm guessing it's something to do with _root or _level etc. But for the life of me I can't quite figure it out at the moment.
This is the bit of code that generates the buttons:
ActionScript Code:
mask._visible = false;function getButtons() { mask._width = 0; var clip = this.createEmptyMovieClip("paper", 10000); //clip.setMask(mask); clip._y = 556; clip._x = 10; for (var i = 0; i<cliparray.length; i++) { var clap = clip.attachMovie("btn", "btn"+i, i); clap._x = (clap._width+5)*i; clap.ivar = i; clap._alpha = 40; clap.myText.text = i+1; //clap.onPress = dopress; clap.onRelease = dorelease; //clap.onReleaseOutside= doreleaseOutside; clap.onRollOver = dorollover; clap.onRollOut = dorollout; } //mask.onEnterFrame = grow;}
Help With Intervals
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:
http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)
and here is all the code I am working with, and it's the button codes that are messing things up (I think):
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};
buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};
buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};
buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};
Playing Mcs In Intervals
was wondering if anyone had a good aproach to play different mcs with a certain pause between each play command
i used to just put something at the end of an mc's timeline that would play the next mc... but i want to try and centralize the code
i have a few mc... all sitting there with a stop in begining and end... i want to say mc1.play(); ... wait 2 sec... mc2.play()... wait 3 sec ... etc
any ideas?
Clear ALL Intervals ?
hi there,
i 'd like to know if there is a way to clear all Intervals in a movie with one command...
in my current project I use setInterval()
very often in different clips and though i cleanly put the corresponding clearInterval() commands in the script I realized, that on slow computers some of them don't get stopped...
which puts more weight on the CPU and sometimes slows down the comp very much.
is there a fix ?
tia
Intervals Problem
Please help
What's wrong in this code?
Why do the 3 objects open with the same interval (1 second), when I set 3 different intervals?
Please help me fix this script...
Thanks a lot!
Keypress Intervals
i have a keypress, but i don't want it to repeat itself at a unbelievable speed. I would like the actions only to happen, at the fastest, half a second apart. This is my code:
on (keyPress "w") {
this.container.attachMovie("ollie", "container", 10);
_root.score = _root.score + 20;
}
I just want it so you can't hold down the button and rack up the points. Somekind of SetInterval thing. What script would i use?
|