Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




.:pure Actionscripted Animation Goodness ::...



ok i have read many tutorials. including the one all about the drawing api in my flash mx 2004 actionscript bible... but i still have yet to understand the simplest & most basic fundamentals involved with (creating objects &) animating via actionscript.

i'd like to know... for example... how to (PURELY WITH ACTIONSCRIPT !) ::...

. make a vector based (or any) object scale, & tween as it does it. (like i see on some juxtinteractive sites... and many others...)

. make a point draw into a line. then into a shape. i want to see it draw. not just appear in full.

. move an object. from current x/y position to another x/y position... though i want it to appear to move, not just pop over to another coordinate.

** robertpenner... i keep seeing your name on more and more forums/tutorials/sites... & i've gone through one or more of your tutorials (on as.org i think) but it's still a little too complicated... the proverbial lightbulb hasn't gone off on this topic for me.

...any help or even pointers to already existing tutorials on this(/these) topics will be greatly appreciated!

T H A N K S !!

marzstar aka cyberblue aka wannabeflashgoddessvixon



Ultrashock Forums > Flash > ActionScript
Posted on: 2004-10-21


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Pure Actionscript Or Pure Animation?
Hi. I'm just curious how to achieve the effect on 2advanced.com? In the intro there were lines will form something like a 3d background and then it form the menus. Or anyone can give me links to how to achieve this effect?

Pure Actionscript Or Pure Animation?
Hi. I'm just curious how to achieve the effect on 2advanced.com? In the intro there were lines will form something like a 3d background and then it form the menus. Or anyone can give me links to how to achieve this effect?

Actionscripted Animation
I was looking for a way to animate a simple oblect's _x position from one location to a certain target location. I managed to do that by a script taken from flaskit website but the script animates with a certain easing in and out due to the nature of the code which is...

finalXScale = 880;
currentXScale = getProperty("", _xscale);
diffXScale = (finalXScale-currentXScale)/5;
setProperty ("", _xscale, (currentXScale+diffXScale));

...that is placed inside a movie clip's onclipEvent(enterFrame)behaviour.

I was looking for a way to do the same animation with the same speed tweening throughout the whole duration of the animation, if you know what I mean!
I tried to use the for action but it didn't create the intermediate keyframes I was after...

Actionscripted Animation
I had a tutorial teaching this concept, but lost it.

My goal is to have a movieclip button (button_mc) that upon being clicked, will tell an object (object_mc) to move to a certain set of coordinates (say.. 10,43).

I have no idea how to go about this with the code; any suggestions?

Thanks for your time

Actionscripted Animation
I just had a look at this website :
http://www.kodamagallery.com/frameset.html

I find it super nice !...

The top banner with swimming fishes...
Can someone tell me how that was done...is it just animation or the result is achieved by animating each part (like fins, main body) with actionscript?

Mel*

Actionscripted Animation
I just had a look at this website :
http://www.kodamagallery.com/frameset.html

I find it super nice !...

The top banner with swimming fishes...
Can someone tell me how that was done...is it just animation or the result is achieved by animating each part (like fins, main body) with actionscript?

Mel*

Help With ActionScripted Button Animation
ok i got it ...
but the actionscript is messed up
im putting the stop() action after each end frame
now each frame such as the rollover rollout and down all have animations but they are inside their master versions
now im inserting the stop() action in those frames as well as the first frame... (note: im not inserting the stop() action in the last rollout frame only the action you told me before)
but flash is giving me this when i try to preview:

**Error** Scene=Scene 1, layer=Layer 1, frame=2:Line 1: Statement must appear within on/onClipEvent handler
stop()

**Error** Scene=Scene 1, layer=Layer 1, frame=3:Line 1: Statement must appear within on/onClipEvent handler
stop()

**Error** Symbol=rollout, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler
stop()

Total ActionScript Errors: 3 Reported Errors: 3

i dont know what to do now

here is the FLA if you can mess with it please or just tell me how to fix it..ive also taken out the stop() actions so you can mess with them

Swf File And Actionscripted Animation
Hi, where I am working we are making swf files for an advertising system that display ads to flat panels in public places. One requirement of the system is to have non-scripted, 1 level only swf files, so basicly a frame by frame sequence. Is there any way to capture the frame per frame vector output of flash player so I can convert the dynamic animation into a static frame by frame one (also a swf file) ?

Thanks for any pointer on this!

Actionscripted Button/mc Animation...
hi,
(im using Flash MX)
i want to animate my buttons/mcs using AS. i want rollOver and rollOut effects to be smooth. (ie. button fades out on rollOver and fades in on rollOut.) but i want it all done with actionscript (and in one frame if possible). i tried to use this:
all code is placed on the main timeline.

