May 22, 2013, 07:13:34 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Prowlie Welcome back! The site migration is complete and normal service resumed.
Advanced search
Pages: [1]   Go Down
Print
Author Topic: Anchoring objects in flash  (Read 2663 times)
0 Members and 1 Guest are viewing this topic.
Juggleballz
Funk Junky
MotM
Heroic
**
Offline Offline

Gender: Male
Posts: 4926



WWW
« on: September 30, 2008, 01:55:24 AM »

I need help.

Okay dokay, these what is happening.

I am building a flash site, that adjusts the stage width to the width of the browser window, done simply through the publish settings under the HTML tab.

I have been searching all day to find code that can anchor flash objects to particular corners of the browser window. This is done simply by  using a listener to find the stage width.

Say I want to anchor the object to the right of the page, all I do is make it work out the new stage width then tell the object to move to the new stage width, and the object._x should be placed against the right side of the browser window. Hunky fucking dory. This works.

HOWEVER! this is only possible if the original stage is positioned top left of the browser.

Code:
// ***Stage aligned top left
Stage.align = "TL";
// *** Stop the stage from scaling with the browser window.
Stage.scaleMode = "noScale";
stop ();
// initiate postitions and scaling values for objects


boxbutton._x = Stage.width - boxbutton._width
// end initial position setting

//create a listner that checks to see if the browser window is resized
sizeListener = new Object();
sizeListener.onResize = function() {
// change movieclip properties when the window is resized.

boxbutton._x = Stage.width - boxbutton._width
};
Stage.addListener(sizeListener);

Right so basically the boxbutton object's x coordinate is the same as stage width, but this is base don the fact that the top left hand corner of the stage is set at the cordinates 0,0 of the browser window.

If you replace the "LT" at the start of the code with s "C" it centres the flash stage in the centre of the browser.

BUT now the code telling the box to position itself to the right hand side of the browser doesn't do it correctly. So what I need to know is how can I make this code work out that the stage is not set at 0,0 but in fact set at a varying position based on the browser size.

I also need the boxbutton, when clicked, to enlarge to 90% size of the stage (again based on the size of the browser window), so its position coordinates now become negative numbers.

Does this make sense.

Here is where I downloaded the demo fla and tried to change it to suit. The entire thing is called liquid flash, in the sense that the objects move according to the broswer size, very much like Liquid CSS.

http://www.tutorio.com/media/flash/liquid-demo.html

http://www.tutorio.com/media/flash/liquid-demo.zip

One solution i have is to position the stage top left and reposition everything I have on stage with code to make them centered but FUCK THAT.

Thanks for ytou help folks.  Kiss

Logged

The value of life lies not in its length, but in its depth and breadth.
Juggleballz
Funk Junky
MotM
Heroic
**
Offline Offline

Gender: Male
Posts: 4926



WWW
« Reply #1 on: September 30, 2008, 11:37:02 AM »

Sorry bumping this so that it is seen on the front page of the forum.

I know im committing serious criminal offences doing this but im very drunk so i make the rules.

Saying you are drunk always works. Especially when you drink drive.
Logged

The value of life lies not in its length, but in its depth and breadth.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #2 on: October 01, 2008, 12:12:59 AM »

I'm not entirely sure why you want it centred, but something like this?
Code:
boxbutton._x = (Stage.width / 2) + 100 - boxbutton._width;
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
Juggleballz
Funk Junky
MotM
Heroic
**
Offline Offline

Gender: Male
Posts: 4926



WWW
« Reply #3 on: October 01, 2008, 08:26:38 AM »

Basically I have started making a site, and it is 700 x 500 pixels. The site is not a typical site format. The logo fades in in the centre of the stage then fades out, and the navigation fades in which is also centered.

I want it to be that the site is always centered but the logo to be always in the bottom right hand corner of the stage. The flash site takes up the entire browser window and resizes depending on the browser window's size, so I would like it to be that the logo appears in the bottom right hand corner no matter what size the browser is.

