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
Adobe > Flash Site Design
Posted on: 07/21/2008 05:20:53 AM
View Complete Forum Thread with Replies
Sponsored Links:
Positioning Symbol By Registration Point?
I already checked many forums about this, maybe i am the only one who has a problem with this change in flash mx 2004:
Using the info panel, if you position a symbol - with the middle spot in the 3x3 grid selected - you do not move the symbol by the registration point any more (as in recent versions).
Instead you move it by the center point of the instance, and that seems to be in the middle of the symbol by default. ok, you can move it to match the registration point, but you have to do it for every instance by hand. bad.
this new behaviour is especially annoying if you use symbold that have the registration point neither in the upper left, nor in the middle. that is the case in a lot of symbols i use.
even more inconsistent: if you move a symbol by actionscript the center point is totally ignored and only the registration point is used. Is there no way to move it like this using the panels?
i use still use the trial version, but i dont think that causes my problems.
any help appreciated!
View Replies !
View Related
Positioning Symbol By Registration Point?
I already checked many forums about this, maybe i am the only one who has a problem with this change in flash mx 2004:
Using the info panel, if you position a symbol - with the middle spot in the 3x3 grid selected - you do not move the symbol by the registration point any more (as in recent versions).
Instead you move it by the center point of the instance, and that seems to be in the middle of the symbol by default. ok, you can move it to match the registration point, but you have to do it for every instance by hand. bad.
this new behaviour is especially annoying if you use symbold that have the registration point neither in the upper left, nor in the middle. that is the case in a lot of symbols i use.
even more inconsistent: if you move a symbol by actionscript the center point is totally ignored and only the registration point is used. Is there no way to move it like this using the panels?
i use still use the trial version, but i dont think that causes my problems.
any help appreciated!
View Replies !
View Related
Positioning Symbol By Registration Point
I already checked many forums about this, maybe i am the only one who has a problem with this change in flash mx 2004:
Using the info panel, if you position a symbol - with the middle spot in the 3x3 grid selected - you do not move the symbol by the registration point any more (as in recent versions).
Instead you move it by the center point of the instance, and that seems to be in the middle of the symbol by default. ok, you can move it to match the registration point, but you have to do it for every instance by hand. bad.
this new behaviour is especially annoying if you use symbold that have the registration point neither in the upper left, nor in the middle. that is the case in a lot of symbols i use.
even more inconsistent: if you move a symbol by actionscript the center point is totally ignored and only the registration point is used. Is there no way to move it like this using the panels?
i use still use the trial version, but i dont think that causes my problems.
any help appreciated!
View Replies !
View Related
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
View Replies !
View Related
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 ?
View Replies !
View Related
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);
}
}
}
View Replies !
View Related
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 it
if 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?
View Replies !
View Related
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);
}
}
}
View Replies !
View Related
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
View Replies !
View Related
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.
View Replies !
View Related
Point(x, Y) Vs Object.x And .y
I am making a game by calculating vectors/points.
and i keep wondering what is less taxing on ram/cpu?
also what would be more convenient?
1
Code:
var vector1:Object = new Object();
vector1.p0 = new Point(123, 123);
vector1.vx = 5; //the direction of the vector, should this be a point too?
vector1.vx = 5;
vs
2
Code:
var vector1:Object = new Object();
vector1.p0 = new Object();
vector1.p0.x = 123;
vector1.p0.y = 123;
vector1.vx = 5;
vector1.vx = 5;
the point object, also has some nice methods like normalize etc.
it would save me a few lines.
View Replies !
View Related
Locking An Object At A Certain Point
I'm very new to Flash, just got it (Flash 5) this weekend, and trying to make my first animation. I'm trying to make it look like a dude playing a guitar, but it looks kind of strange:
http://home.no.net/skenzy/flash/Guitardude.swf
Pay attention to his right arm. I would like to "lock" his shoulder, and only his shoulder, so that it would stay in place, and not move around from frame to frame. That way it would probably look a bit more realistic.
Is there any way to do this?
All help would be much appreciated.
View Replies !
View Related
Object Point At Mouse?
Hello, I'm tring to design a basic proof-of-cocept game in Flash, and I can't seem to get this working properly: I need a movie clip able to orient itself to be pointing at the mouse even as the clip moves around the screen. What I'm attempting is something heli-attack like in that it will be a platform-based shooter, but there's a few things I have planned... Anyways, if aybody could help me out, I'd really appreciate it!
View Replies !
View Related
Object Must Face A Sertain Point
Hi,
I want to make some kind of puzzle, by dragging objects and dropping them in the place where they belong.
The puzzle should be a circle and I want the pieces to rotate as I drag them around the puzzle. That way I can see where one could fit.
So, I think that I should put something in the middle of the puzzle, defined: center.
Then I should put something in the inner side of the puzzle's pieces, defined: inner side.
Finally I want the piece to always face the center with it's inner side, so it will rotate automatically when I drag it around the puzzle in order to find the correct spot.
Any Ideas?
View Replies !
View Related
Lock Center Point Of Object?
I have a flash movie with 4 drag and drop objects. These objects can be dropped anywhere on the background wheel. No problem so far. The problem is that these background wheels can be rotated in cw or ccw direction and I need the drag and drop objects to stay locked relative to their position on those wheels. So if the wheel rotates 20 degrees cw the drag and drop x needs to stay in the same position it was dropped yet rotate the 20 degrees as if it was stuck on to the wheel with a magnet. Can this be done?
It seems like I need to lock the center point of the drag and drop objects to the center of the wheel but I have not been able to find that actionscript code. I'm just a graphic artist - so I get overwhelmed by all the programming sometimes. I appreciate any help I can get.
View Replies !
View Related
Moving An Object To A Specific Point
Hello, I thought this would be a simple thing to do but I was wrong :-(. I would like to move a movie clip one from coordinates to another using ActionScript, at a constant speed. Example (0,0) ----> (300,250) at a speed variable that i would be able to set. I can do this by using motion tweens but I MUST use actionscript.
Thanks in advance :-)
/edit BTW, i have searched the forum but i keep finding threads about easing an object to a specific point, and I cant figure out how to do it at a constant speed. Thanks.
View Replies !
View Related
[F8] How Do I Point To A Specific Object - Syntax?
Question: What is the correct syntax to append the value of a variable to the instance name in a path (i.e. _root.instanceName+variable._x)?
I have a series of movie clips, instances named "Square1", "Square2" etc. I want to do the same thing to all of them in a row and instead of typing in _root.square1.whatever over and over again I wanted to cycle through them in a for loop like this:
Code:
for (i=1; i<total; i++){
//this returns an error
_root.square+i+.product+i+._x = 40;
//so does this
target = "_root.square"+i+".product"+i;
target._x = 40;
}
I know the + is used for a string, but I don't know how to do this. I've also tried _root.square[i]._x but that didn't seem to work either.
View Replies !
View Related
[F8] How To Set Point Of Origin For Object That Follows Mouse
Hi, I have the following problem: I've set up a file in which an object follows the motion of the mouse, but when the file loads, the object starts as a default in the top left corner rather than where I placed it. How can I get the object to start from a designated location in the file? Everything I've tried so far doesn't seem to work...
Here's what I have right now:
A layer with an Object (set up as movie clip)
A layer with the following actionscript:
Code:
object.onEnterFrame = function() {
var xMouse = _root._xmouse;
var yMouse = _root._ymouse;
this._x = xMouse;
this._y = yMouse;
}
In addition, I would like the object to return to that same default location when the mouse is moved off of the file area.
Anyone who could provide guidance would be greatly appreciated!
Thanks a bunch.
Until then, Mr. T will be sitting here pitying me...
View Replies !
View Related
Resizing An Object From The Center Point?
I want to resize an object, but I want it to resize it to where the center point stays in the same spot but it resizes outward. Right now it does this:
start
http://moose.cc/uploaded/resize_ball_1.jpg
after resizing
http://moose.cc/uploaded/resize_ball_2.jpg
You can see that the tops are still aligned, but on the resized one it resized downward, I don't want that, I want to keep the center point the same and expand its size outward.
How can this be done?
View Replies !
View Related
Make An Object Stop At Specified Point
Hello guys!
Im currently working on a little game of mine, and I need a little help solving one of my greatest mysteries
If you look at my example, youŽll probably figure out my problem allready. As seen on the sheet, I want to move an object from one point to another, using actionscript.
IŽve figured out that iŽll need the help of good oldschool maths. Trigonometry to be exact. IŽve jumped the current conclusions:
Code:
moveSpeed = 5;
movingAngle = Math.atan(endY/endX)
speedX = moveSpeed * Math.cos(movingAngle);
speedY = moveSpeed * Math.sin(movingAngle);
if(this._x < endX) { this._x += speedX; }
else if(this._x > endX) { this._x -= speedX; }
if(this._y < endY) { this._y += speedY; }
else if(this._y > endY) { this._y -= speedY; }
IŽve tested this code, and it seems to work allright. The problem is that the movement is continius - the object doesnt stop at my selected point. My question is therefore; How do i stop the movement when the object reaches its destination?
IŽve tried to make if-conditions, but the speedoperarator (speed * angle) is not precise enough to make my object stop where i want it to. Any good ideas people?
Please help
View Replies !
View Related
How Do You Find An Object's Center Point?
Hi,
I'm trying to find an object's center point. I've been using .x and .y (eg. object.x) to find the registration point. From there I've been calculating the center point by adding half the objects width to object.x and half the objects height to object.y. The code below is an example of what I've done.
Or is there a way to set an object's registration point to the center of the object?
Is there a method or property that will give me an object's center point automatically without me having to calculate it?
Attach Code
center.x = object.x + (object.width / 2);
center.y = object.y + (object.height / 2);
View Replies !
View Related
Default Object Registration Point Help
Hello,
I'm on a mac osx with MX 2004, and wondering if/how I can edit the default registration point of my mc's and graphics. Right now it's defaulting in the center, and I thought it was supposed to default in the upper left corner. Is there anyway to change or set this preference? any help is appreciated. Thanks for your time ~
Dbit
View Replies !
View Related
Moving Object Registration Point
Kirupa,
you are wrong.
Moving transformation point is not the same as moving registration point.
So, the problem exists and I don't know how to beat it.
I got a movie clip with registration point set in center. Now I changed my mind and want registration point in left top corner. I dunno how to set it there without re-creating my movieclip!!
View Replies !
View Related
Rotating Object To Point Forward
I'm working on creating an animation in which there are insects randomly moving around - based on tutorials on this site. Does anybody know how to make the insect rotate so that it always points towards the direction of travel.
here's what's on my movie clip:
Code:
onClipEvent (load) {
scale = (random(100)+50);
this._alpha = random(50)+20;
this._xscale = scale;
this._yscale = scale;
//data you may want to change
width = 650;
height = 150;
speed = Math.round(Math.random()*2)+1;
//initial positions
x = this._x=Math.random()*width;
y = this._y=Math.random()*height;
x_new = Math.random()*width;
y_new = Math.random()*height;
}
onClipEvent (enterFrame) {
//rotation1
this._rotation += rot;
rot = random(500);
setInterval(changeRot, 3000);
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_x*speed;
} else {
x_new = Math.random()*width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_y*speed;
} else {
y_new = Math.random()*height;
}
}
here's what's on my timeline:
Code:
i = 0;
while (i<5) {
//duplicateMovieClip(box, "box"+i, i);
box.duplicateMovieClip("box"-i, i, 0);
i++;
}
View Replies !
View Related
Instead Of Moving, The Object Jumps From One Point To Another
the program below is suppose to make the object move instead of just jumping from one point to another. can someone help me modify my program so that it moves(what i mean by move is that is glides to the other point)... please... thank you...
ActionScript Code:
#include "tomcatURL.as"stop(); import mx.controls.Button; var mUnit:Array = new Array(i); var targetIndex:Number = 0;this.initMap(); //to include this functionthis.createEmptyMovieClip("line_mc", 1); //draw lineline_mc.lineStyle(2, 0xFF00FF, 30); this.attachMovie("arsmc", "arsmc", this.getNextHighestDepth()); var intervalTime:Number; createClassObject(Button,"btnPara", 99, {_height:60, _width:175, _x:605, _y:525}); //to create & insert buttonbtnPara._visible = true;btnPara.enabled = true;btnPara.label = "Update Move";btnPara._alpha = 100; function tarTime():Void{ btnPara.onRelease = function(){ //test if there anymore targets if(targetIndex<mUnit.length){ //object moves to the coordinates from the Database arsmc._x = mUnit[targetIndex].mLong; arsmc._y = mUnit[targetIndex].mLati; //object moves at the angle from the Database arsmc._rotation = (mUnit[targetIndex].mAngle); //creates a line using the Array value line_mc.lineTo(arsmc._x, arsmc._y); trace("x, y: " + mUnit[targetIndex].mLong + "," + mUnit[targetIndex].mLati); trace("angle: " + mUnit[targetIndex].mAngle); } //test for no more targets in mUnit if(mUnit[targetIndex].mLong == undefined){ clearInterval(intervalTime); trace("successful"); } //to go to the next Array targetIndex++; trace("Target Index:" +targetIndex); }} //to indicate the startfunction objStart():Void{ this.attachMovie("starmc", "starmc", this.getNextHighestDepth()); starmc._x = mUnit[0].mLong; starmc._y = mUnit[0].mLati; starmc._alpha = 100 trace("Start: " + mUnit[0].mLong + "," + mUnit[0].mLati);} function initMap():Void { var send_lv:LoadVars = new LoadVars(); var rec_lv:LoadVars = new LoadVars(); // read from test.mapping using mine.jsp send_lv.sendAndLoad(_global.serverURL + "mine.jsp", rec_lv, "POST"); rec_lv.onLoad = function(success:Boolean) { if (success) { var i:Number = 0; while (rec_lv["Long"+i] != null){ mUnit[i] = new Mappie(rec_lv["Long"+i], rec_lv["Lati"+i], rec_lv["Ang"+i]); i++; //counting number of objects } line_mc.moveTo(mUnit[0].mLong, mUnit[0].mLati); //the start of the line objStart(); intervalTime = setInterval(tarTime, 1000); } }}
View Replies !
View Related
Default Object Registration Point Help
Hello,
I'm on a mac osx with MX 2004, and wondering if/how I can edit the default registration point of my mc's and graphics. Right now it's defaulting in the center, and I thought it was supposed to default in the upper left corner. Is there anyway to change or set this preference? any help is appreciated. Thanks for your time ~
Dbit
View Replies !
View Related
Moving Object Registration Point
Kirupa,
you are wrong.
Moving transformation point is not the same as moving registration point.
So, the problem exists and I don't know how to beat it.
I got a movie clip with registration point set in center. Now I changed my mind and want registration point in left top corner. I dunno how to set it there without re-creating my movieclip!!
View Replies !
View Related
Scale Object Beyond Anchor Point
Hello
I have a big square with the anchor point set to the top left corner. To the right, left and bottom of this square I have collapsing menu's.
So I have been able to work with the right and bottom just fine by increasing the _xscale and _yscale But how do I increase the scale of the square to the left when the anchor point is set there? Or what is the solution?
Sandman9
View Replies !
View Related
Make Object Return To Origin Point
Attempting to script a sliding tab-navigation (similiar to the Mac Control-Strip Panel).
The sliding "tab button" has
the following script which sends
it into position on the main stage.
on (release){
this._x = 200;
}
I am trying to figure out how to
send it back to its' origin point on
the next (on release) event.
Any recommendations on how to approach script?
thanks,
superintendent
View Replies !
View Related
Unable To Point Back To Class From An Object Within It
I found it hard to explain what this post is about in the title so thank you for taking time to read it.
Let me explain what I'm trying to do. I have a class that has has an XML and loads it.
Code:
class net.quirkworks.dataMgt.SupreLoader extends MovieClip
{
private var _xmlList:XML;
private var _nTotalItems:Number;
private var _nLastLoadedItem:Number;
private var _nodeRoot:XMLNode;
private var _mcl:MovieClipLoader;
private var _mclListener:Object = new Object();
private var _aObjectsToLoad:Array;
function SupreLoader(xml:String)
{
//instantiate the moviecliplistener and add a listener
_mcl = new MovieClipLoader();
_mcl.addListener(_mclListener);
_mclListener.onLoadStart = mclListenerOnLoadStart;
_mclListener.onLoadProgress = mclListenerOnLoadProgress;
_mclListener.onLoadComplete = mclListenerOnLoadComplete;
_mclListener.onLoadInit = mclListenerOnLoadProgress;
//set the last loaded item to the one before 0. we start counting at 0.
_nLastLoadedItem = -1;
//instantiate the xml and connect to it
_xmlList = new XML();
_xmlList.ignoreWhite = true;
//trace("about to assign the onLoad");
_xmlList.load(xml);
_xmlList.onLoad = xmlListOnLoad;
}
private function startLoad(nLastLoadedItem:Number):Void
{
trace("will load starting from " + (nLastLoadedItem + 1) );
_aObjectsToLoad = createArray(_xmlList);
}
function createArray(x:XML):Array
{
var a:Array = new Array();
var nodeFirstChild:XMLNode = x.firstChild;
trace("first child: " + nodeFirstChild);
return null;
}
//xml events stuff
private function xmlListOnLoad(b:Boolean):Void
{
//trace("onLoad");
//trace(b);
if (b)
{
//_nodeRoot = _xmlList.firstChild;
//start the load process!
//trace(this);
//trace("about to call startLoad(" + _nLastLoadedItem + ");");
startLoad(_nLastLoadedItem);
}
}
Take a look at xmlListOnLoad. When I trace "this" I get the XML data. So, I can't call anything that belongs to the class from inside the onLoaded function. I tried _parent or this._parent knowing though they wouldn't work.
How can I go about this? This is not the first time I come across a hurdle like this in Flash: objects that don't have _parents anymore - makes referencing a lot harder.
Oh, and no, I do not want to use _root. In fact, I never use _root. I try to make my code as modular as possible
Thanks,
View Replies !
View Related
Question On Moving An Object's Coordinates Away From A Point
hi
the question i had was the math equation to move an objects coordinates
away from the center of the world... which in my case is 512, 386 on a flat plane.
depending on the angle of the object and the center of the world what would
be the equation to move the object away from the center, keeping the same
angle as the beginning?
i can think that just multiplying the delta x and delta y by a certain number
could simplify the process but wouldn't be accurate in the rate of speed
it was getting away from the center...
it has been so long since i had to think about these problems...
oh and it would be nice if someone could help giving an equation that
can be used on a frame based increase...
thanks
View Replies !
View Related
[f8] Need Super Help Trying To Get My Object To Ease To A Diagonal Point
Hey people, can anyone help me try to get this object myMovieClass to, instead of going to a horizontal point _x, I need the object to go to a (x, y) point,...one other thing, I need the object to pause at it's second destination, please help any input will do.
thanks a bunch
see code below:
MovieClip.prototype.easeX = function(to:Number, speed:Number, endF:Function, endO:Object, endP:Array) {
if (what._x != to) {
var _this:MovieClip = this;
var aux:MovieClip = this.createEmptyMovieClip("aux_easeX", 1337);
var previousPosition:Number = this._x;
if (isNaN(speed) || Number(speed) !== speed || speed<=1) {
speed = 1.2;
}
aux.onEnterFrame = function() {
_this._x = to-(to-_this._x)/speed;
if (_this._x == previousPosition) {
_this._x = to;
this.removeMovieClip();
if (endF) {
endF.apply(endO, endP);
}
}
previousPosition = _this._x;
};
} else {
if (endF) {
endF.apply(endO, endP);
}
}
};
var startX:Number = myMovieClip._x;
var endX:Number = startX+400;
chain = function () {
myMovieClip.easeX(endX, 1.2, myMovieClip.easeX, myMovieClip, [startX, 1.4, chain, null, []]);
};
chain();
View Replies !
View Related
Rotation Problem With Object Facing Point
ok so heres the deal, I have this short little enterframe event that recalculates the rotation of my object based on the position of a point (simply put it is always facing that point)
The code works as intended and worked great until I tried to ease the rotation to look like the object is actualy "spinning" to face it's target, as soon as I did this I noticed a new problem, the spin is based on a 0-360 scale, so if the rotation needs to be 12 then it makes the rotation to be 12, the only problem is, say the rotation of the object is 350 and it needs to be 12, the object will spin all the way around to get back to 12, but in essence it should have rotated to 372 which is the more visually logical way of doing it,
Thus I come to my issue, I can't seem to get my head around how to calculate this properly so that it always goes to the closer rotation value.
I have tried a bunch of different solutions and searched all over the place and can't seem to find anything that works
here is my current code to calculate the roation of the objects:
The object I am rotating is the holder and the object it is facing is the target
ActionScript Code:
var angle = Math.atan2(target.y - holder.y, target.x - holder.x);
var radDeg:Number = 180 / Math.PI;
holder.rotation -= (holder.rotation - (angle*radDeg))*0.4;
I would be grateful if anyone has any insight on this subject or if you know of any documentation or tutorial anywhere that speaks to this sort of problem
thx
View Replies !
View Related
Center Registration Point For 3D Object (Matrix3D)
Hi,
I am trying to do a basic 3d rotation in Actionscript for a Flex UIComponent (using Flex 3.2) and I can't make it rotate around its center. I checked out some of Flex 4's classes, on how they accomplished the FxRotate3D effect which is centered, but it's too complex to just extract out the parts I need (and the effect is very bug prone anyway).
How do you set the UIComponent to have a center registration point if you are using 3D effects? I've tried using the basic Matrix class, as there are some examples of centering registration points in 2D, but they don't work here. I have done the following so far and have achieved at least a 3d rotation, but I can't control where it is (I don't know much about matrices).
Code:
myView.addEventListener(Event.ENTER_FRAME, tick);
private function tick(event:Event):void {
myView.transform.matrix3D.appendRotation(1, Vector3D.Y_AXIS)
}
I would like to be able to just have the object rotate like you would see in papervision using the camera, but I don't know where to start.
Thanks for your help.
Lance
View Replies !
View Related
Scripting An Object's Complete 3d Rotation Around Point... Gurus?
I've been burning midnight oil for maybe three days now and im really no closer to cracking this thing. Everyone knows how to orbit an object around a point on a 2d path, right? (example at ftp://project732.ath.cx/orbit.html), using some triginometry (sin, cos) and a fake z coordinate that produces scale... Anyway, I want to create something that will allow the user to rotate the orbiting object to any point on the sphere defined by the radii in the given equation(ie, x=Math.cos(angle*Math.PI/180)*radius; //where radius defines the sphere's size). I've tried so many different ways and I've come to the conclusion that I may have to wait to actually take trig (im a sohpomore now... so lets see, thats a few years away), or teach myself (ack! without you guys? no way) the math i need to do it. Right now, im convinced I have to do something (mathamatically) that I haven't run into before and all my shinanigans in the meantime are a waste, until I run into the correct equation. What I'm looking for from you guys is a nudge in the right direction. In other words, HOW?? All I need to go on is a concept, I *think* I can figure the code out on my own, and id like to try anyway once I have an idea in my head of how to go about it. This is kind of a biggie (for me) so thanks a bunch to any out there that even try to tackle it. As always, suggestions/comments/opinions are welcome. Happy Flashing
View Replies !
View Related
Make Object Move To Point And Face Direction?
Okay; so I'm using rather an odd system to trigger enemy AI in my latest game. If you're wondering why it's odd...don't ask. I'm a 14 year old n00b; whatever works for me . Anywho; here's the triggers I need attached.
onClipEvent (enterFrame) {
if (_root.hdeath1.text>=1) {
//Enemy is alive
if (this.hitTest(_root.meleeai)) {
Here's where I need to make the MC: guy1 move to and face the MC: attack
}
}
}
Thanks
-SaRs
View Replies !
View Related
|