Code:
button.onRollOver=function(){
if(this._alpha>0)
this._alpha-=5;
}
button.onRollOut=function(){
if(this._alpha<100)
this._alpha+=5;
}

but it didnt fade. it's alpha just jumps to 5 less or 5 more. i want it to keep going. is there some way to loop this? do i need to work with setProperty? its there a better way?

Actionscripted Radial Sunlight Animation
I would like to create a vector art rotating radial background animation - like a starburst, or more like a sunburst... or* but vector art with gradient.

Is the best way to just draw it in Flash and have it play without actionscript
or will actionscript make it run smoother?

What's the best way to start ?
Does anybosy have an example of this?

Actionscripted Animation Hit Area Problem
Hey guys, im working on this products page for a clothing company and i have a problem.
I have a scroll panel that reacts to the mouse movement left or right, the movie clip that slides contains individual product movie clips, each product movie clip has an image of a girl wearing a bikini and a hat or something similar, i have a tooltip set up so when you roll over the individual products the image of the girl scale's up and all the other images lower opacity and a tooltip comes up over the product that says buy now. This is all fine and working but the problem is that i have my code to scale the image up and lower opacity on the movieclip that contains the image and i have my code to show the tooltip on an invisible movie clip above each product. When i roll over the image of the girl at runtime the image scales up and then when i rollover the part of the image where the product is flash performs the rollout i have specified, I know the problem is that i have one movie clip over the other so theoretically i have rolled out of one and onto the another despite the fact that the cursor is still over the image.

I know this is a pretty technical explanation but im sure you guys will understand.

Any ideas what i should do?

Actionscripted Animation/math Problem
Hi,
I have a problem which I am sure is very simple to solve, but my memory of school maths isn't great so I need some help!

I am trying to use the following script to make a movie clip travel across the screen from right to left. I can't figure out why the minus value I have used in the first line of code doesn't do the trick. can someone tell me which bit of schoolboy maths I am getting wrong here?!

var endX = asban_mc._x -50;
var stepX = (endX - asban_mc._x) / 216;
asban_mc.onEnterFrame = function ()
{
if (asban_mc._x < endX) asban_mc._x += stepX;
};

Thanks for reading!
Illus12000

Bugs In Actionscripted Book Animation
Hey,

I downloaded the original FLA from te net and changed it that I can load external jpg's and swf's into it.

But threir are 2 weird problems.
Sometimes the book flashes and when you turn a page it is upside down.

You can find the files here .

Who can help me with it.

Actionscripted Text Animation Problems
Hi,

I am trying to create a text animation where the letters of my words are released from a certain spot in the movie clip and move into place somewhere else on the screen.

Sounds simple so far, except there is a twist.

I would like the letters to start with a negative y increase and have gravity pull them down over a time period until they hit their positive x, y co-ords.

I have made a simple basis for my idea, and the letters do indeed ascend and then descend with the pull of gravity. My problem comes however, where I want them to go to a certain x, y position. The y pull is too great and the letters miss their x co-ords.

Now this is hard to explain so I have included links to my files, any and all help will be appreciated.

Cheers

SWF File
FLA Source

Problem Looping Actionscripted Animation, Specifically Laco Tweening Prototypes.
Hey everyone,
I am working on an animation at work for a web banner and i have coded all of the animation using the Laco Tweening prototypes, Problem is that i need this animation to loop. I know i need to be using the callback function in some way but the forums on the laco site are down so i cant ask there. If anyone could help me with this i would really appreciate it.

Cheers

Problem Looping Actionscripted Animation, Specifically Laco Tweening Prototypes.
Hey everyone,
I am working on an animation at work for a web banner and i have coded all of the animation using the Laco Tweening prototypes, Problem is that i need this animation to loop. I know i need to be using the callback function in some way but the forums on the laco site are down so i cant ask there. If anyone could help me with this i would really appreciate it.

Cheers

Reverse Goodness
Bonjour tout le monde!

I was wondering how I could reverse the process in this attached file so that I could rerun the XML file that is outputted.

In other words at the end of this prsentation you can choose to see the code. I want to be able to write something so that the movement is declared by this code...

sorry, you'll have to see the example

thanz

vshadow

Bell Curved Goodness
I have an equation, that i made up i guess, cause i didn't get it out of a text book. And its (a^3)*(b^3). Not very exciting. But a is a continous count from 0 to 30 and goes back to 0. And b is a count from 30 to 0, and goes back to 30. I have my counters set up good, and there are no syntx errors, unless they are extremly obscure.