So postioning the entire site in the top left hand corner allows for the logo to be placed in the bottom right hand corner with no problems and always sits there, however this fucks up my centered naviagation and logo fade in during the intro.

My only solution I know at the moment (and I don't wish to do it this way but if needs be I will) is that I position the stage top left, and using code make the navigation position itself automatically. This is more of a pain in the ass because i only need to position one object as opposed to the entire navigation buttons.

If you wish I can upload the swf file with diagramatic explanations to what I want.

Thanks for you help by the way. Smiley
Logged

The value of life lies not in its length, but in its depth and breadth.
Jaehl
Mobal Gloderator
Global Moderator
Veteran
***
Offline Offline

Gender: Male
Posts: 1418


/* No comment */


WWW
« Reply #4 on: October 01, 2008, 09:17:33 AM »

If you wish I can upload the swf file with diagramatic explanations to what I want.
Yes please Smiley
Logged


<a href="http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf" target="_blank">http://i17.photobucket.com/albums/b90/Jaehll/Actionscript_Banner.swf</a><a href="http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/motm.swf?vTitle=oct%2Fnov%2007.swf</a>
Sarus translator:
<a href="http://www.jaehl.com/files/progress.swf" target="_blank">http://www.jaehl.com/files/progress.swf</a>
Juggleballz
Funk Junky
MotM
Heroic
**
Offline Offline

Gender: Male
Posts: 4926



WWW
« Reply #5 on: October 01, 2008, 07:01:15 PM »

Here is a pic describing the issue:



The code on Frame 1:


// Stage aligned top left or centered, in this case centered - change C to "TL" to align it top left
Stage.align = "C";
//  Stop the stage from scaling with the browser window.
Stage.scaleMode = "noScale";
stop ();

//Logo in bottom right hand corner has instance name - logobox
logobox._x = Stage.width - logobox._width



//create a listener that checks to see if the browser window is resized
sizeListener = new Object();
sizeListener.onResize = function() {
   // change movieclip properties when the window is resized.
   
   logobox._x = Stage.width - logobox._width
};
Stage.addListener(sizeListener);


----

So the code above is working out the browser window size, then positioning the logobox on coordinates that match the new resized stage width and subtracting its own width in order to position perfectly. However I have a feeling this does not work because the stage is originally centered as opposed to being aligned top left. I think...?

Problem 2:

Say I click one of the centered buttons, it resizes to fit the screen and become a background for that particular section.
like so:


Does this make sense?

This might help:
Save and open these to files in SWF player (works the same) and enlarge the swf player window manually, and the box should stick to the bottom right hand corner:

Download - http://www.axisthree.com/Site_issue.swf
Download - http://www.axisthree.com/Site_issue2.swf

Thanks Jaehl

« Last Edit: October 01, 2008, 07:44:18 PM by Juggleballz » Logged

The value of life lies not in its length, but in its depth and breadth.
Cel
Senior Member
****
Offline Offline

Gender: Male
Posts: 967


« Reply #6 on: October 02, 2008, 01:50:55 AM »

This might help:
When positioning the box with the stage zero at the center, subtract Stage.Width / 2 (or Height if you want to align it vertically) from the position of the object you want to align.

Since you placed the stage zero point in the center, the positive width has been halved. So now it goes from -350 to 350 instead of 0 to 700, which means you have to cut your base position in half as well.
« Last Edit: October 02, 2008, 02:15:41 AM by Cel » Logged

My DeviantArt

<a href="http://img.photobucket.com/albums/v661/Vector88/sfx_3.swf" target="_blank">http://img.photobucket.com/albums/v661/Vector88/sfx_3.swf</a><a href="http://img.photobucket.com/albums/v697/Espengenin/banner1star-1.swf" target="_blank">http://img.photobucket.com/albums/v697/Espengenin/banner1star-1.swf</a>
Brackenwood
   

 Logged
Pages: [1]   Go Up
Print
Jump to:  

Theme by Pieter, based on Black Rain by Crip Powered by SMF 1.1.16 | SMF © 2011, Simple Machines XHTML | CSS

Page created in 0.144 seconds with 25 queries.