create your own

Flash CS3, CS4 Tutorial, Graphics Properties

66
rate or flag this page

By frenchsquared

Flash CS3 Tutoral

Flash CS3 Tutoral
Flash CS3 Tutoral


CS3 Basic Properties

In this Flash CS3 Tutorial I am going to go over the basic Graphic Properties and how to control them. Flash CS3 and ActionScript 3.0 give the programmer the ability to control the properties of graphic while the swf is playing. That means that with ActionScript you can create tetris style games that enable a graphic to move as well as change shape and color based on user input. So, lets jump right into this Flash CS3 Tutorial and start manipulating graphics.

In the start01 folder you will find a movie clip labeled chevy_mc, see picture. As you will notice the truck isnt even on the stage. Lets start by simply moving the trucks position so as to located the truck onto the stage. Select the first key frame on the actions time line and add the code from the example. As you will soon see the synax has changed since ActionScript 2.0, you no longer need the underscore ( _ ) in front of many of the property names. This code simple moves the trucks location from wherever it may be to an x position of 100 pixels in and a y position of 50 pixels down. You may press Control-Enter to see the truck appear on stage.

chevy_mc.x=100 chevy_mc.y=50

Lets rotate the truck, simple add the example code the the action pannel and press Control_Enter. The property roation is rather self explanitary. It rotates the object.

chevy_mc.rotation=25

scaleX and scaleY simple scale the movie clip, the example code will scale the image down to one quarter of its current size. While the width and height properties will change the width and height to 250px by 250px. Scale changes the size of the object based on the original object, not unnecessarily what is on the stage. While the width and height values are an exact setting.

chevy_mc.scaleX=.25 chevy_mc.scaleY=.25

chevy_mc.width=250 chevy_mc.height=250

The alpha property has scene a change in that the value now ranges from 0 to 1 instead of 0 to 100. The following code will change the alpha to 50% transparent.

chevy_mc.alpha=.5

Relatively Controlling Properties In the previous examples I showed you haw to control an object's properties based on a set value, but at times you may want to control an Objects Properties based on another object.

Lets rotate the position of the truck based on a mouse click. Start by creating an event handler by adding a listener to the truck to detect a mouse click.

function rotate(yourEvent:MouseEvent):void{ chevy_mc.rotation+=25; }; chevy_mc.addEventListener(MouseEvent.CLICK, rotate);

Color You can you the ColorTransform class to manipulate the Red, Blue, Green and Alpha channels of an object. To change the color you need create a new variable, give the variable the data type of ColorTransform and set it equal to new ColorTransform. Next you need to define the new color. and finally change the color. with the colorTransform. If you test the movie you will see that the truck as turned a torques color. Not very useful for this image, however if we move on I will show you how to make advanced color changes.

var yourNewColor:ColorTransform = new ColorTransform(.5, 2, 2, 1, 0, 0, 0, 0); chevy_mc.addEventListener(MouseEvent.CLICK, changeColor) function changeColor(yourEvent:MouseEvent):void{ chevy_mc.transform.colorTransform = yourNewColor; };

In this case we are passing parameters to the colorTransfor Property. The parameters are offset values(red, green, blue, alpha, and offset values). The best way to understand how these channels relate to the objects color is just to play with them for awhile. You do not have to define the color values when calling the ColorTransform instance. You can specify a value for each color property if you so wish. Either way of defining the values works in the same manner. However, if you set the values individually you have more control over the colors.

var yourNewColor:ColorTransform = new ColorTransform(); chevy_mc.addEventListener(MouseEvent.CLICK, changeColor) function changeColor(yourEvent:MouseEvent):void{ yourNewColor.redMultiplier=.5; yourNewColor.greenMultiplier=.8; yourNewColor.blueMultiplier=3; yourNewColor.alphaMultiplier=1; yourNewColor.redOffset=0; yourNewColor.greenOffset=0; yourNewColor.blueOffset=0; yourNewColor.alphaOffset=0; chevy_mc.transform.colorTransform = yourNewColor; };

The offsets are relevant to the 255 RGB setting. If all offset values are set to 255, would turn the object white.

