Solved

Actionscript 3 sprite.graphics.drawPath function not working

Posted on 2011-03-24
3
853 Views
Last Modified: 2012-08-13
Here's my code and some of the errors i get - the omitted errors are the same as those listed.

protected function DrawArrow(oSprite:Sprite, nColorIndex:Number, nStyle:Number)
{
            var star_commands:Vector.<int> = new Vector.<int>();
            star_commands.push(1, 2, 2, 2, 2);
            
            var star_coord:Vector.<Number> = new Vector.<Number>();
            star_coord.push(66,10, 23,127, 122,50, 10,49, 109,127);
            
            oSprite.graphics.beginFill( m_aScrollerColors[nColorIndex] );
            oSprite.graphics.drawPath( star_commands, star_coord );
            ...

CMenuScroller.as, Line 114      1120: Access of undefined property int.
CMenuScroller.as, Line 114      1120: Access of undefined property Number.
CMenuScroller.as, Line 114      1061: Call to a possibly undefined method drawPath through a reference with static type flash.display:Graphics.

Any ideas why this won't work?
With Thanks
0
Comment
Question by:jasonb2
3 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35220390
I guess you are wrong here:
 var star_commands:Vector.<int> = new Vector.<int>();
star_commands.push(1, 2, 2, 2, 2);
           
var star_coord:Vector.<Number> = new Vector.<Number>();
star_coord.push(66,10, 23,127, 122,50, 10,49, 109,127);

You will have to push the values individually.
 
var star_commands:Vector.<int> = new Vector.<int>();
star_commands.push(1);
star_commands.push(2);
star_commands.push(2);
star_commands.push(2);
star_commands.push(2);
            
var star_coord:Vector.<Number> = new Vector.<Number>();
star_coord.push(66);
star_coord.push(10);
star_coord.push(23);
star_coord.push(127);
star_coord.push(122);
star_coord.push(50);
star_coord.push(10);
star_coord.push(49);
star_coord.push(109);
star_coord.push(127);

Open in new window


Warm Regards
Deepanjan Das
0
 
LVL 4

Accepted Solution

by:
ute_arbeit earned 125 total points
ID: 35224653
The code creating and filing the vectors seems ok. You don't have to push the values one by one, Vector.push takes multiple arguments.
Also the rest of your code with the call to drawPath seems ok to me.

The only thing I can imagine is that you did not set ActionScript 3.0 as the scripting language for your file. If it is set to ActionScript 2.0 all the Vector stuff is not supported and you get compiler errors.
Please make sure you have ActionScript 3.0 set in your settings for publishing.
0
 

Author Comment

by:jasonb2
ID: 35228221
thanks guys.
I got it to work.
I changed the 'player' setting in 'publish settings' from 'player 9' to 'player 10".
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question