My problem is when i start the movie, a and b start there count and do fine, untill b, for no apperant reason stops at 9. a will continue to count to 30 and then restart its count down, but b is still stuck at 9 for some reason.

Does anyone know why this is? If you want the whole movie to see wtf im talking about just send me a mail. kaisersoze03@hotmail.com
and i'll send you the .fla

thanks for your help.

FLV, Cue Points, And Other Streamy Goodness
How can I grab a "frame" of a FLV based on it's cuepoint and use it as a thumbnail?

Stop Looping For Goodness Sakes
I have a movie clip with an 8 frame motion tween & have placed this clip into my 1 frame scene.

Can someone please explain how to get this movie to stay on the last frame after the animation and NOT LOOP. Seems like a stop action… maybe…???

Please be explicit.

THANKS a ton!!!!!!!!!!!!!!!!!



-Phil

Text Boxes, HTML, And All That Goodness
Is it possable to have a dynamic text box load a html file as it's input? I know that there is an option to "render text as html".

Basically, i want to make a flash document that can read a HTML file and display it in a pane of some sort.

Any help is appreciated.

Some PURE Newbie Help
Okay guys don't get too mad at me I just wanna know where I could get a flash maker preferibly Free or for Trial that i could make a short movie with like on www.newgrounds.com I just want to mess around a bit.

Are Sites Like These Pure AS2?
I guess my question is, when I look at sites like the new 2Advanced Site:

http://www.2advanced.com/

I always wonder, are they pure AS2.0? Do you guys think that sites like this are built entirely via classes, without a single procedural script or frame-based code or keyframe animation? I guess the reason I ask, is because there's this idea that the perfect flash site should be 100% Class-based, but when I look at sites like this, I'm amazed they can manage to do what they do, only through code.

-Z

Pure Actionscript 3.0
I am new to AS 3.0 and coming from a heavy 2.0 background (not objects and classes though) I am finding the change quite interesting.

In particular what do people think about writing flash projects from pure actionscript alone, Not sure if I'm being clear but I read in Essential Actionscript 3.0 that this is how the book approaches it!

'Pure' meaning, that you don't actually place any objects physically on the stage in a fla file, but rather things are all accessed from libraries, put there by code dynamically! (i think, that's what it means).

what are the advantages to this, does anyone approach projects this way?

I trying to avoid going through this whole book and still not be able to start with AS 3.0! Any pointers

thanks lots
Ikonik

-----------------------------------
i laugh at aliens