IT Admin

  • CSS, How to understand inline and block level elements.

    Block level  elements are normally displayed as blocks with line breaks before and after. Examples of block level elements include paragraphs, headings, divs and block quotes. Inline elements are... - 4 months ago

  • CSS, How To tweak css for only Safari?

    If you have spent anytime dealing with CSS you have run into issues with a browser rendering code incorrectly. You may even have gone as far as to make several style sheets and use a browser check... - 4 months ago

  • CSS, How to Hide Styles from Older Browsers?

    Some older browsers, such as Netscape Navigator 4 and IE 4, have poor support for CSS. It is possible to hide styles from these browsers using specific media types and @import rules. All styles will... - 4 months ago

  • CSS, How to use @import styles

    @import Styles? Header and external style sheets also can import other style sheets using the @import rule. The @import rule must be placed before all other rules in the header or external style... - 4 months ago

  • CSS, How to use External Style Sheets!

    The third method of applying styles to  document involves linking to external style sheets. External style sheets are the most appropriate method for styling documents. If styles need to be... - 4 months ago

  • CSS, How to Use Header Styles

    Header styles also can be used to style the <p> element. The CSS rules can be placed in the head of the document using the style element. Like inline styles, header styles, header styles... - 4 months ago

  • CSS, How to Apply Inline Styles.

    CSS, Inline styles can be applied directly to elements in the HTML code using the style attribute. However, inline styles should be avoided wherever possible because the styles are added to the HTML... - 4 months ago

  • Twitter Weekly Updates for 2009-08-09

    New blog post: CSS, What is a <div> http://bit.ly/Sbfu # Flash, ActionScript tutorials on loops http://bit.ly/QMq8t # Great PHP Tutorial on using include and require. Include is a great way... - 4 months ago

CSS Tutorials

  • Twitter Weekly Updates for 2009-11-29

    looking to make a contact form for your flash website? Then check out this simple tutorial. http://tinyurl.com/yjnocyc # http://twitvid.com/06368 RT @dkprinting A quick vid of @joelcomm Top 1% Report newsletter being bound . Learn more about the report – http:/ # Adopted a Ragdoll Kitten sunday, actually found a true Ragdoll at the pound. # We decided to [...] - 4 days ago

  • Twitter Weekly Updates for 2009-11-22

    The maker of iFart is sending a message to Steve Jobs and Apple: http://digg.com/d31ARUx?t # An Open Appeal to Steve Jobs: http://digg.com/d31ARUx?t # Powered by Twitter Tools - 2 weeks ago

  • CSS, How to work with content areas.

    The content are of a box can be given width, height, and color. Width and height can be specified in points (equal to 1/72 of an inch), picas (equal to 12 points), pixels, ems, exes, millimeters, centimeters, inches, or percents. - 2 months ago

  • Twitter Weekly Updates for 2009-09-20

    My Farmville is broken, cant access, gifts, market, or ribbons # Farmville and zynga are a rip off. Watch out. There are still some glitches in the game and zynga told me to bad Im unimportant. # wouldnt it make more since for a developer to fix broken issues rather then add new features. Well not farmville, [...] - 2 months ago

  • Twitter Weekly Updates for 2009-09-06

    I need 5 more neighbors on FarmVille help me out. http://bit.ly/tLsni # looking for flash tutorials and how to guides check out – http://frenchsquared.com/ # Powered by Twitter Tools - 3 months ago

  • Twitter Weekly Updates for 2009-08-30

    New version of Wordpress theme adStyle is live at: http://wordpress.org/extend/themes/adstyle # Just finished installing OS X 10.6 on my new Solid State drive. Very impressed, seems noticeably faster. # I need more neighbors on Farmville for Facebook. Hit me up as a friend. http://bit.ly/tLsni # playin farmville on my macbook 10.6 and new solid sate sata II [...] - 3 months ago

  • CSS, How to properly use Border Styles.

    The border properties specify the width, color and style of the border of an element. Shorthand border properties include border-top, border-bottom, border-right, border-left and border. - 3 months ago

  • CSS, How to Padding Padding and more Padding

    Padding can be applied to the outside edges of the content area of any block level or inline element. Padding creates the space between the edge of the element and its content. - 3 months ago

Comments

RSS for comments on this Hub

frenchsquared profile image

frenchsquared  says:
2 years ago

This is a valuable Flash Tutorial, if you understand Flash you should be able to follow this tutorial. I have had many people complement me on these tutorials

Submit a Comment

Members and Guests

Sign in or sign up and post using a hubpages account.


optional


  • No HTML is allowed in comments, but URLs will be hyperlinked
  • Comments are not for promoting your hubs or other sites

working