Flash Question
- Started
- Last post
- 10 Responses
- psv78
How can I make a resizable "table" in flash, depending on how the user open the browser window?
See this example: http://www.toormix.com/ and click "projects"
Thanks!
- PonyBoy0
as3 -
stage.scaleMode= StageScaleMode.NO_SCALE;
stage.align= StageAlign.TOP_LEFT;
stage.displayState= StageDisplayState.NORMAL;
stage.addEventListener ( "resize",stageRESIZE );public function stageRESIZE (event:Event ) :void {
var STAGEWIDTH: Number = stage.stageWidth;
var STAGEHEIGHT : Number = stage.stageHeight;
}
- PonyBoy0
the top 3 lines control your stage's scale ability, alignment and display state...
the forth line creates a listener for the 'stage' calling a function 'stageRESIZE'... which has two variables - note that they're equal to stage.stageWidth etc (properties of the stage class)... these variables allow you to capture the width / height of the stage and then of course you'd need extra code after those two variables that control the table that holds all your content...
- er... properties that extend the 'display' class actually... i think... yeah :)PonyBoy
- psv780
Wow! Can you help a little more...where do I put this?
I am not a flash Pro, so it would be very difficult for me to make this work?
Also, I am using as2...
- PonyBoy0
as2 - a little diff. syntax - same concepts:
Stage.scaleMode = " noScale "; //keeps everything from resizing w/the Stage when it's scaled
Stage.align = " TL "; //aligns the stage to the top leftsiteListener = new Object(); // create the listener
siteListener.onResize = siteLisFunct; // apply a function to the listener
Stage.addListener(siteListener); // add the listener to the 'Stage'// this is the function called when the stage is resized
function siteLisFunct() {
stageHeight = Stage.height;
stageWidth = Stage.width;
}-- put that all on your first frame of your movie... anything that needs to adjust when the stage is resized should be controlled in that function applied to the 'siteListener' object
It's a bit of a learning curve here - you have to understand functions and then understand Flash's built-in properties that you can use to control such things as the 'Stage'...
... google some of what I just wrote above like 'Stage.addListener' - plenty of info out there... but this should be enough to get you on the right track :)
- psv780
First, thank you very much for your help!
OK, I've understood the stage resize theory. But then, how can I make that "table" like in the example? Flash doesn't have a table, does it? I want to do a table like that, that displays the "squares" along the screen depending on browser window size. And also the "resizable" scroll...
Thanks!
- PonyBoy0
if you're building a fresh site... may i suggest you get out of that silly as2-ness and onto as3? :)
- psv780
Yes, I can manage that. I was doing it in AS2 because I know a little bit of it and I've never done anything with AS3...
- PonyBoy0
i gotta get to bed - it's 4am here.. :D
... quick answer to your Question - you need to build a container movieClip that houses all that content.
What I'd do is create one module for each piece of content and make sure that module is available at runtime (this means you would have a custom movieClip ready in the library that is checked 'Export for Actionscript').
I'm not sure where you're getting your content from - but what I'd do is set up an xml file with a set of nodes that look something like the following:
<Project _Name="Project Name">
<image _Location="http: // www.wherever .com/images/ imageA"/>
<image _Location="http: // www.wherever .com/images/ imageB"/>
</Project>
<Project _Name="Project Name 2">... and so on...... then feed each 'Project' node's content into a module exported at runtime...
... place each module in the containerMC based on a few things - the width of the Stage, the placement of the module before the module you're now placing in the container - and then of course the height of the stage - you'd use the same math to calculate the size of the modules on the row above...
... and the row above - the amount of modules would be based on the Stage.width...
... each time you resize the stage - you readjust the placement of the modules in that main container...
... there's a lot to 'take in' here - but the concepts are rather simple as is the math. :)
- Autokern0
From what i see from the example you linke you should do this way
store all your movieClips into an array then do with this for cycle
mc_array // that is the array of your movie clips
for (var i = 0; i < mc_array.length; i++)
{
mc = array_mc[i]
if (i ==0)
{
mc._x = [your x position]
mc._y = [your y position]
} else{
prev_mc = array_mc.[i-1]
mc._x = prev_mc._x+ prev_mc._width + [distance]
if (mc._x+ mc._widt > [available width])
{
mc._y = prev_mc._y + prev_mc.height + [distance]
}else {
mc._y = prev_mc._y
}
}
}That should do
between square brackets are the numeric value you should know/determine according to what you need.Better if you put this into a function and you call it everytime you resize the stage.