How come my XML file ain't doing nothin' as a code snippet?
Copy link to clipboard
Copied
Hello people,
I made an XML file as follows. (See below - don't worry about the code & description, they're to be updated.)
When I go to the Code Snippets panel in Flash CS6 and click on "Import code snippets XML", and I click on my xml document, all seems to go well - but there is no added code snippet in my panel.
Anyone have any idea what's going wrong, here?
Thanks!
<?xml version='1.0' encoding='us-ascii'?>
<snippet>
<title>Draw a circle</title>
<description>Draw a circle with (xcenter,ycenter) as middle point and a width of someNumber pixels.</description>
<requiresSymbol>false</requiresSymbol>
<code><![CDATA[
var myCircle:Shape = new Shape();
myCircle.graphics.beginFill(0x00CCFF);
myCircle.graphics.lineStyle(20, 0xCCCC99);
myCircle.graphics.drawCircle(130, 130, 100);
myCircle.graphics.endFill();
addChild(myCircle);
]]></code>
</snippet>
Copy link to clipboard
Copied
it's not clear you're loading that xml, but even if you do that successfully the loaded strings will NOT be interpreted by flash as code.
Copy link to clipboard
Copied
Any idea how to do it, kglad? I thought I was following Adobe's instructions faithfully.
This is what Flash says to do:
To create your own code snippets copy the following empty one and paste it into the
category where you want it to appear.
<snippet isBranch="false">
<title>Custom Snippet</title>
<description>This is an example of a custom code snippet.</description>
<requiresSymbol>true</requiresSymbol>
<code><![CDATA[
// Code goes here
trace("A custom code snippet");
]]></code>
</snippet>
Of course, I can paste my code, and that works. But I want to make a separate XML file for use by other people, so this is the way I have to do it. And there IS the button "Import Code Snippets XML".
There has to be a way to do this, but I can't find it anywhere.
Any light on this, kglad? Or someone else
Ehrenfest
Copy link to clipboard
Copied
oops, my error.
i thought you were loading the xml dynamically using the urlloader.
after importing your xml what happens if you double click your code snippet while the actions panel is open and has focus?
Copy link to clipboard
Copied
That's the sad thing, k -
I click on Import Code Snippets XML, after which a window appears for me to browse to my xml file, I click on that xml file and the subwindow of the Code Snippets panel dutifully disappears. But....nothing happens. My code snippet does not show anywhere. Not in the Code Snippets window, where it should be (under Custom), nor even in the code that appears when you click "Edit Code Snippets XML".
Hence my wonderment: why did nothing get done with it?
Copy link to clipboard
Copied
1. open your snippets panel
2. click the setting icon (gear) and select export>save to a location you can remember
3. open that xml file in an xml/text editor and add your snippet above the go to web page snippet.
4. save
5. in flash import that file and open the actions folder and find your custom snippet. after selecting an onstage object double click your custom snippet.
Copy link to clipboard
Copied
Things are a bit weird, k -
I tried to do as you suggested. I selected Export Code Snippets XML, and named that file ExportedSnippets.xml when saving.
When I opened it in my text editor, I was surprised to find only text. I don't see any actual XML in it. When I pasted my XML code snippet, Word warned me that the result would not be a well-formed XML file; that the result would not be readable to any program trying to open it.
Where's the XML, I wonder? I paste here a chunk from that ExportedSnippets.xml file, so you can see what I mean:
3
Click_to_Set_Video_Source
/* Click To Set Video Source (Requires FLVPlayback) Clicking on the specified symbol instance plays a new video file in the specified FLVPlayback component instance. The specified FLVPlayback component instance will pause. Instructions: 1. Replace video_instance_name below with the instance name of the FLVPlayback component that you want to play the new video file. 2. Replace "http://www.helpexamples.com/flash/video/water.flv" below with the URL of the new video file you want to play. Keep the quotation marks (""). */ instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToSetSource); function fl_ClickToSetSource(event:MouseEvent):void { video_instance_name.source = "http://www.helpexamples.com/flash/video/water.flv"; }
Click to Seek to Cue Point
Clicking the specified object seeks to a cue point of the video in an FLVPlayback component.
true
3
Click_to_Seek_to_Cue_Point
/* Click to Seek to Cue Point (Requires FLVPlayback component) Clicking on the specified symbol instance seeks to a cue point of the video in the specified FLVPlayback component instance. Instructions: 1. Replace video_instance_name below with the instance name of the FLVPlayback component that you want to seek. 2. Replace "Cue Point 1" below with the name of the cue point to seek to. Keep the quotation marks (""). */ instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint); function fl_ClickToSeekToCuePoint(event:MouseEvent):void { // Replace video_instance_name with the instance name of the video component. // Replace "Cue Point 1" with the name of the cue point to seek to. var cuePointInstance:Object = video_instance_name.findCuePoint("Cue Point 1"); video_instance_name.seek(cuePointInstance.time); }
Create a NetStream Video
Begins playing a video file without using the FLVPlayback component.
false
3
Create_a_NetStream_Video
/* Create a NetStream Video Displays a video on stage without using the FLVPlayback video component. Instructions: 1. If you are connecting to a video file that is on a streaming server such as Adobe Flash Media Server 2, replace 'null' below with the URL address of the video file. Place quotation marks ("") around the URL address. 2. If you are connecting to a local video file or one that is not using a streaming server, leave 'null' in place below. 3. Replace "http://www.helpexamples.com/flash/video/water.flv" with the URL of the video you want to play. Keep the quotation marks (""). */ var fl_NC:NetConnection = new NetConnection(); fl_NC.connect(null); // starts a connection; null is used unless using Flash Media Server var fl_NS:NetStream = new NetStream(fl_NC); fl_NS.client = {}; var fl_Vid:Video = new Video(); fl_Vid.attachNetStream(fl_NS); addChild(fl_Vid); fl_NS.play("http://www.helpexamples.com/flash/video/water.flv");
Mouse Click Event
Clicking on the specified object executes a function containing your custom code.
true
3
Mouse_Click_Event
/* Mouse Click Event Clicking on the specified symbol instance executes a function in which you can add your own custom code. Instructions: 1. Add your custom code on a new line after the line that says "// Start your custom code" below. The code will execute when the symbol instance is clicked. */ instance_name_here.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler); function fl_MouseClickHandler(event:MouseEvent):void { // Start your custom code // This example code displays the words "Mouse clicked" in the Output panel. trace("Mouse clicked"); // End your custom code }
Mouse Over Event
Mousing over the specified object executes a function containing your custom code.
true
3
Mouse_Over_Event
/* Mouse Over Event Mousing over the symbol instance executes a function in which you can add your own custom code. Instructions: 1. Add your custom code on a new line after the line that says "// Start your custom code" below. The code will execute when the symbol instance is moused over. */ instance_name_here.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler); function fl_MouseOverHandler(event:MouseEvent):void { // Start your custom code // This example code displays the words "Moused over" in the Output panel. trace("Moused over"); // End your custom code }
Copy link to clipboard
Copied
download http://www.kglad.com/Files/forums/snippets.zip and extract the xml.
import it using your snippets panel. then follow the above directions BUT do not open in word. you must use a plain text editor like wordpad or textpad.