Failing In Pure AS3 Gui
Hello, this is my first post, and i need some help.
Currently i am trying to replace an AJAX gui with a pure-AS3-flash version, however, i have one *big* problem ( and maybe i'm just "google-impaired", but could not found any working examples online ):
on my gui, the user drags elements around ( Sprites are working fine ), click on the element to have a menu ( eventListeners and ContextMenu are very nice ) and can open up a modal-window with selectors ( and here lies my trouble ).

The window should have one first "select-box", given the selection, the gui fetches the data for the next selector from the server, which could be another select-box, or a text-box, or a label... i *must* build the gui dynamically, accordingly with the user's inputs.
Well, right now i'm absolutely frustrated that i can't even place a static select-box ( or a button ) on the stage

for instance, here http://willperone.net/Code/as3ui.php gave me this idea:

Code:
package {
import mx.containers.Canvas;
import mx.controls.Button;
import flash.events.MouseEvent;
import mx.core.Singleton;
import mx.resources.ResourceManagerImpl;
import mx.resources.IResourceManager;
import mx.resources.ResourceManager;

import flash.system.*;

public class App extends Canvas {

private var button:Button;

public function App() {

/* this should HACK-away the IResourceManager error
( http://groups.google.com/group/flex_india/browse_thread/thread/b53a0a828f1346eb )
, but it doesn't */
var resourceManagerImpl:Object =
ApplicationDomain.currentDomain.getDefinition("mx.resources::ResourceManagerImpl");
Singleton.registerClass("mx.resources::IResourceManager", Class(resourceManagerImpl));



button = new Button();
button.label = "I'm a Button!";
button.addEventListener(MouseEvent.CLICK, click);
addChild(button);
}

private function click(evt:MouseEvent):void {
removeChild(button);
}
}
}
despite the Singleton HACK, i still get this dreadful error, that aparently does not happen on a MXML project:


Code:
Error: No class registered for interface 'mx.resources::IResourceManager'.
at mx.core::Singleton$/getInstance()
at mx.resources::ResourceManager$/getInstance()
at mx.containers.utilityClasses::Layout()
at mx.containers.utilityClasses::CanvasLayout()
at mx.containers::Canvas()
at App()

i'm fixed on using pure-AS3 classes because i don't believe that MXML would play nicely with my requirements of
truly-dynamically-gui-fetched-from-server elements... no Flex-drag'n'drop, no MXML, just pure programatically AS3 classes with gui components.

Could anybody, please, point me to the right direction ? I'm really lost on how to work with select-boxes, text-fields, checkboxes and such GUI components on a pure-AS3-classes project.

(
I'm running:
$ ~/src/flex3_sdk/bin/mxmlc -version
Version 3.0.0 build 477

on Linux.
)

many Thanks in advance.

Pure AS3 And Sqlite
Is it possible to interact with a sqlite database directly using pure AS3? The deployment platform will be the browser.

I've seen connectors for use in Air, but not in a browser. I know I can use server-side stuff such as php/mysql/amf, but was wondering if there's anyway to just use AS3 and sqlite?

Pure Flash
Do you guys advice me to do a pure flash site ?? or shall I inlude with it some Html an PHP?

Pure HTML/CSS Help Here...thanks.
I am trying to get this HTML effect....(the RED Line in the center of the page to be directly in the center between the two headers)

http://mikebake.p194.pandawebsites.com/ ... center.jpg

with this page...

http://mikebake.p194.pandawebsites.com/ ... /index.php


if it looks right to you, then you are probably like me, and either have a mac, or use firefox...

but in IE I can't for the life of me get the darn red line to center in the window...it is slightly off to the right...if its not for you, try this link

http://mikebake.p194.pandawebsites.com/ ... s_home.php


The code for the page is very complex due to all the dynamic data loading...but even the simplest of pages....doesn't work...

I am trying to have a 5 column table....

the far left and far right are just indents....the 2nd and 4th are 300 wide...and the middle is 40 wide...

the middle TD has css applied to it like this..

Code:

.verticalLine {   background: #000000; background: url(/Staging-StudioAuditions/DesignTempImages/vertical_line.gif);
      background-repeat:repeat-y; background-position: center;

}


But I think the dynamically loaded text in the page makes the 2nd column widen sometimes...

I have played with all sorts of table-fixed type solutions...and cannot come up with a valid way to predict the outcome of this type deal.

I have played with
Code:

word-wrap: break-word;


but no luck at all....I have tried makiing a huge graphic in the background table and putting other tables on top of it....no luck.

What is the best way to keep a vertical line centered between to columns...and have it STAY no matter what...

The page can grown in the down direction forever.


My first born is up for grabs!!

Am Doing A Webby Using Pure Flash.
me and my friend r doing a webby in flash..... and uuh... he noticed something...... ( i have programmed nothing to do this ) but for some strange reason. when i export it to a moive as a "swf" file, just to test see if everything is working ok. it can skip to the next scenes by pressing "CTRL + ENTER" on my swf....... i reprogrammed our webby 3 times and it's still doing da same thing. does anyone know why it's doing this? or is it a bug? plz i need to know .

.... is it something to do wid scenes?
[Edited by xanbarian on 07-09-2002 at 12:51 PM]

Pure Flash E-commerce
I am really interested in making and e-commerce store that operates 100% in flash. Flash posts the variables, calculates the shipping and everything.

I have never seen a site that stays in Flash for the entire transaction process. Is there a reason not to do this?

Hybrid To Pure Flash
Hi...

Right now I have a complex page built and I want to remake this page so that it functions the same, but uses only flash (no more hybrid design).

The problem I am running in to is tying the PHP together with Flash. I can pass variables back and forth no problem, but I do not know how to detect if this variable is fully loaded in to Flash. When using a textfield it is no problem because Flash will automatically place the text in to the textfield whenever it's done loading. However, how is this done otherwise?

If I query the PHP page and have it return the result (for example: echo "&result=blah,blah,blah,blah,blah" and I want Flash to take that returned string and split it at every , (NOT do this with php's explode function), how do i determine if the return string is fully loaded <B>WITHOUT</B> using a timeline loop?

basically, let's say I have a button that has this:

Code:
on(press)
{
loadVariablesNum("page.php?section=1", 0, "POST");
myArray = result.split(",");
for(i = 0; i < myArray.length; i++)
...
}


and the php is something along the lines of

Code:
<?
$section = $_GET['section'];
switch($section)
{
case 1:
$message = "&result=blah,blah,blah,blah,blah";
break;
...
echo $message;
}
?>


how do I check, in flash, that "result" is fully loaded in to flash so that I can continue with the actionscript to manipulate the string.

Sort of like doing the following, which makes logical sense, but does not work:

Code:
on(press)
{
loadVariablesNum("page.php?section=1", 0, "POST");

while(1)
if(message != "")
{
myArray = result.split(",");
break;
}
}

Using Library Symbols Vs. Using Pure AS3
Hey,

I have a pretty general question about Flash CS3/ AS3. I'm creating an application that has several windows (forms) that will be visible at different times, and I've been able to successfully implement them using both pure AS3 (creating classes that build the windows and populate them all with AS3 addChild...), and also using the "old" author time way (create the symbols for them in the library and populate and control them with the getChildByName() methodology).

My question is pretty simple, and in many ways it is probably opinion. Is there a significant difference in performance one way or the other ? On the one hand, using the coded approach makes for smaller file sizes, but then using the symbol approach seems to make designing the visuals much faster and easier to edit.

File size isn't that big of a consideration, only because the app is going to be run on a LAN most of the time, where loading times are not that much of a concern.

In using the coding approach, I find myself 'mocking up' the appearance of the windows anyway, and then just translating that into code, but is there a real reason to do this, or should I just make the symbols up and pull them from the library when I need them.

I'm sure that there is a happy medium to be found, but I wanted to see if there is a definitive 'best practice' for this type of thing and I figured others might have questioned it as well.

Thanks in advance.

MovieClip Instance In Pure AS3
I am sure that this has been asked before so please forgive me.

What I'm attempting to do is display a GIF image with fading provided by TransitionManager. The only examples I can find assume that a MovieClip instance has been created already in the Flash authoring tool. How can I create this instance in pure Actionscript 3.0?

Pure As3 Vs Frame Script..
Im am getting to grips with AS3 and classes, but am struggling on where to start on a project now. There are so many ways of building a site:

pure as3, all classes and objects in library
objects in library, script on frames

What is the best solution to working out which way to start a project?

Pure Code (CreateEmptyMovieClip)
Hello,
I have been using Flash for quite a while now, thinking I had got rather good at actionscript.
How wrong I was.
Having copied code from various places in order to try and figure out how it works, I am completely BAFFLED by what can be achieved without tool-drawing anything at all.
A good example would be McGiver's "eye candy flowers"

My question therefore is: Could anyone explain in a very basic way how to create a shape and colour it using pure actionscript? possibly explaining step by step how to get curves and angles as in the example above.
Just a couple of lines would do, just to get me started...

Actionscript - There's always something new

Many thanks for any help on this one
All the best

Magic Or Pure Coding?
Does anyone have a clue how did they create this menu??
http://www.capitalcomm.com.my/

This strings are amazing.... even the preloader in separated strings..

Did they use FUSE?...
I really wanna know this code... I am clueless how to achieve this effect.... I have seen tons of others examples but none is as good as this one..

thanks..
cheers

Pure Mvc /// Design Patterns
here is a really cool MVC app development framwork i have found and am currently playing with, check it out:

http://puremvc.org/
what does everyone think?

Pure Actionscript Preloader
hi,

actually i am trying to get a little insight into this whole object orientated thing. so i want to create a preloader which is pure code.
the problem is that the variable showing the percent loaded does not update, it stays at zero (at least that's what the textfield shows me); the variable that should show me the current frame of _root stays at 1 however the music that starts with frame 2 in my testfile can be heard.
finally the dynamically created textfields disappear when the film jumps to frame 2.

could anybody please correct my code and tell me why it didn't work?
i am not quite a newbie to flash but i am as far as it concernes object orientated programming...

thanks a lot

here is my code (which is positioned on the first frame of the root):


_root.stop();
finishedloading = 0;
Preloader=new MovieClip();
MovieClip.prototype.makeTextfields=function(){
    //textfield for percentage
    _root.createTextField("percent",2,10,10,50,20);
    percent.type="dynamic";
    percent.variable="_root.percent";
    percent.border=true;
    percent.background=true;
    percent.backgroundColor="0x00ffff";
    
    //textfield for current (root)frame - just to see where we are while developing the code
    _root.createTextField("WhereAmI",1,10,40,50,20);
    WhereAmI.type="dynamic";
    WhereAmI.variable="_root.whereami";
    WhereAmI.border=true;
    WhereAmI.background=true;
    WhereAmI.backgroundColor="0x00ff00";
    
    // textStyle
    format=new TextFormat();
    format.font="Arial";
    format.bold="true";
    format.size="16";
    format.align="right";
    format.color="0x000066";
    //attach format to textfields
    WhereAmI.setTextFormat(format);
    percent.setTextFormat(format);
}// end of makeTextfields()

MovieClip.prototype.preload = function() {
    total = getBytesTotal();
    loaded = getBytesLoaded();
    percent = Math.round(100*loaded/total);
    _root.percent = percent+"%";
    _root.whereami = _root._currentframe;
    if (finishedloading==0) {
        if (percent == "100%") {
            _root.nextFrame();
            finishedloading = 1;
        }        //end of if-condition
    }    //end of if-condition
}//end of preload()
Preloader.createEmptyMovieClip(MCPreloader,1);
MCPreloader.onLoad=makeTextfields();
MCPreloader.onEnterFrame = preload();


regards



Communicating Between Flash MX And Pure Data (PD) ?
anyone have idea about how to implement it ?

the communication should happen in both directions.

using database/php as gateway between them is one possibility ???

Generating Menus With Pure Actionscript
hey there

I've seen this sort of thing done but don't know advanced actionscript. Can somoen point me to some code that I can edit to my own specs?

here is what i need to do. An interface for a cd rom i am designing need to be generated on the fly so that the client can edit a simple xml file (or whatever kind) to make new menus, sub menu, sub subs, and then links to portfolio pieces, jpgs, which also are pulled out of a folder on the server via actionscrpting. Using flash MX by way

ANy ideas? Thanks much for any help!


Stevie Spin

Alpha Fading MC Using Pure Actionscript
Hi everybody i have a question...i want to make a banner that looks similar to this http://nikon.ca/en/ each picture is a movie clip and after its done playing it uses alpha to change from that mc to another one...i only want to use actionscript nothing else....any help is greatly appreciated!!!

[solution] MX Components In Pure Actionscript...
Problem: You want to use MX components using only actionscript.

Solution: Yes, it is very possible, as I will now describe.


Setup

Before starting you must ensure you have you the framework.swc in your library path. The details on how to achieve that in the Flex Builder can be found here: http://www.moock.org/blog/archives/000197.html

For anyone using the SDK, you shouldn't have any problems, the mx components appear to be automatically added to the path.

To test if you have the correct setup try compiling the minimal application:


Code:
package {

import mx.core.Application;

public class MXApp extends Application
{
public function MXApp()
{
}
}
}
NOTE: Running this application will generate runtime errors. However, you must be able to COMPILE it to proceed.


Problem Details

There are, as I see it, two major errors people encounter trying to use MX components:

1) The component is added but does not appear.

2) The application generates runtime errors.


Solution Details

The solution to (1) is simple. Any MX component must be a child of an class descended from mx.core.Application or it will not be visible.

Most actionscript applications extend flash.display.Sprite, but to use MX components the application must extend mx.core.Application.

The solution to (2) is more complex. Generally speaking it involves specifying the default style characteristics of the MX components. This is done via the CSSSyleDeclaration object, and MUST BE DONE before any MX component is loaded.

The style elements are listed in the adobe livedocs. For example, the base element, Application, lists:


Quote:




Styles
backgroundGradientAlphas="[ 1.0, 1.0 ]"
backgroundGradientColors="undefined"
...




These values must all be specified before an Application instance can be created. The same applies for any other component; button, label, scrollbar. Indeed, the matter is further complicated by the fact that any component that CONTAINS other components requires that the child component style elements also be specified.

To specify the style elements first a CSSSyleDeclaration object is required for the type of application. Then the setStyle() is used to specify each style element. For example, for Application it might be:


Code:
style = new CSSStyleDeclaration ("Application");
style.setStyle("backgroundGradientAlphas", [ 1.0, 1.0 ]);
style.setStyle("backgroundGradientColors", undefined);
style.setStyle("horizontalAlign", "center");
style.setStyle("horizontalGap", "8");
...
NOTE: The name of the style declaration MUST match the MX component class name. It is possible however, to call style = new CSSStyleDeclaration (); and then bind a single style declaration to multiple components using mx.styles.StyleManager.setStyleDeclaration ("NAME", object, false). See the livedocs.

NOTE: It is important to pay attention to the livedocs. The style elements listed there may come in the form: "[ 1.0, 1.0 ]", or "undefined", or "mx.skins.halo.ScrollThumbSkin", or "No default". These are NOT TEXT STRINGS. Make sure the appropriate data is passed to setStyle().


Sample Application

The following is a sample actionscript application that compiles both under the Flex builder and the SDK to provide a single working swf file.

Note: This object uses Label, Application, Button, Scrollbar, HScrollBar, VScrollBar. That's about the minimum you can get away with, because the Application automatically adds a scrollbars, which includes buttons.


Code:
package {

import mx.containers.*;
import mx.controls.*;
import mx.core.*;
import mx.styles.*;
import mx.skins.halo.*;
import mx.events.FlexEvent;

public class MXApp extends Application
{
public function MXApp()
{
var style:CSSStyleDeclaration;

style = new CSSStyleDeclaration ("Application");
style.setStyle("backgroundGradientAlphas", [ 1.0, 1.0 ]);
style.setStyle("backgroundGradientColors", undefined);
style.setStyle("horizontalAlign", "center");
style.setStyle("horizontalGap", "8");
style.setStyle("modalTransparency", "0.5");
style.setStyle("modalTransparencyBlur", "3");
style.setStyle("modalTransparencyColor", "#DDDDDD");
style.setStyle("modalTransparencyDuration", "100");
style.setStyle("paddingBottom", "24");
style.setStyle("paddingTop", "24");
style.setStyle("verticalAlign", "left");
style.setStyle("verticalGap", "6");

style = new CSSStyleDeclaration ("ScrollBar");
style.setStyle("borderColor", "0xB7BABC");
style.setStyle("cornerRadius", "0");
style.setStyle("downArrowDisabledSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("downArrowDownSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("downArrowOverSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("downArrowUpSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("fillAlphas", [0.6, 0.4]);
style.setStyle("fillColors", [0xFFFFFF, 0xCCCCCC]);
style.setStyle("highlightAlphas", [0.3, 0.0]);
style.setStyle("thumbDownSkin", mx.skins.halo.ScrollThumbSkin);
style.setStyle("thumbIcon", undefined);
style.setStyle("thumbOverSkin", mx.skins.halo.ScrollThumbSkin);
style.setStyle("thumbUpSkin", mx.skins.halo.ScrollThumbSkin);
style.setStyle("trackColors", [0x94999b, 0xe7e7e7]);
style.setStyle("trackSkin", mx.skins.halo.ScrollTrackSkin);
style.setStyle("upArrowDisabledSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("upArrowDownSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("upArrowOverSkin", mx.skins.halo.ScrollArrowSkin);
style.setStyle("upArrowUpSkin", mx.skins.halo.ScrollArrowSkin);

style = new CSSStyleDeclaration ("HScrollBar");
style.setStyle ("repeatDelay", "500");
style.setStyle ("epeatInterval", "35");

style = new CSSStyleDeclaration ("VScrollBar");
style.setStyle ("repeatDelay", "500");
style.setStyle ("epeatInterval", "35");

style = new CSSStyleDeclaration ("Button");
style.setStyle("borderColor", "0xAAB3B3");
style.setStyle("color", "0x0B333C");
style.setStyle("cornerRadius", "4");
style.setStyle("disabledColor", "0xAAB3B3");
style.setStyle("disabledIcon", null);
style.setStyle("disabledSkin", mx.skins.halo.ButtonSkin);
style.setStyle("downIcon", null);
style.setStyle("downSkin", mx.skins.halo.ButtonSkin);
style.setStyle("fillAlphas", [0.6, 0.4]);
style.setStyle("fillColors", [0xE6EEEE, 0xFFFFFF]);
style.setStyle("focusAlpha", "0.5");
style.setStyle("focusRoundedCorners", "tl tr bl br");
style.setStyle("fontAntiAliasType", "advanced");
style.setStyle("fontFamily", "Verdana");
style.setStyle("fontGridFitType", "pixel");
style.setStyle("fontSharpness", "0");
style.setStyle("fontSize", "10");
style.setStyle("fontStyle", "normal");
style.setStyle("fontThickness", "0");
style.setStyle("fontWeight", "normal");
style.setStyle("highlightAlphas", [0.3, 0.0]);
style.setStyle("horizontalGap", "2");
style.setStyle("icon", null);
style.setStyle("leading", "2");
style.setStyle("overIcon", null);
style.setStyle("overSkin", mx.skins.halo.ButtonSkin);
style.setStyle("paddingBottom", "0");
style.setStyle("paddingLeft", "0");
style.setStyle("paddingRight", "0");
style.setStyle("paddingTop", "0");
style.setStyle("repeatDelay", "500");
style.setStyle("repeatInterval", "35");
style.setStyle("selectedDisabledIcon", null);
style.setStyle("selectedDisabledSkin", mx.skins.halo.ButtonSkin);
style.setStyle("selectedDownIcon", null);
style.setStyle("selectedDownSkin", mx.skins.halo.ButtonSkin);
style.setStyle("selectedOverIcon", null);
style.setStyle("selectedOverSkin", mx.skins.halo.ButtonSkin);
style.setStyle("selectedUpIcon", null);
style.setStyle("selectedUpSkin", mx.skins.halo.ButtonSkin);
style.setStyle("textAlign", "center");
style.setStyle("textDecoration", "none");
style.setStyle("textIndent", "0");
style.setStyle("textRollOverColor", "0x2B333C");
style.setStyle("textSelectedColor", "0x000000");
style.setStyle("upIcon", null);
style.setStyle("upSkin", mx.skins.halo.ButtonSkin);
style.setStyle("verticalGap", "2");

style = new CSSStyleDeclaration ("Label");
style.setStyle("color", "0x00ffffff");
style.setStyle("disabledColor", "0x00000000");
style.setStyle("fontAntiAliasType", "advanced");
style.setStyle("fontFamily", "Verdana");
style.setStyle("fontGridFitType", "pixel");
style.setStyle("fontSharpness", "0");
style.setStyle("fontSize", "10");
style.setStyle("fontStyle", "normal");
style.setStyle("fontThickness", "0");
style.setStyle("fontWeight", "normal");
style.setStyle("paddingLeft", "0");
style.setStyle("paddingRight", "0");
style.setStyle("paddingTop", "0");
style.setStyle("paddingBottom", "0");
style.setStyle("textAlign", "center");
style.setStyle("textDecoration", "normal");
style.setStyle("textIndent", "0");

this.addEventListener(FlexEvent.CREATION_COMPLETE, completedCallback);
}

private function completedCallback (E:FlexEvent):void
{
var lb:Label = new Label ();
lb.width = 100;
lb.height = 100;
lb.text = "Hello World";
addChild (lb);
}
}
}

End
Thanks to everyone who posted about this, it was a really annoying thing to struggle with when no-one knew the answer.

I hereby grant anyone who wants complete permission to take this post or any part of it and do with it as they please (even claim it was their own if they want .

g'night.

Best Way To Create Different Screens With Pure Actionscript
I'm trying to write a simple game with pure Actionscript (i.e. no Flash CS3 or Flex MXML). What's the best way to create different screens, and switch between them?

Is it possible to use the [Frame(factoryClass="blarg")] notation to create a separate frame/class for each screen?

Tutorial: Spinning Preloader In Pure AS3
I just finished a tutorial on an all-time classic, the spinning preloader. -> Link

I hope you find the tutorial useful.

Pure Flash Page Has Problems With MS-IE
I produced a pure Flash web page for some friends who have a small local fashion label. I made the movie with Flash MX Version 6 and made a primitive HTML-wrapper for it in Dreamweaver MX. The page has behaved very well over years and was enhanced with occasional updates.

Recently however people, usually from corporate Windows platforms report problems accessing the page. In fact the page seems to stay black for them. Since I am only an occasional Flash programer I am puzzled and I wonder about an easy cure to this.

Would any of you experts here offer help for me? Thank you very much. Oh yes, the page is www.viento.ch. Press on ''VIENTO'' to start. Its works well in Safari, Firefox, Netscape and older type IEs.

Thank you

Saving JPG Without External Components, PURE PHP
i made a thing with flash 8 to take an image from the webcam and save it, but NOT USING PHP!!! the image is not saved in JPG format, is saved in NIM format, i invented that bicouse my server dont have the image component of php to create images, so i invent this way to save pictures to files, look!

if you have a better way of doing this, please let me know, realy.

here is the link, you have to have a webcam: http://grupoapis.com.ar/jpv/flash8/

the file taken from the webcam is 40 Kb aprox. So is not the most efficient way of saving images, but take a look!!

takes a wile in upload.

NOTE: it dosent have a preloader!

Tutorial: Spinning Preloader In Pure AS3
I just finished a tutorial on an all-time classic, the spinning preloader. -> Link

I hope you find the tutorial useful.

Pure ActionScript For Waving Flag
Last edited by Codemonkey : 2007-06-14 at 10:13.
























Hi everybody,

Does anyone know of a pure ActionScipt way of generating a waving flag animation like the following (made in swish by the way)?

http://files.swish-tutorials.com/ex/...le.php?id=1482

Thx, KD

AS3 - Tutorial: Spinning Preloader In Pure AS3
I just finished a tutorial on an all-time classic, the spinning preloader. -> Link

I hope you find the tutorial useful.

Copyright © 2005-08 www.BigResource.com, All rights reserved