Solved

Actionscript 3 sprite.graphics.drawPath function not working

Posted on 2011-03-24
3
878 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

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 Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

615 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