Solved

Actionscript 3 sprite.graphics.drawPath function not working

Posted on 2011-03-24
3
847 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now