Please write back about this it's bugging me lol. Thanks a bunch!
public function set scale(s:Number):void {
var w:Number = width - width/s;
var h:Number = height - height/s;
scroll(-w/2 - _origin.x,-h/2 - _origin.y,false);
scaleX = s;
scaleY = s;
_scale = s;
_forceUpdateEdges = true;
refresh();
}
Okay bro...I'm not at the office right now but hopefully that works. Cuz everytime i try to zoom in and out (especially if i do it fast), then my graph completely leaves the stage. I need that part working cuz I'm trying to make the graph so that when a user opens the app, they start by selecting a node from a big list. I plan to populate this list by getting all the visible nodes of as many xml files as i want thru that dictionary object (hopefully i can get all visible nodes from all xmls thru that dictionary object). and when they double click the node name from the list.....the app refreshes wit the graph that node is on centers on that node! It doesnt center correctly if the zoom is off hehe. I typically use forced directed (so sick looking) but this zoom problem is happening across all layouts! ima use the code u sent me and see if it works early monday morning and i will def keep you informed on how it goes. been trying to mess wit that zoom problem for months haha. besides that i really love this ravis api....its like a mini facebook haahha. thanx billy i really appreciate this cuz i havent seen many examples using flex. good thing im relatively smart and pieced all the files together :) very good work guys it is an impressive piece of API!!! i was gonna go wit flare but that bullshit dont got no implementation for edge labels (like seriously?? lol)I LIVE FOR THIS FLEX SHITTTT....AND MAKIN BEATS HAHHAHAH. god bless u billy
public function set scale(s:Number):void {
//difference in apparent width / height due to scale changes
var w:Number = width - width/s;
var h:Number = height - height/s;
//its the -w/2 -h/2 that centers the diagram
scroll(-w/2 - _origin.x,-h/2 - _origin.y,false);
scaleX = s;
scaleY = s;
_scale = s;
_forceUpdateEdges = true;
refresh();
}
When i combine the two it's alot better....but still drags lol:
public function set scale(s:Number):void {
/* get the current value */
const s0:Number = _canvas.scaleX;
/* set the new value */
/* Fix Scaling problem (Scrollbar shouldn't scale with graph)*/
//scaleX = s;
//scaleY = s;
_canvas.scaleX = s;
_canvas.scaleY = s;
/* scroll to the center */
scroll((origin.x) * (1 - s / s0) / s0, origin.y * (1 - s / s0) / s,true);
/* redraw the edges */
refresh();
/* remember the set value, this is probably unnecesary
* since the getter could just return the value of scaleX
* but anyway */
_scale = s;
}
Thanks a bunch Billy....I am going to stick with this version of set scale (the one i posted below). It is tricky I can agree haha! Now I am currently trying to populate a big datagrid list of nodes from several different graphs (xml files) through this dictionary object: noOfVisibleNodes(). That way I can double click the node from the list and it will load it's respective graph. You see why i wanted to center the node on double click now? Makes for easy access to find the node!
-JeromeOn Mon, Oct 25, 2010 at 12:03 PM, Jerome King <jerom...@macefusion.com> wrote:
This works best when graph is in middle of stage:
public function set scale(s:Number):void {
/* get the current value */
const s0:Number = _canvas.scaleX;
var stageCenter:Point = new Point((FlexGlobals.topLevelApplication.width)/ 2, (FlexGlobals.topLevelApplication.height) / 2);
var point:Point = localToGlobal(new Point (x,y));
const s1:Number = _canvas.scaleY;
/* set the new value */
/* Fix Scaling problem (Scrollbar shouldn't scale with graph)*/
//scaleX = s;
//scaleY = s;
//Alert.show(point.x.toString());
//scroll((mouseX) * (1 - s / s0) / s0, mouseY * (1 - s / s0) / s,false);
//scroll((200) * (1 - s / s0) / s0, (200) * (1 - s / s0) / s,false);
//Alert.show((stageCenter.x - point.x).toString());
//Alert.show(stageCenter.x.toString());
//Alert.show(point.x.toString());
_canvas.scaleX = s;
_canvas.scaleY = s;
/* scroll to the center */
scroll((stageCenter.x - point.x) * (1 - s / s0) / s0, (stageCenter.y - point.y) * (1 - s / s0) / s,false);
THANKS bro its all workin out pretty good so farOn Mon, Oct 25, 2010 at 4:17 PM, Jerome King <jerom...@macefusion.com> wrote:
oh i see wats goin on...the dictionaries aren't getting set till like later. idk ill mess around wit it....and leave you alone for now lol. Thanks manOn Mon, Oct 25, 2010 at 2:42 PM, Jerome King <jerom...@macefusion.com> wrote:
all of the dictionaries are empty smh...and vgraph.noVisibleVNodes returns 0. I really don't know why these are empty makes no sense!